@samitouri / QOS-React-2 / commits / 47e9a2b8a5

[FeatureFlag] add enableTreatHooksAsFunctions

Mofei Zhang committed May 22, 2023 at 19:37 UTC 47e9a2b8a5d2161324edfbd2f805227e88fb4313
1 file changed +13
compiler/forget/src/HIR/Environment.ts
+13
@@ -80,6 +80,16 @@ export type EnvironmentConfig = Partial<{
80 * Defaults to false
81 */
82 enableAssumeHooksFollowRulesOfReact: boolean;
83 +
84 + /**
85 + * When enabled, the compiler treats hooks as normal typed functions for
86 + * type and effect inference.
87 + * Enabling this may change inference to have a higher confidence level
88 + * and create more bailouts (e.g. for mutable effects to immutable values).
89 + *
90 + * Defaults to false
91 + */
92 + enableTreatHooksAsFunctions: boolean;
93 }>;
94
95 export class Environment {
@@ -90,6 +100,7 @@ export class Environment {
100 validateHooksUsage: boolean;
101 enableFunctionCallSignatureOptimizations: boolean;
102 enableAssumeHooksFollowRulesOfReact: boolean;
103 + enableTreatHooksAsFunctions: boolean;
104 #contextIdentifiers: Set<t.Identifier>;
105
106 constructor(
@@ -118,6 +129,8 @@ export class Environment {
129 config?.enableFunctionCallSignatureOptimizations ?? false;
130 this.enableAssumeHooksFollowRulesOfReact =
131 config?.enableAssumeHooksFollowRulesOfReact ?? false;
132 + this.enableTreatHooksAsFunctions =
133 + config?.enableTreatHooksAsFunctions ?? false;
134 this.#contextIdentifiers = contextIdentifiers;
135 }
136