babel-plugin-react-compiler 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.d.ts +1705 -0
- package/dist/index.js +108748 -0
- package/package.json +66 -6
package/dist/index.d.ts
ADDED
@@ -0,0 +1,1705 @@
|
|
1
|
+
import * as BabelCore from '@babel/core';
|
2
|
+
import { NodePath as NodePath$1 } from '@babel/core';
|
3
|
+
import * as t from '@babel/types';
|
4
|
+
import { z } from 'zod';
|
5
|
+
import { NodePath, Scope } from '@babel/traverse';
|
6
|
+
|
7
|
+
interface Result<T, E> {
|
8
|
+
map<U>(fn: (val: T) => U): Result<U, E>;
|
9
|
+
mapErr<F>(fn: (val: E) => F): Result<T, F>;
|
10
|
+
mapOr<U>(fallback: U, fn: (val: T) => U): U;
|
11
|
+
mapOrElse<U>(fallback: () => U, fn: (val: T) => U): U;
|
12
|
+
andThen<U>(fn: (val: T) => Result<U, E>): Result<U, E>;
|
13
|
+
and<U>(res: Result<U, E>): Result<U, E>;
|
14
|
+
or(res: Result<T, E>): Result<T, E>;
|
15
|
+
orElse<F>(fn: (val: E) => Result<T, F>): Result<T, F>;
|
16
|
+
isOk(): this is OkImpl<T>;
|
17
|
+
isErr(): this is ErrImpl<E>;
|
18
|
+
expect(msg: string): T;
|
19
|
+
expectErr(msg: string): E;
|
20
|
+
unwrap(): T;
|
21
|
+
unwrapOr(fallback: T): T;
|
22
|
+
unwrapOrElse(fallback: (val: E) => T): T;
|
23
|
+
unwrapErr(): E;
|
24
|
+
}
|
25
|
+
declare class OkImpl<T> implements Result<T, never> {
|
26
|
+
#private;
|
27
|
+
constructor(val: T);
|
28
|
+
map<U>(fn: (val: T) => U): Result<U, never>;
|
29
|
+
mapErr<F>(_fn: (val: never) => F): Result<T, F>;
|
30
|
+
mapOr<U>(_fallback: U, fn: (val: T) => U): U;
|
31
|
+
mapOrElse<U>(_fallback: () => U, fn: (val: T) => U): U;
|
32
|
+
andThen<U>(fn: (val: T) => Result<U, never>): Result<U, never>;
|
33
|
+
and<U>(res: Result<U, never>): Result<U, never>;
|
34
|
+
or(_res: Result<T, never>): Result<T, never>;
|
35
|
+
orElse<F>(_fn: (val: never) => Result<T, F>): Result<T, F>;
|
36
|
+
isOk(): this is OkImpl<T>;
|
37
|
+
isErr(): this is ErrImpl<never>;
|
38
|
+
expect(_msg: string): T;
|
39
|
+
expectErr(msg: string): never;
|
40
|
+
unwrap(): T;
|
41
|
+
unwrapOr(_fallback: T): T;
|
42
|
+
unwrapOrElse(_fallback: (val: never) => T): T;
|
43
|
+
unwrapErr(): never;
|
44
|
+
}
|
45
|
+
declare class ErrImpl<E> implements Result<never, E> {
|
46
|
+
#private;
|
47
|
+
constructor(val: E);
|
48
|
+
map<U>(_fn: (val: never) => U): Result<U, E>;
|
49
|
+
mapErr<F>(fn: (val: E) => F): Result<never, F>;
|
50
|
+
mapOr<U>(fallback: U, _fn: (val: never) => U): U;
|
51
|
+
mapOrElse<U>(fallback: () => U, _fn: (val: never) => U): U;
|
52
|
+
andThen<U>(_fn: (val: never) => Result<U, E>): Result<U, E>;
|
53
|
+
and<U>(_res: Result<U, E>): Result<U, E>;
|
54
|
+
or(res: Result<never, E>): Result<never, E>;
|
55
|
+
orElse<F>(fn: (val: E) => ErrImpl<F>): Result<never, F>;
|
56
|
+
isOk(): this is OkImpl<never>;
|
57
|
+
isErr(): this is ErrImpl<E>;
|
58
|
+
expect(msg: string): never;
|
59
|
+
expectErr(_msg: string): E;
|
60
|
+
unwrap(): never;
|
61
|
+
unwrapOr<T>(fallback: T): T;
|
62
|
+
unwrapOrElse<T>(fallback: (val: E) => T): T;
|
63
|
+
unwrapErr(): E;
|
64
|
+
}
|
65
|
+
|
66
|
+
type AliasingEffect = {
|
67
|
+
kind: 'Freeze';
|
68
|
+
value: Place;
|
69
|
+
reason: ValueReason;
|
70
|
+
} | {
|
71
|
+
kind: 'Mutate';
|
72
|
+
value: Place;
|
73
|
+
reason?: MutationReason | null;
|
74
|
+
} | {
|
75
|
+
kind: 'MutateConditionally';
|
76
|
+
value: Place;
|
77
|
+
} | {
|
78
|
+
kind: 'MutateTransitive';
|
79
|
+
value: Place;
|
80
|
+
} | {
|
81
|
+
kind: 'MutateTransitiveConditionally';
|
82
|
+
value: Place;
|
83
|
+
} | {
|
84
|
+
kind: 'Capture';
|
85
|
+
from: Place;
|
86
|
+
into: Place;
|
87
|
+
} | {
|
88
|
+
kind: 'Alias';
|
89
|
+
from: Place;
|
90
|
+
into: Place;
|
91
|
+
} | {
|
92
|
+
kind: 'MaybeAlias';
|
93
|
+
from: Place;
|
94
|
+
into: Place;
|
95
|
+
} | {
|
96
|
+
kind: 'Assign';
|
97
|
+
from: Place;
|
98
|
+
into: Place;
|
99
|
+
} | {
|
100
|
+
kind: 'Create';
|
101
|
+
into: Place;
|
102
|
+
value: ValueKind;
|
103
|
+
reason: ValueReason;
|
104
|
+
} | {
|
105
|
+
kind: 'CreateFrom';
|
106
|
+
from: Place;
|
107
|
+
into: Place;
|
108
|
+
} | {
|
109
|
+
kind: 'ImmutableCapture';
|
110
|
+
from: Place;
|
111
|
+
into: Place;
|
112
|
+
} | {
|
113
|
+
kind: 'Apply';
|
114
|
+
receiver: Place;
|
115
|
+
function: Place;
|
116
|
+
mutatesFunction: boolean;
|
117
|
+
args: Array<Place | SpreadPattern | Hole>;
|
118
|
+
into: Place;
|
119
|
+
signature: FunctionSignature | null;
|
120
|
+
loc: SourceLocation;
|
121
|
+
} | {
|
122
|
+
kind: 'CreateFunction';
|
123
|
+
captures: Array<Place>;
|
124
|
+
function: FunctionExpression | ObjectMethod;
|
125
|
+
into: Place;
|
126
|
+
} | {
|
127
|
+
kind: 'MutateFrozen';
|
128
|
+
place: Place;
|
129
|
+
error: CompilerDiagnostic;
|
130
|
+
} | {
|
131
|
+
kind: 'MutateGlobal';
|
132
|
+
place: Place;
|
133
|
+
error: CompilerDiagnostic;
|
134
|
+
} | {
|
135
|
+
kind: 'Impure';
|
136
|
+
place: Place;
|
137
|
+
error: CompilerDiagnostic;
|
138
|
+
} | {
|
139
|
+
kind: 'Render';
|
140
|
+
place: Place;
|
141
|
+
};
|
142
|
+
type MutationReason = {
|
143
|
+
kind: 'AssignCurrentProperty';
|
144
|
+
};
|
145
|
+
type AliasingSignature = {
|
146
|
+
receiver: IdentifierId;
|
147
|
+
params: Array<IdentifierId>;
|
148
|
+
rest: IdentifierId | null;
|
149
|
+
returns: IdentifierId;
|
150
|
+
effects: Array<AliasingEffect>;
|
151
|
+
temporaries: Array<Place>;
|
152
|
+
};
|
153
|
+
|
154
|
+
type BuiltInType = PrimitiveType | FunctionType | ObjectType;
|
155
|
+
type Type = BuiltInType | PhiType | TypeVar | PolyType | PropType | ObjectMethod$1;
|
156
|
+
type PrimitiveType = {
|
157
|
+
kind: 'Primitive';
|
158
|
+
};
|
159
|
+
type FunctionType = {
|
160
|
+
kind: 'Function';
|
161
|
+
shapeId: string | null;
|
162
|
+
return: Type;
|
163
|
+
isConstructor: boolean;
|
164
|
+
};
|
165
|
+
type ObjectType = {
|
166
|
+
kind: 'Object';
|
167
|
+
shapeId: string | null;
|
168
|
+
};
|
169
|
+
type TypeVar = {
|
170
|
+
kind: 'Type';
|
171
|
+
id: TypeId;
|
172
|
+
};
|
173
|
+
type PolyType = {
|
174
|
+
kind: 'Poly';
|
175
|
+
};
|
176
|
+
type PhiType = {
|
177
|
+
kind: 'Phi';
|
178
|
+
operands: Array<Type>;
|
179
|
+
};
|
180
|
+
type PropType = {
|
181
|
+
kind: 'Property';
|
182
|
+
objectType: Type;
|
183
|
+
objectName: string;
|
184
|
+
propertyName: {
|
185
|
+
kind: 'literal';
|
186
|
+
value: PropertyLiteral;
|
187
|
+
} | {
|
188
|
+
kind: 'computed';
|
189
|
+
value: Type;
|
190
|
+
};
|
191
|
+
};
|
192
|
+
type ObjectMethod$1 = {
|
193
|
+
kind: 'ObjectMethod';
|
194
|
+
};
|
195
|
+
declare const opaqueTypeId: unique symbol;
|
196
|
+
type TypeId = number & {
|
197
|
+
[opaqueTypeId]: 'IdentifierId';
|
198
|
+
};
|
199
|
+
|
200
|
+
type HookKind = 'useContext' | 'useState' | 'useActionState' | 'useReducer' | 'useRef' | 'useEffect' | 'useLayoutEffect' | 'useInsertionEffect' | 'useMemo' | 'useCallback' | 'useTransition' | 'useImperativeHandle' | 'useEffectEvent' | 'Custom';
|
201
|
+
type FunctionSignature = {
|
202
|
+
positionalParams: Array<Effect>;
|
203
|
+
restParam: Effect | null;
|
204
|
+
returnType: BuiltInType | PolyType;
|
205
|
+
returnValueKind: ValueKind;
|
206
|
+
returnValueReason?: ValueReason;
|
207
|
+
calleeEffect: Effect;
|
208
|
+
hookKind: HookKind | null;
|
209
|
+
noAlias?: boolean;
|
210
|
+
mutableOnlyIfOperandsAreMutable?: boolean;
|
211
|
+
impure?: boolean;
|
212
|
+
knownIncompatible?: string | null | undefined;
|
213
|
+
canonicalName?: string;
|
214
|
+
aliasing?: AliasingSignature | null | undefined;
|
215
|
+
};
|
216
|
+
|
217
|
+
type Global = BuiltInType | PolyType;
|
218
|
+
|
219
|
+
type ResolvedType = {
|
220
|
+
kind: 'Concrete';
|
221
|
+
type: ConcreteType<ResolvedType>;
|
222
|
+
platform: Platform;
|
223
|
+
};
|
224
|
+
type ComponentType<T> = {
|
225
|
+
kind: 'Component';
|
226
|
+
props: Map<string, T>;
|
227
|
+
children: null | T;
|
228
|
+
};
|
229
|
+
type ConcreteType<T> = {
|
230
|
+
kind: 'Enum';
|
231
|
+
} | {
|
232
|
+
kind: 'Mixed';
|
233
|
+
} | {
|
234
|
+
kind: 'Number';
|
235
|
+
} | {
|
236
|
+
kind: 'String';
|
237
|
+
} | {
|
238
|
+
kind: 'Boolean';
|
239
|
+
} | {
|
240
|
+
kind: 'Void';
|
241
|
+
} | {
|
242
|
+
kind: 'Nullable';
|
243
|
+
type: T;
|
244
|
+
} | {
|
245
|
+
kind: 'Array';
|
246
|
+
element: T;
|
247
|
+
} | {
|
248
|
+
kind: 'Set';
|
249
|
+
element: T;
|
250
|
+
} | {
|
251
|
+
kind: 'Map';
|
252
|
+
key: T;
|
253
|
+
value: T;
|
254
|
+
} | {
|
255
|
+
kind: 'Function';
|
256
|
+
typeParameters: null | Array<TypeParameter<T>>;
|
257
|
+
params: Array<T>;
|
258
|
+
returnType: T;
|
259
|
+
} | ComponentType<T> | {
|
260
|
+
kind: 'Generic';
|
261
|
+
id: TypeParameterId;
|
262
|
+
bound: T;
|
263
|
+
} | {
|
264
|
+
kind: 'Object';
|
265
|
+
id: NominalId;
|
266
|
+
members: Map<string, ResolvedType>;
|
267
|
+
} | {
|
268
|
+
kind: 'Tuple';
|
269
|
+
id: NominalId;
|
270
|
+
members: Array<T>;
|
271
|
+
} | {
|
272
|
+
kind: 'Structural';
|
273
|
+
id: LinearId;
|
274
|
+
} | {
|
275
|
+
kind: 'Union';
|
276
|
+
members: Array<T>;
|
277
|
+
} | {
|
278
|
+
kind: 'Instance';
|
279
|
+
name: string;
|
280
|
+
members: Map<string, ResolvedType>;
|
281
|
+
};
|
282
|
+
type TypeParameter<T> = {
|
283
|
+
name: string;
|
284
|
+
id: TypeParameterId;
|
285
|
+
bound: T;
|
286
|
+
};
|
287
|
+
declare const opaqueLinearId: unique symbol;
|
288
|
+
type LinearId = number & {
|
289
|
+
[opaqueLinearId]: 'LinearId';
|
290
|
+
};
|
291
|
+
declare const opaqueTypeParameterId: unique symbol;
|
292
|
+
type TypeParameterId = number & {
|
293
|
+
[opaqueTypeParameterId]: 'TypeParameterId';
|
294
|
+
};
|
295
|
+
declare const opaqueNominalId: unique symbol;
|
296
|
+
type NominalId = number & {
|
297
|
+
[opaqueNominalId]: 'NominalId';
|
298
|
+
};
|
299
|
+
type Platform = 'client' | 'server' | 'shared';
|
300
|
+
interface ITypeEnv {
|
301
|
+
popGeneric(name: string): void;
|
302
|
+
getGeneric(name: string): null | TypeParameter<ResolvedType>;
|
303
|
+
pushGeneric(name: string, binding: {
|
304
|
+
name: string;
|
305
|
+
id: TypeParameterId;
|
306
|
+
bound: ResolvedType;
|
307
|
+
}): void;
|
308
|
+
getType(id: Identifier): ResolvedType;
|
309
|
+
getTypeOrNull(id: Identifier): ResolvedType | null;
|
310
|
+
setType(id: Identifier, type: ResolvedType): void;
|
311
|
+
nextNominalId(): NominalId;
|
312
|
+
nextTypeParameterId(): TypeParameterId;
|
313
|
+
moduleEnv: Map<string, ResolvedType>;
|
314
|
+
addBinding(bindingIdentifier: t.Identifier, type: ResolvedType): void;
|
315
|
+
resolveBinding(bindingIdentifier: t.Identifier): ResolvedType | null;
|
316
|
+
}
|
317
|
+
declare class FlowTypeEnv implements ITypeEnv {
|
318
|
+
#private;
|
319
|
+
moduleEnv: Map<string, ResolvedType>;
|
320
|
+
init(env: Environment, source: string): void;
|
321
|
+
setType(identifier: Identifier, type: ResolvedType): void;
|
322
|
+
getType(identifier: Identifier): ResolvedType;
|
323
|
+
getTypeOrNull(identifier: Identifier): ResolvedType | null;
|
324
|
+
getTypeByLoc(loc: SourceLocation): ResolvedType | null;
|
325
|
+
nextNominalId(): NominalId;
|
326
|
+
nextTypeParameterId(): TypeParameterId;
|
327
|
+
addBinding(bindingIdentifier: t.Identifier, type: ResolvedType): void;
|
328
|
+
resolveBinding(bindingIdentifier: t.Identifier): ResolvedType | null;
|
329
|
+
pushGeneric(name: string, generic: TypeParameter<ResolvedType>): void;
|
330
|
+
popGeneric(name: string): void;
|
331
|
+
getGeneric(name: string): null | TypeParameter<ResolvedType>;
|
332
|
+
}
|
333
|
+
|
334
|
+
declare const ExternalFunctionSchema: z.ZodObject<{
|
335
|
+
source: z.ZodString;
|
336
|
+
importSpecifierName: z.ZodString;
|
337
|
+
}, z.core.$strip>;
|
338
|
+
type ExternalFunction = z.infer<typeof ExternalFunctionSchema>;
|
339
|
+
type CompilerMode = 'all_features' | 'no_inferred_memo';
|
340
|
+
declare const HookSchema: z.ZodObject<{
|
341
|
+
effectKind: z.ZodEnum<typeof Effect>;
|
342
|
+
valueKind: z.ZodEnum<typeof ValueKind>;
|
343
|
+
noAlias: z.ZodDefault<z.ZodBoolean>;
|
344
|
+
transitiveMixedData: z.ZodDefault<z.ZodBoolean>;
|
345
|
+
}, z.core.$strip>;
|
346
|
+
type Hook = z.infer<typeof HookSchema>;
|
347
|
+
declare const EnvironmentConfigSchema: z.ZodObject<{
|
348
|
+
customHooks: z.ZodDefault<z.ZodMap<z.ZodString, z.ZodObject<{
|
349
|
+
effectKind: z.ZodEnum<typeof Effect>;
|
350
|
+
valueKind: z.ZodEnum<typeof ValueKind>;
|
351
|
+
noAlias: z.ZodDefault<z.ZodBoolean>;
|
352
|
+
transitiveMixedData: z.ZodDefault<z.ZodBoolean>;
|
353
|
+
}, z.core.$strip>>>;
|
354
|
+
moduleTypeProvider: z.ZodDefault<z.ZodNullable<z.ZodAny>>;
|
355
|
+
customMacros: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
356
|
+
type: z.ZodLiteral<"wildcard">;
|
357
|
+
}, z.core.$strip>, z.ZodObject<{
|
358
|
+
type: z.ZodLiteral<"name">;
|
359
|
+
name: z.ZodString;
|
360
|
+
}, z.core.$strip>]>>], null>]>>>>;
|
361
|
+
enableResetCacheOnSourceFileChanges: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
|
362
|
+
enablePreserveExistingMemoizationGuarantees: z.ZodDefault<z.ZodBoolean>;
|
363
|
+
validatePreserveExistingMemoizationGuarantees: z.ZodDefault<z.ZodBoolean>;
|
364
|
+
enablePreserveExistingManualUseMemo: z.ZodDefault<z.ZodBoolean>;
|
365
|
+
enableForest: z.ZodDefault<z.ZodBoolean>;
|
366
|
+
enableUseTypeAnnotations: z.ZodDefault<z.ZodBoolean>;
|
367
|
+
flowTypeProvider: z.ZodDefault<z.ZodNullable<z.ZodAny>>;
|
368
|
+
enableOptionalDependencies: z.ZodDefault<z.ZodBoolean>;
|
369
|
+
enableFire: z.ZodDefault<z.ZodBoolean>;
|
370
|
+
enableNameAnonymousFunctions: z.ZodDefault<z.ZodBoolean>;
|
371
|
+
inferEffectDependencies: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
372
|
+
function: z.ZodObject<{
|
373
|
+
source: z.ZodString;
|
374
|
+
importSpecifierName: z.ZodString;
|
375
|
+
}, z.core.$strip>;
|
376
|
+
autodepsIndex: z.ZodNumber;
|
377
|
+
}, z.core.$strip>>>>;
|
378
|
+
inlineJsxTransform: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
379
|
+
elementSymbol: z.ZodUnion<readonly [z.ZodLiteral<"react.element">, z.ZodLiteral<"react.transitional.element">]>;
|
380
|
+
globalDevVar: z.ZodString;
|
381
|
+
}, z.core.$strip>>>;
|
382
|
+
validateHooksUsage: z.ZodDefault<z.ZodBoolean>;
|
383
|
+
validateRefAccessDuringRender: z.ZodDefault<z.ZodBoolean>;
|
384
|
+
validateNoSetStateInRender: z.ZodDefault<z.ZodBoolean>;
|
385
|
+
validateNoSetStateInEffects: z.ZodDefault<z.ZodBoolean>;
|
386
|
+
validateNoDerivedComputationsInEffects: z.ZodDefault<z.ZodBoolean>;
|
387
|
+
validateNoJSXInTryStatements: z.ZodDefault<z.ZodBoolean>;
|
388
|
+
validateStaticComponents: z.ZodDefault<z.ZodBoolean>;
|
389
|
+
validateMemoizedEffectDependencies: z.ZodDefault<z.ZodBoolean>;
|
390
|
+
validateNoCapitalizedCalls: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
391
|
+
validateBlocklistedImports: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
392
|
+
validateNoImpureFunctionsInRender: z.ZodDefault<z.ZodBoolean>;
|
393
|
+
validateNoFreezingKnownMutableFunctions: z.ZodDefault<z.ZodBoolean>;
|
394
|
+
enableAssumeHooksFollowRulesOfReact: z.ZodDefault<z.ZodBoolean>;
|
395
|
+
enableTransitivelyFreezeFunctionExpressions: z.ZodDefault<z.ZodBoolean>;
|
396
|
+
enableEmitFreeze: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
397
|
+
source: z.ZodString;
|
398
|
+
importSpecifierName: z.ZodString;
|
399
|
+
}, z.core.$strip>>>;
|
400
|
+
enableEmitHookGuards: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
401
|
+
source: z.ZodString;
|
402
|
+
importSpecifierName: z.ZodString;
|
403
|
+
}, z.core.$strip>>>;
|
404
|
+
enableInstructionReordering: z.ZodDefault<z.ZodBoolean>;
|
405
|
+
enableFunctionOutlining: z.ZodDefault<z.ZodBoolean>;
|
406
|
+
enableJsxOutlining: z.ZodDefault<z.ZodBoolean>;
|
407
|
+
enableEmitInstrumentForget: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
408
|
+
fn: z.ZodObject<{
|
409
|
+
source: z.ZodString;
|
410
|
+
importSpecifierName: z.ZodString;
|
411
|
+
}, z.core.$strip>;
|
412
|
+
gating: z.ZodNullable<z.ZodObject<{
|
413
|
+
source: z.ZodString;
|
414
|
+
importSpecifierName: z.ZodString;
|
415
|
+
}, z.core.$strip>>;
|
416
|
+
globalGating: z.ZodNullable<z.ZodString>;
|
417
|
+
}, z.core.$strip>>>;
|
418
|
+
assertValidMutableRanges: z.ZodDefault<z.ZodBoolean>;
|
419
|
+
enableChangeVariableCodegen: z.ZodDefault<z.ZodBoolean>;
|
420
|
+
enableMemoizationComments: z.ZodDefault<z.ZodBoolean>;
|
421
|
+
throwUnknownException__testonly: z.ZodDefault<z.ZodBoolean>;
|
422
|
+
enableTreatFunctionDepsAsConditional: z.ZodDefault<z.ZodBoolean>;
|
423
|
+
disableMemoizationForDebugging: z.ZodDefault<z.ZodBoolean>;
|
424
|
+
enableChangeDetectionForDebugging: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
425
|
+
source: z.ZodString;
|
426
|
+
importSpecifierName: z.ZodString;
|
427
|
+
}, z.core.$strip>>>;
|
428
|
+
enableCustomTypeDefinitionForReanimated: z.ZodDefault<z.ZodBoolean>;
|
429
|
+
hookPattern: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
430
|
+
enableTreatRefLikeIdentifiersAsRefs: z.ZodDefault<z.ZodBoolean>;
|
431
|
+
enableTreatSetIdentifiersAsStateSetters: z.ZodDefault<z.ZodBoolean>;
|
432
|
+
lowerContextAccess: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
433
|
+
source: z.ZodString;
|
434
|
+
importSpecifierName: z.ZodString;
|
435
|
+
}, z.core.$strip>>>;
|
436
|
+
validateNoVoidUseMemo: z.ZodDefault<z.ZodBoolean>;
|
437
|
+
validateNoDynamicallyCreatedComponentsOrHooks: z.ZodDefault<z.ZodBoolean>;
|
438
|
+
enableAllowSetStateFromRefsInEffects: z.ZodDefault<z.ZodBoolean>;
|
439
|
+
}, z.core.$strip>;
|
440
|
+
type EnvironmentConfig = z.infer<typeof EnvironmentConfigSchema>;
|
441
|
+
type PartialEnvironmentConfig = Partial<EnvironmentConfig>;
|
442
|
+
type ReactFunctionType = 'Component' | 'Hook' | 'Other';
|
443
|
+
declare class Environment {
|
444
|
+
#private;
|
445
|
+
logger: Logger | null;
|
446
|
+
filename: string | null;
|
447
|
+
code: string | null;
|
448
|
+
config: EnvironmentConfig;
|
449
|
+
fnType: ReactFunctionType;
|
450
|
+
compilerMode: CompilerMode;
|
451
|
+
programContext: ProgramContext;
|
452
|
+
hasFireRewrite: boolean;
|
453
|
+
hasInferredEffect: boolean;
|
454
|
+
inferredEffectLocations: Set<SourceLocation>;
|
455
|
+
parentFunction: NodePath<t.Function>;
|
456
|
+
constructor(scope: Scope, fnType: ReactFunctionType, compilerMode: CompilerMode, config: EnvironmentConfig, contextIdentifiers: Set<t.Identifier>, parentFunction: NodePath<t.Function>, logger: Logger | null, filename: string | null, code: string | null, programContext: ProgramContext);
|
457
|
+
get typeContext(): FlowTypeEnv;
|
458
|
+
get isInferredMemoEnabled(): boolean;
|
459
|
+
get nextIdentifierId(): IdentifierId;
|
460
|
+
get nextBlockId(): BlockId;
|
461
|
+
get nextScopeId(): ScopeId;
|
462
|
+
get scope(): Scope;
|
463
|
+
logErrors(errors: Result<void, CompilerError>): void;
|
464
|
+
isContextIdentifier(node: t.Identifier): boolean;
|
465
|
+
isHoistedIdentifier(node: t.Identifier): boolean;
|
466
|
+
generateGloballyUniqueIdentifierName(name: string | null): ValidatedIdentifier;
|
467
|
+
outlineFunction(fn: HIRFunction, type: ReactFunctionType | null): void;
|
468
|
+
getOutlinedFunctions(): Array<{
|
469
|
+
fn: HIRFunction;
|
470
|
+
type: ReactFunctionType | null;
|
471
|
+
}>;
|
472
|
+
getGlobalDeclaration(binding: NonLocalBinding, loc: SourceLocation): Global | null;
|
473
|
+
static knownReactModules: ReadonlyArray<string>;
|
474
|
+
getFallthroughPropertyType(receiver: Type, _property: Type): BuiltInType | PolyType | null;
|
475
|
+
getPropertyType(receiver: Type, property: string | number): BuiltInType | PolyType | null;
|
476
|
+
getFunctionSignature(type: FunctionType): FunctionSignature | null;
|
477
|
+
addHoistedIdentifier(node: t.Identifier): void;
|
478
|
+
}
|
479
|
+
declare function validateEnvironmentConfig(partialConfig: PartialEnvironmentConfig): EnvironmentConfig;
|
480
|
+
|
481
|
+
declare const GeneratedSource: unique symbol;
|
482
|
+
type SourceLocation = t.SourceLocation | typeof GeneratedSource;
|
483
|
+
type ReactiveFunction = {
|
484
|
+
loc: SourceLocation;
|
485
|
+
id: ValidIdentifierName | null;
|
486
|
+
nameHint: string | null;
|
487
|
+
params: Array<Place | SpreadPattern>;
|
488
|
+
generator: boolean;
|
489
|
+
async: boolean;
|
490
|
+
body: ReactiveBlock;
|
491
|
+
env: Environment;
|
492
|
+
directives: Array<string>;
|
493
|
+
};
|
494
|
+
type ReactiveScopeBlock = {
|
495
|
+
kind: 'scope';
|
496
|
+
scope: ReactiveScope;
|
497
|
+
instructions: ReactiveBlock;
|
498
|
+
};
|
499
|
+
type PrunedReactiveScopeBlock = {
|
500
|
+
kind: 'pruned-scope';
|
501
|
+
scope: ReactiveScope;
|
502
|
+
instructions: ReactiveBlock;
|
503
|
+
};
|
504
|
+
type ReactiveBlock = Array<ReactiveStatement>;
|
505
|
+
type ReactiveStatement = ReactiveInstructionStatement | ReactiveTerminalStatement | ReactiveScopeBlock | PrunedReactiveScopeBlock;
|
506
|
+
type ReactiveInstructionStatement = {
|
507
|
+
kind: 'instruction';
|
508
|
+
instruction: ReactiveInstruction;
|
509
|
+
};
|
510
|
+
type ReactiveTerminalStatement<Tterminal extends ReactiveTerminal = ReactiveTerminal> = {
|
511
|
+
kind: 'terminal';
|
512
|
+
terminal: Tterminal;
|
513
|
+
label: {
|
514
|
+
id: BlockId;
|
515
|
+
implicit: boolean;
|
516
|
+
} | null;
|
517
|
+
};
|
518
|
+
type ReactiveInstruction = {
|
519
|
+
id: InstructionId;
|
520
|
+
lvalue: Place | null;
|
521
|
+
value: ReactiveValue;
|
522
|
+
effects?: Array<AliasingEffect> | null;
|
523
|
+
loc: SourceLocation;
|
524
|
+
};
|
525
|
+
type ReactiveValue = InstructionValue | ReactiveLogicalValue | ReactiveSequenceValue | ReactiveTernaryValue | ReactiveOptionalCallValue;
|
526
|
+
type ReactiveLogicalValue = {
|
527
|
+
kind: 'LogicalExpression';
|
528
|
+
operator: t.LogicalExpression['operator'];
|
529
|
+
left: ReactiveValue;
|
530
|
+
right: ReactiveValue;
|
531
|
+
loc: SourceLocation;
|
532
|
+
};
|
533
|
+
type ReactiveTernaryValue = {
|
534
|
+
kind: 'ConditionalExpression';
|
535
|
+
test: ReactiveValue;
|
536
|
+
consequent: ReactiveValue;
|
537
|
+
alternate: ReactiveValue;
|
538
|
+
loc: SourceLocation;
|
539
|
+
};
|
540
|
+
type ReactiveSequenceValue = {
|
541
|
+
kind: 'SequenceExpression';
|
542
|
+
instructions: Array<ReactiveInstruction>;
|
543
|
+
id: InstructionId;
|
544
|
+
value: ReactiveValue;
|
545
|
+
loc: SourceLocation;
|
546
|
+
};
|
547
|
+
type ReactiveOptionalCallValue = {
|
548
|
+
kind: 'OptionalExpression';
|
549
|
+
id: InstructionId;
|
550
|
+
value: ReactiveValue;
|
551
|
+
optional: boolean;
|
552
|
+
loc: SourceLocation;
|
553
|
+
};
|
554
|
+
type ReactiveTerminal = ReactiveBreakTerminal | ReactiveContinueTerminal | ReactiveReturnTerminal | ReactiveThrowTerminal | ReactiveSwitchTerminal | ReactiveDoWhileTerminal | ReactiveWhileTerminal | ReactiveForTerminal | ReactiveForOfTerminal | ReactiveForInTerminal | ReactiveIfTerminal | ReactiveLabelTerminal | ReactiveTryTerminal;
|
555
|
+
type ReactiveTerminalTargetKind = 'implicit' | 'labeled' | 'unlabeled';
|
556
|
+
type ReactiveBreakTerminal = {
|
557
|
+
kind: 'break';
|
558
|
+
target: BlockId;
|
559
|
+
id: InstructionId;
|
560
|
+
targetKind: ReactiveTerminalTargetKind;
|
561
|
+
loc: SourceLocation;
|
562
|
+
};
|
563
|
+
type ReactiveContinueTerminal = {
|
564
|
+
kind: 'continue';
|
565
|
+
target: BlockId;
|
566
|
+
id: InstructionId;
|
567
|
+
targetKind: ReactiveTerminalTargetKind;
|
568
|
+
loc: SourceLocation;
|
569
|
+
};
|
570
|
+
type ReactiveReturnTerminal = {
|
571
|
+
kind: 'return';
|
572
|
+
value: Place;
|
573
|
+
id: InstructionId;
|
574
|
+
loc: SourceLocation;
|
575
|
+
};
|
576
|
+
type ReactiveThrowTerminal = {
|
577
|
+
kind: 'throw';
|
578
|
+
value: Place;
|
579
|
+
id: InstructionId;
|
580
|
+
loc: SourceLocation;
|
581
|
+
};
|
582
|
+
type ReactiveSwitchTerminal = {
|
583
|
+
kind: 'switch';
|
584
|
+
test: Place;
|
585
|
+
cases: Array<{
|
586
|
+
test: Place | null;
|
587
|
+
block: ReactiveBlock | void;
|
588
|
+
}>;
|
589
|
+
id: InstructionId;
|
590
|
+
loc: SourceLocation;
|
591
|
+
};
|
592
|
+
type ReactiveDoWhileTerminal = {
|
593
|
+
kind: 'do-while';
|
594
|
+
loop: ReactiveBlock;
|
595
|
+
test: ReactiveValue;
|
596
|
+
id: InstructionId;
|
597
|
+
loc: SourceLocation;
|
598
|
+
};
|
599
|
+
type ReactiveWhileTerminal = {
|
600
|
+
kind: 'while';
|
601
|
+
test: ReactiveValue;
|
602
|
+
loop: ReactiveBlock;
|
603
|
+
id: InstructionId;
|
604
|
+
loc: SourceLocation;
|
605
|
+
};
|
606
|
+
type ReactiveForTerminal = {
|
607
|
+
kind: 'for';
|
608
|
+
init: ReactiveValue;
|
609
|
+
test: ReactiveValue;
|
610
|
+
update: ReactiveValue | null;
|
611
|
+
loop: ReactiveBlock;
|
612
|
+
id: InstructionId;
|
613
|
+
loc: SourceLocation;
|
614
|
+
};
|
615
|
+
type ReactiveForOfTerminal = {
|
616
|
+
kind: 'for-of';
|
617
|
+
init: ReactiveValue;
|
618
|
+
test: ReactiveValue;
|
619
|
+
loop: ReactiveBlock;
|
620
|
+
id: InstructionId;
|
621
|
+
loc: SourceLocation;
|
622
|
+
};
|
623
|
+
type ReactiveForInTerminal = {
|
624
|
+
kind: 'for-in';
|
625
|
+
init: ReactiveValue;
|
626
|
+
loop: ReactiveBlock;
|
627
|
+
id: InstructionId;
|
628
|
+
loc: SourceLocation;
|
629
|
+
};
|
630
|
+
type ReactiveIfTerminal = {
|
631
|
+
kind: 'if';
|
632
|
+
test: Place;
|
633
|
+
consequent: ReactiveBlock;
|
634
|
+
alternate: ReactiveBlock | null;
|
635
|
+
id: InstructionId;
|
636
|
+
loc: SourceLocation;
|
637
|
+
};
|
638
|
+
type ReactiveLabelTerminal = {
|
639
|
+
kind: 'label';
|
640
|
+
block: ReactiveBlock;
|
641
|
+
id: InstructionId;
|
642
|
+
loc: SourceLocation;
|
643
|
+
};
|
644
|
+
type ReactiveTryTerminal = {
|
645
|
+
kind: 'try';
|
646
|
+
block: ReactiveBlock;
|
647
|
+
handlerBinding: Place | null;
|
648
|
+
handler: ReactiveBlock;
|
649
|
+
id: InstructionId;
|
650
|
+
loc: SourceLocation;
|
651
|
+
};
|
652
|
+
type HIRFunction = {
|
653
|
+
loc: SourceLocation;
|
654
|
+
id: ValidIdentifierName | null;
|
655
|
+
nameHint: string | null;
|
656
|
+
fnType: ReactFunctionType;
|
657
|
+
env: Environment;
|
658
|
+
params: Array<Place | SpreadPattern>;
|
659
|
+
returnTypeAnnotation: t.FlowType | t.TSType | null;
|
660
|
+
returns: Place;
|
661
|
+
context: Array<Place>;
|
662
|
+
body: HIR;
|
663
|
+
generator: boolean;
|
664
|
+
async: boolean;
|
665
|
+
directives: Array<string>;
|
666
|
+
aliasingEffects: Array<AliasingEffect> | null;
|
667
|
+
};
|
668
|
+
type HIR = {
|
669
|
+
entry: BlockId;
|
670
|
+
blocks: Map<BlockId, BasicBlock>;
|
671
|
+
};
|
672
|
+
type BlockKind = 'block' | 'value' | 'loop' | 'sequence' | 'catch';
|
673
|
+
type BasicBlock = {
|
674
|
+
kind: BlockKind;
|
675
|
+
id: BlockId;
|
676
|
+
instructions: Array<Instruction>;
|
677
|
+
terminal: Terminal;
|
678
|
+
preds: Set<BlockId>;
|
679
|
+
phis: Set<Phi>;
|
680
|
+
};
|
681
|
+
type Terminal = UnsupportedTerminal | UnreachableTerminal | ThrowTerminal | ReturnTerminal | GotoTerminal | IfTerminal | BranchTerminal | SwitchTerminal | ForTerminal | ForOfTerminal | ForInTerminal | DoWhileTerminal | WhileTerminal | LogicalTerminal | TernaryTerminal | OptionalTerminal | LabelTerminal | SequenceTerminal | MaybeThrowTerminal | TryTerminal | ReactiveScopeTerminal | PrunedScopeTerminal;
|
682
|
+
type UnsupportedTerminal = {
|
683
|
+
kind: 'unsupported';
|
684
|
+
id: InstructionId;
|
685
|
+
loc: SourceLocation;
|
686
|
+
fallthrough?: never;
|
687
|
+
};
|
688
|
+
type UnreachableTerminal = {
|
689
|
+
kind: 'unreachable';
|
690
|
+
id: InstructionId;
|
691
|
+
loc: SourceLocation;
|
692
|
+
fallthrough?: never;
|
693
|
+
};
|
694
|
+
type ThrowTerminal = {
|
695
|
+
kind: 'throw';
|
696
|
+
value: Place;
|
697
|
+
id: InstructionId;
|
698
|
+
loc: SourceLocation;
|
699
|
+
fallthrough?: never;
|
700
|
+
};
|
701
|
+
type Case = {
|
702
|
+
test: Place | null;
|
703
|
+
block: BlockId;
|
704
|
+
};
|
705
|
+
type ReturnVariant = 'Void' | 'Implicit' | 'Explicit';
|
706
|
+
type ReturnTerminal = {
|
707
|
+
kind: 'return';
|
708
|
+
returnVariant: ReturnVariant;
|
709
|
+
loc: SourceLocation;
|
710
|
+
value: Place;
|
711
|
+
id: InstructionId;
|
712
|
+
fallthrough?: never;
|
713
|
+
effects: Array<AliasingEffect> | null;
|
714
|
+
};
|
715
|
+
type GotoTerminal = {
|
716
|
+
kind: 'goto';
|
717
|
+
block: BlockId;
|
718
|
+
variant: GotoVariant;
|
719
|
+
id: InstructionId;
|
720
|
+
loc: SourceLocation;
|
721
|
+
fallthrough?: never;
|
722
|
+
};
|
723
|
+
declare enum GotoVariant {
|
724
|
+
Break = "Break",
|
725
|
+
Continue = "Continue",
|
726
|
+
Try = "Try"
|
727
|
+
}
|
728
|
+
type IfTerminal = {
|
729
|
+
kind: 'if';
|
730
|
+
test: Place;
|
731
|
+
consequent: BlockId;
|
732
|
+
alternate: BlockId;
|
733
|
+
fallthrough: BlockId;
|
734
|
+
id: InstructionId;
|
735
|
+
loc: SourceLocation;
|
736
|
+
};
|
737
|
+
type BranchTerminal = {
|
738
|
+
kind: 'branch';
|
739
|
+
test: Place;
|
740
|
+
consequent: BlockId;
|
741
|
+
alternate: BlockId;
|
742
|
+
id: InstructionId;
|
743
|
+
loc: SourceLocation;
|
744
|
+
fallthrough: BlockId;
|
745
|
+
};
|
746
|
+
type SwitchTerminal = {
|
747
|
+
kind: 'switch';
|
748
|
+
test: Place;
|
749
|
+
cases: Array<Case>;
|
750
|
+
fallthrough: BlockId;
|
751
|
+
id: InstructionId;
|
752
|
+
loc: SourceLocation;
|
753
|
+
};
|
754
|
+
type DoWhileTerminal = {
|
755
|
+
kind: 'do-while';
|
756
|
+
loop: BlockId;
|
757
|
+
test: BlockId;
|
758
|
+
fallthrough: BlockId;
|
759
|
+
id: InstructionId;
|
760
|
+
loc: SourceLocation;
|
761
|
+
};
|
762
|
+
type WhileTerminal = {
|
763
|
+
kind: 'while';
|
764
|
+
loc: SourceLocation;
|
765
|
+
test: BlockId;
|
766
|
+
loop: BlockId;
|
767
|
+
fallthrough: BlockId;
|
768
|
+
id: InstructionId;
|
769
|
+
};
|
770
|
+
type ForTerminal = {
|
771
|
+
kind: 'for';
|
772
|
+
loc: SourceLocation;
|
773
|
+
init: BlockId;
|
774
|
+
test: BlockId;
|
775
|
+
update: BlockId | null;
|
776
|
+
loop: BlockId;
|
777
|
+
fallthrough: BlockId;
|
778
|
+
id: InstructionId;
|
779
|
+
};
|
780
|
+
type ForOfTerminal = {
|
781
|
+
kind: 'for-of';
|
782
|
+
loc: SourceLocation;
|
783
|
+
init: BlockId;
|
784
|
+
test: BlockId;
|
785
|
+
loop: BlockId;
|
786
|
+
fallthrough: BlockId;
|
787
|
+
id: InstructionId;
|
788
|
+
};
|
789
|
+
type ForInTerminal = {
|
790
|
+
kind: 'for-in';
|
791
|
+
loc: SourceLocation;
|
792
|
+
init: BlockId;
|
793
|
+
loop: BlockId;
|
794
|
+
fallthrough: BlockId;
|
795
|
+
id: InstructionId;
|
796
|
+
};
|
797
|
+
type LogicalTerminal = {
|
798
|
+
kind: 'logical';
|
799
|
+
operator: t.LogicalExpression['operator'];
|
800
|
+
test: BlockId;
|
801
|
+
fallthrough: BlockId;
|
802
|
+
id: InstructionId;
|
803
|
+
loc: SourceLocation;
|
804
|
+
};
|
805
|
+
type TernaryTerminal = {
|
806
|
+
kind: 'ternary';
|
807
|
+
test: BlockId;
|
808
|
+
fallthrough: BlockId;
|
809
|
+
id: InstructionId;
|
810
|
+
loc: SourceLocation;
|
811
|
+
};
|
812
|
+
type LabelTerminal = {
|
813
|
+
kind: 'label';
|
814
|
+
block: BlockId;
|
815
|
+
fallthrough: BlockId;
|
816
|
+
id: InstructionId;
|
817
|
+
loc: SourceLocation;
|
818
|
+
};
|
819
|
+
type OptionalTerminal = {
|
820
|
+
kind: 'optional';
|
821
|
+
optional: boolean;
|
822
|
+
test: BlockId;
|
823
|
+
fallthrough: BlockId;
|
824
|
+
id: InstructionId;
|
825
|
+
loc: SourceLocation;
|
826
|
+
};
|
827
|
+
type SequenceTerminal = {
|
828
|
+
kind: 'sequence';
|
829
|
+
block: BlockId;
|
830
|
+
fallthrough: BlockId;
|
831
|
+
id: InstructionId;
|
832
|
+
loc: SourceLocation;
|
833
|
+
};
|
834
|
+
type TryTerminal = {
|
835
|
+
kind: 'try';
|
836
|
+
block: BlockId;
|
837
|
+
handlerBinding: Place | null;
|
838
|
+
handler: BlockId;
|
839
|
+
fallthrough: BlockId;
|
840
|
+
id: InstructionId;
|
841
|
+
loc: SourceLocation;
|
842
|
+
};
|
843
|
+
type MaybeThrowTerminal = {
|
844
|
+
kind: 'maybe-throw';
|
845
|
+
continuation: BlockId;
|
846
|
+
handler: BlockId;
|
847
|
+
id: InstructionId;
|
848
|
+
loc: SourceLocation;
|
849
|
+
fallthrough?: never;
|
850
|
+
effects: Array<AliasingEffect> | null;
|
851
|
+
};
|
852
|
+
type ReactiveScopeTerminal = {
|
853
|
+
kind: 'scope';
|
854
|
+
fallthrough: BlockId;
|
855
|
+
block: BlockId;
|
856
|
+
scope: ReactiveScope;
|
857
|
+
id: InstructionId;
|
858
|
+
loc: SourceLocation;
|
859
|
+
};
|
860
|
+
type PrunedScopeTerminal = {
|
861
|
+
kind: 'pruned-scope';
|
862
|
+
fallthrough: BlockId;
|
863
|
+
block: BlockId;
|
864
|
+
scope: ReactiveScope;
|
865
|
+
id: InstructionId;
|
866
|
+
loc: SourceLocation;
|
867
|
+
};
|
868
|
+
type Instruction = {
|
869
|
+
id: InstructionId;
|
870
|
+
lvalue: Place;
|
871
|
+
value: InstructionValue;
|
872
|
+
loc: SourceLocation;
|
873
|
+
effects: Array<AliasingEffect> | null;
|
874
|
+
};
|
875
|
+
type LValue = {
|
876
|
+
place: Place;
|
877
|
+
kind: InstructionKind;
|
878
|
+
};
|
879
|
+
type LValuePattern = {
|
880
|
+
pattern: Pattern;
|
881
|
+
kind: InstructionKind;
|
882
|
+
};
|
883
|
+
type ArrayExpression = {
|
884
|
+
kind: 'ArrayExpression';
|
885
|
+
elements: Array<Place | SpreadPattern | Hole>;
|
886
|
+
loc: SourceLocation;
|
887
|
+
};
|
888
|
+
type Pattern = ArrayPattern | ObjectPattern;
|
889
|
+
type Hole = {
|
890
|
+
kind: 'Hole';
|
891
|
+
};
|
892
|
+
type SpreadPattern = {
|
893
|
+
kind: 'Spread';
|
894
|
+
place: Place;
|
895
|
+
};
|
896
|
+
type ArrayPattern = {
|
897
|
+
kind: 'ArrayPattern';
|
898
|
+
items: Array<Place | SpreadPattern | Hole>;
|
899
|
+
};
|
900
|
+
type ObjectPattern = {
|
901
|
+
kind: 'ObjectPattern';
|
902
|
+
properties: Array<ObjectProperty | SpreadPattern>;
|
903
|
+
};
|
904
|
+
type ObjectPropertyKey = {
|
905
|
+
kind: 'string';
|
906
|
+
name: string;
|
907
|
+
} | {
|
908
|
+
kind: 'identifier';
|
909
|
+
name: string;
|
910
|
+
} | {
|
911
|
+
kind: 'computed';
|
912
|
+
name: Place;
|
913
|
+
} | {
|
914
|
+
kind: 'number';
|
915
|
+
name: number;
|
916
|
+
};
|
917
|
+
type ObjectProperty = {
|
918
|
+
kind: 'ObjectProperty';
|
919
|
+
key: ObjectPropertyKey;
|
920
|
+
type: 'property' | 'method';
|
921
|
+
place: Place;
|
922
|
+
};
|
923
|
+
type LoweredFunction = {
|
924
|
+
func: HIRFunction;
|
925
|
+
};
|
926
|
+
type ObjectMethod = {
|
927
|
+
kind: 'ObjectMethod';
|
928
|
+
loc: SourceLocation;
|
929
|
+
loweredFunc: LoweredFunction;
|
930
|
+
};
|
931
|
+
declare enum InstructionKind {
|
932
|
+
Const = "Const",
|
933
|
+
Let = "Let",
|
934
|
+
Reassign = "Reassign",
|
935
|
+
Catch = "Catch",
|
936
|
+
HoistedConst = "HoistedConst",
|
937
|
+
HoistedLet = "HoistedLet",
|
938
|
+
HoistedFunction = "HoistedFunction",
|
939
|
+
Function = "Function"
|
940
|
+
}
|
941
|
+
type Phi = {
|
942
|
+
kind: 'Phi';
|
943
|
+
place: Place;
|
944
|
+
operands: Map<BlockId, Place>;
|
945
|
+
};
|
946
|
+
type ManualMemoDependency = {
|
947
|
+
root: {
|
948
|
+
kind: 'NamedLocal';
|
949
|
+
value: Place;
|
950
|
+
} | {
|
951
|
+
kind: 'Global';
|
952
|
+
identifierName: string;
|
953
|
+
};
|
954
|
+
path: DependencyPath;
|
955
|
+
};
|
956
|
+
type StartMemoize = {
|
957
|
+
kind: 'StartMemoize';
|
958
|
+
manualMemoId: number;
|
959
|
+
deps: Array<ManualMemoDependency> | null;
|
960
|
+
loc: SourceLocation;
|
961
|
+
};
|
962
|
+
type FinishMemoize = {
|
963
|
+
kind: 'FinishMemoize';
|
964
|
+
manualMemoId: number;
|
965
|
+
decl: Place;
|
966
|
+
pruned?: true;
|
967
|
+
loc: SourceLocation;
|
968
|
+
};
|
969
|
+
type MethodCall = {
|
970
|
+
kind: 'MethodCall';
|
971
|
+
receiver: Place;
|
972
|
+
property: Place;
|
973
|
+
args: Array<Place | SpreadPattern>;
|
974
|
+
loc: SourceLocation;
|
975
|
+
};
|
976
|
+
type CallExpression = {
|
977
|
+
kind: 'CallExpression';
|
978
|
+
callee: Place;
|
979
|
+
args: Array<Place | SpreadPattern>;
|
980
|
+
loc: SourceLocation;
|
981
|
+
typeArguments?: Array<t.FlowType>;
|
982
|
+
};
|
983
|
+
type NewExpression = {
|
984
|
+
kind: 'NewExpression';
|
985
|
+
callee: Place;
|
986
|
+
args: Array<Place | SpreadPattern>;
|
987
|
+
loc: SourceLocation;
|
988
|
+
};
|
989
|
+
type LoadLocal = {
|
990
|
+
kind: 'LoadLocal';
|
991
|
+
place: Place;
|
992
|
+
loc: SourceLocation;
|
993
|
+
};
|
994
|
+
type LoadContext = {
|
995
|
+
kind: 'LoadContext';
|
996
|
+
place: Place;
|
997
|
+
loc: SourceLocation;
|
998
|
+
};
|
999
|
+
type InstructionValue = LoadLocal | LoadContext | {
|
1000
|
+
kind: 'DeclareLocal';
|
1001
|
+
lvalue: LValue;
|
1002
|
+
type: t.FlowType | t.TSType | null;
|
1003
|
+
loc: SourceLocation;
|
1004
|
+
} | {
|
1005
|
+
kind: 'DeclareContext';
|
1006
|
+
lvalue: {
|
1007
|
+
kind: InstructionKind.Let | InstructionKind.HoistedConst | InstructionKind.HoistedLet | InstructionKind.HoistedFunction;
|
1008
|
+
place: Place;
|
1009
|
+
};
|
1010
|
+
loc: SourceLocation;
|
1011
|
+
} | StoreLocal | {
|
1012
|
+
kind: 'StoreContext';
|
1013
|
+
lvalue: {
|
1014
|
+
kind: InstructionKind.Reassign | InstructionKind.Const | InstructionKind.Let | InstructionKind.Function;
|
1015
|
+
place: Place;
|
1016
|
+
};
|
1017
|
+
value: Place;
|
1018
|
+
loc: SourceLocation;
|
1019
|
+
} | Destructure | {
|
1020
|
+
kind: 'Primitive';
|
1021
|
+
value: number | boolean | string | null | undefined;
|
1022
|
+
loc: SourceLocation;
|
1023
|
+
} | JSXText | {
|
1024
|
+
kind: 'BinaryExpression';
|
1025
|
+
operator: Exclude<t.BinaryExpression['operator'], '|>'>;
|
1026
|
+
left: Place;
|
1027
|
+
right: Place;
|
1028
|
+
loc: SourceLocation;
|
1029
|
+
} | NewExpression | CallExpression | MethodCall | {
|
1030
|
+
kind: 'UnaryExpression';
|
1031
|
+
operator: Exclude<t.UnaryExpression['operator'], 'throw' | 'delete'>;
|
1032
|
+
value: Place;
|
1033
|
+
loc: SourceLocation;
|
1034
|
+
} | ({
|
1035
|
+
kind: 'TypeCastExpression';
|
1036
|
+
value: Place;
|
1037
|
+
type: Type;
|
1038
|
+
loc: SourceLocation;
|
1039
|
+
} & ({
|
1040
|
+
typeAnnotation: t.FlowType;
|
1041
|
+
typeAnnotationKind: 'cast';
|
1042
|
+
} | {
|
1043
|
+
typeAnnotation: t.TSType;
|
1044
|
+
typeAnnotationKind: 'as' | 'satisfies';
|
1045
|
+
})) | JsxExpression | {
|
1046
|
+
kind: 'ObjectExpression';
|
1047
|
+
properties: Array<ObjectProperty | SpreadPattern>;
|
1048
|
+
loc: SourceLocation;
|
1049
|
+
} | ObjectMethod | ArrayExpression | {
|
1050
|
+
kind: 'JsxFragment';
|
1051
|
+
children: Array<Place>;
|
1052
|
+
loc: SourceLocation;
|
1053
|
+
} | {
|
1054
|
+
kind: 'RegExpLiteral';
|
1055
|
+
pattern: string;
|
1056
|
+
flags: string;
|
1057
|
+
loc: SourceLocation;
|
1058
|
+
} | {
|
1059
|
+
kind: 'MetaProperty';
|
1060
|
+
meta: string;
|
1061
|
+
property: string;
|
1062
|
+
loc: SourceLocation;
|
1063
|
+
} | {
|
1064
|
+
kind: 'PropertyStore';
|
1065
|
+
object: Place;
|
1066
|
+
property: PropertyLiteral;
|
1067
|
+
value: Place;
|
1068
|
+
loc: SourceLocation;
|
1069
|
+
} | PropertyLoad | {
|
1070
|
+
kind: 'PropertyDelete';
|
1071
|
+
object: Place;
|
1072
|
+
property: PropertyLiteral;
|
1073
|
+
loc: SourceLocation;
|
1074
|
+
} | {
|
1075
|
+
kind: 'ComputedStore';
|
1076
|
+
object: Place;
|
1077
|
+
property: Place;
|
1078
|
+
value: Place;
|
1079
|
+
loc: SourceLocation;
|
1080
|
+
} | {
|
1081
|
+
kind: 'ComputedLoad';
|
1082
|
+
object: Place;
|
1083
|
+
property: Place;
|
1084
|
+
loc: SourceLocation;
|
1085
|
+
} | {
|
1086
|
+
kind: 'ComputedDelete';
|
1087
|
+
object: Place;
|
1088
|
+
property: Place;
|
1089
|
+
loc: SourceLocation;
|
1090
|
+
} | LoadGlobal | StoreGlobal | FunctionExpression | {
|
1091
|
+
kind: 'TaggedTemplateExpression';
|
1092
|
+
tag: Place;
|
1093
|
+
value: {
|
1094
|
+
raw: string;
|
1095
|
+
cooked?: string;
|
1096
|
+
};
|
1097
|
+
loc: SourceLocation;
|
1098
|
+
} | {
|
1099
|
+
kind: 'TemplateLiteral';
|
1100
|
+
subexprs: Array<Place>;
|
1101
|
+
quasis: Array<{
|
1102
|
+
raw: string;
|
1103
|
+
cooked?: string;
|
1104
|
+
}>;
|
1105
|
+
loc: SourceLocation;
|
1106
|
+
} | {
|
1107
|
+
kind: 'Await';
|
1108
|
+
value: Place;
|
1109
|
+
loc: SourceLocation;
|
1110
|
+
} | {
|
1111
|
+
kind: 'GetIterator';
|
1112
|
+
collection: Place;
|
1113
|
+
loc: SourceLocation;
|
1114
|
+
} | {
|
1115
|
+
kind: 'IteratorNext';
|
1116
|
+
iterator: Place;
|
1117
|
+
collection: Place;
|
1118
|
+
loc: SourceLocation;
|
1119
|
+
} | {
|
1120
|
+
kind: 'NextPropertyOf';
|
1121
|
+
value: Place;
|
1122
|
+
loc: SourceLocation;
|
1123
|
+
} | {
|
1124
|
+
kind: 'PrefixUpdate';
|
1125
|
+
lvalue: Place;
|
1126
|
+
operation: t.UpdateExpression['operator'];
|
1127
|
+
value: Place;
|
1128
|
+
loc: SourceLocation;
|
1129
|
+
} | {
|
1130
|
+
kind: 'PostfixUpdate';
|
1131
|
+
lvalue: Place;
|
1132
|
+
operation: t.UpdateExpression['operator'];
|
1133
|
+
value: Place;
|
1134
|
+
loc: SourceLocation;
|
1135
|
+
} | {
|
1136
|
+
kind: 'Debugger';
|
1137
|
+
loc: SourceLocation;
|
1138
|
+
} | StartMemoize | FinishMemoize | {
|
1139
|
+
kind: 'UnsupportedNode';
|
1140
|
+
node: t.Node;
|
1141
|
+
loc: SourceLocation;
|
1142
|
+
};
|
1143
|
+
type JsxExpression = {
|
1144
|
+
kind: 'JsxExpression';
|
1145
|
+
tag: Place | BuiltinTag;
|
1146
|
+
props: Array<JsxAttribute>;
|
1147
|
+
children: Array<Place> | null;
|
1148
|
+
loc: SourceLocation;
|
1149
|
+
openingLoc: SourceLocation;
|
1150
|
+
closingLoc: SourceLocation;
|
1151
|
+
};
|
1152
|
+
type JsxAttribute = {
|
1153
|
+
kind: 'JsxSpreadAttribute';
|
1154
|
+
argument: Place;
|
1155
|
+
} | {
|
1156
|
+
kind: 'JsxAttribute';
|
1157
|
+
name: string;
|
1158
|
+
place: Place;
|
1159
|
+
};
|
1160
|
+
type FunctionExpression = {
|
1161
|
+
kind: 'FunctionExpression';
|
1162
|
+
name: ValidIdentifierName | null;
|
1163
|
+
nameHint: string | null;
|
1164
|
+
loweredFunc: LoweredFunction;
|
1165
|
+
type: 'ArrowFunctionExpression' | 'FunctionExpression' | 'FunctionDeclaration';
|
1166
|
+
loc: SourceLocation;
|
1167
|
+
};
|
1168
|
+
type Destructure = {
|
1169
|
+
kind: 'Destructure';
|
1170
|
+
lvalue: LValuePattern;
|
1171
|
+
value: Place;
|
1172
|
+
loc: SourceLocation;
|
1173
|
+
};
|
1174
|
+
type Place = {
|
1175
|
+
kind: 'Identifier';
|
1176
|
+
identifier: Identifier;
|
1177
|
+
effect: Effect;
|
1178
|
+
reactive: boolean;
|
1179
|
+
loc: SourceLocation;
|
1180
|
+
};
|
1181
|
+
type JSXText = {
|
1182
|
+
kind: 'JSXText';
|
1183
|
+
value: string;
|
1184
|
+
loc: SourceLocation;
|
1185
|
+
};
|
1186
|
+
type StoreLocal = {
|
1187
|
+
kind: 'StoreLocal';
|
1188
|
+
lvalue: LValue;
|
1189
|
+
value: Place;
|
1190
|
+
type: t.FlowType | t.TSType | null;
|
1191
|
+
loc: SourceLocation;
|
1192
|
+
};
|
1193
|
+
type PropertyLoad = {
|
1194
|
+
kind: 'PropertyLoad';
|
1195
|
+
object: Place;
|
1196
|
+
property: PropertyLiteral;
|
1197
|
+
loc: SourceLocation;
|
1198
|
+
};
|
1199
|
+
type LoadGlobal = {
|
1200
|
+
kind: 'LoadGlobal';
|
1201
|
+
binding: NonLocalBinding;
|
1202
|
+
loc: SourceLocation;
|
1203
|
+
};
|
1204
|
+
type StoreGlobal = {
|
1205
|
+
kind: 'StoreGlobal';
|
1206
|
+
name: string;
|
1207
|
+
value: Place;
|
1208
|
+
loc: SourceLocation;
|
1209
|
+
};
|
1210
|
+
type BuiltinTag = {
|
1211
|
+
kind: 'BuiltinTag';
|
1212
|
+
name: string;
|
1213
|
+
loc: SourceLocation;
|
1214
|
+
};
|
1215
|
+
type MutableRange = {
|
1216
|
+
start: InstructionId;
|
1217
|
+
end: InstructionId;
|
1218
|
+
};
|
1219
|
+
type NonLocalImportSpecifier = {
|
1220
|
+
kind: 'ImportSpecifier';
|
1221
|
+
name: string;
|
1222
|
+
module: string;
|
1223
|
+
imported: string;
|
1224
|
+
};
|
1225
|
+
type NonLocalBinding = {
|
1226
|
+
kind: 'ImportDefault';
|
1227
|
+
name: string;
|
1228
|
+
module: string;
|
1229
|
+
} | {
|
1230
|
+
kind: 'ImportNamespace';
|
1231
|
+
name: string;
|
1232
|
+
module: string;
|
1233
|
+
} | NonLocalImportSpecifier | {
|
1234
|
+
kind: 'ModuleLocal';
|
1235
|
+
name: string;
|
1236
|
+
} | {
|
1237
|
+
kind: 'Global';
|
1238
|
+
name: string;
|
1239
|
+
};
|
1240
|
+
type Identifier = {
|
1241
|
+
id: IdentifierId;
|
1242
|
+
declarationId: DeclarationId;
|
1243
|
+
name: IdentifierName | null;
|
1244
|
+
mutableRange: MutableRange;
|
1245
|
+
scope: ReactiveScope | null;
|
1246
|
+
type: Type;
|
1247
|
+
loc: SourceLocation;
|
1248
|
+
};
|
1249
|
+
type IdentifierName = ValidatedIdentifier | PromotedIdentifier;
|
1250
|
+
type ValidatedIdentifier = {
|
1251
|
+
kind: 'named';
|
1252
|
+
value: ValidIdentifierName;
|
1253
|
+
};
|
1254
|
+
type PromotedIdentifier = {
|
1255
|
+
kind: 'promoted';
|
1256
|
+
value: string;
|
1257
|
+
};
|
1258
|
+
declare const opaqueValidIdentifierName: unique symbol;
|
1259
|
+
type ValidIdentifierName = string & {
|
1260
|
+
[opaqueValidIdentifierName]: 'ValidIdentifierName';
|
1261
|
+
};
|
1262
|
+
declare enum ValueReason {
|
1263
|
+
Global = "global",
|
1264
|
+
JsxCaptured = "jsx-captured",
|
1265
|
+
HookCaptured = "hook-captured",
|
1266
|
+
HookReturn = "hook-return",
|
1267
|
+
Effect = "effect",
|
1268
|
+
KnownReturnSignature = "known-return-signature",
|
1269
|
+
Context = "context",
|
1270
|
+
State = "state",
|
1271
|
+
ReducerState = "reducer-state",
|
1272
|
+
ReactiveFunctionArgument = "reactive-function-argument",
|
1273
|
+
Other = "other"
|
1274
|
+
}
|
1275
|
+
declare enum ValueKind {
|
1276
|
+
MaybeFrozen = "maybefrozen",
|
1277
|
+
Frozen = "frozen",
|
1278
|
+
Primitive = "primitive",
|
1279
|
+
Global = "global",
|
1280
|
+
Mutable = "mutable",
|
1281
|
+
Context = "context"
|
1282
|
+
}
|
1283
|
+
declare enum Effect {
|
1284
|
+
Unknown = "<unknown>",
|
1285
|
+
Freeze = "freeze",
|
1286
|
+
Read = "read",
|
1287
|
+
Capture = "capture",
|
1288
|
+
ConditionallyMutateIterator = "mutate-iterator?",
|
1289
|
+
ConditionallyMutate = "mutate?",
|
1290
|
+
Mutate = "mutate",
|
1291
|
+
Store = "store"
|
1292
|
+
}
|
1293
|
+
type ReactiveScope = {
|
1294
|
+
id: ScopeId;
|
1295
|
+
range: MutableRange;
|
1296
|
+
dependencies: ReactiveScopeDependencies;
|
1297
|
+
declarations: Map<IdentifierId, ReactiveScopeDeclaration>;
|
1298
|
+
reassignments: Set<Identifier>;
|
1299
|
+
earlyReturnValue: {
|
1300
|
+
value: Identifier;
|
1301
|
+
loc: SourceLocation;
|
1302
|
+
label: BlockId;
|
1303
|
+
} | null;
|
1304
|
+
merged: Set<ScopeId>;
|
1305
|
+
loc: SourceLocation;
|
1306
|
+
};
|
1307
|
+
type ReactiveScopeDependencies = Set<ReactiveScopeDependency>;
|
1308
|
+
type ReactiveScopeDeclaration = {
|
1309
|
+
identifier: Identifier;
|
1310
|
+
scope: ReactiveScope;
|
1311
|
+
};
|
1312
|
+
declare const opaquePropertyLiteral: unique symbol;
|
1313
|
+
type PropertyLiteral = (string | number) & {
|
1314
|
+
[opaquePropertyLiteral]: 'PropertyLiteral';
|
1315
|
+
};
|
1316
|
+
type DependencyPathEntry = {
|
1317
|
+
property: PropertyLiteral;
|
1318
|
+
optional: boolean;
|
1319
|
+
};
|
1320
|
+
type DependencyPath = Array<DependencyPathEntry>;
|
1321
|
+
type ReactiveScopeDependency = {
|
1322
|
+
identifier: Identifier;
|
1323
|
+
reactive: boolean;
|
1324
|
+
path: DependencyPath;
|
1325
|
+
};
|
1326
|
+
declare const opaqueBlockId: unique symbol;
|
1327
|
+
type BlockId = number & {
|
1328
|
+
[opaqueBlockId]: 'BlockId';
|
1329
|
+
};
|
1330
|
+
declare const opaqueScopeId: unique symbol;
|
1331
|
+
type ScopeId = number & {
|
1332
|
+
[opaqueScopeId]: 'ScopeId';
|
1333
|
+
};
|
1334
|
+
declare const opaqueIdentifierId: unique symbol;
|
1335
|
+
type IdentifierId = number & {
|
1336
|
+
[opaqueIdentifierId]: 'IdentifierId';
|
1337
|
+
};
|
1338
|
+
declare const opageDeclarationId: unique symbol;
|
1339
|
+
type DeclarationId = number & {
|
1340
|
+
[opageDeclarationId]: 'DeclarationId';
|
1341
|
+
};
|
1342
|
+
declare const opaqueInstructionId: unique symbol;
|
1343
|
+
type InstructionId = number & {
|
1344
|
+
[opaqueInstructionId]: 'IdentifierId';
|
1345
|
+
};
|
1346
|
+
|
1347
|
+
type Options = {
|
1348
|
+
indent: number;
|
1349
|
+
};
|
1350
|
+
declare function printFunctionWithOutlined(fn: HIRFunction): string;
|
1351
|
+
declare function printHIR(ir: HIR, options?: Options | null): string;
|
1352
|
+
|
1353
|
+
declare enum ErrorSeverity {
|
1354
|
+
Error = "Error",
|
1355
|
+
Warning = "Warning",
|
1356
|
+
Hint = "Hint",
|
1357
|
+
Off = "Off"
|
1358
|
+
}
|
1359
|
+
type CompilerDiagnosticOptions = {
|
1360
|
+
category: ErrorCategory;
|
1361
|
+
reason: string;
|
1362
|
+
description: string | null;
|
1363
|
+
details: Array<CompilerDiagnosticDetail>;
|
1364
|
+
suggestions?: Array<CompilerSuggestion> | null | undefined;
|
1365
|
+
};
|
1366
|
+
type CompilerDiagnosticDetail = {
|
1367
|
+
kind: 'error';
|
1368
|
+
loc: SourceLocation | null;
|
1369
|
+
message: string | null;
|
1370
|
+
} | {
|
1371
|
+
kind: 'hint';
|
1372
|
+
message: string;
|
1373
|
+
};
|
1374
|
+
declare enum CompilerSuggestionOperation {
|
1375
|
+
InsertBefore = 0,
|
1376
|
+
InsertAfter = 1,
|
1377
|
+
Remove = 2,
|
1378
|
+
Replace = 3
|
1379
|
+
}
|
1380
|
+
type CompilerSuggestion = {
|
1381
|
+
op: CompilerSuggestionOperation.InsertAfter | CompilerSuggestionOperation.InsertBefore | CompilerSuggestionOperation.Replace;
|
1382
|
+
range: [number, number];
|
1383
|
+
description: string;
|
1384
|
+
text: string;
|
1385
|
+
} | {
|
1386
|
+
op: CompilerSuggestionOperation.Remove;
|
1387
|
+
range: [number, number];
|
1388
|
+
description: string;
|
1389
|
+
};
|
1390
|
+
type CompilerErrorDetailOptions = {
|
1391
|
+
category: ErrorCategory;
|
1392
|
+
reason: string;
|
1393
|
+
description?: string | null | undefined;
|
1394
|
+
loc: SourceLocation | null;
|
1395
|
+
suggestions?: Array<CompilerSuggestion> | null | undefined;
|
1396
|
+
};
|
1397
|
+
type PrintErrorMessageOptions = {
|
1398
|
+
eslint: boolean;
|
1399
|
+
};
|
1400
|
+
declare class CompilerDiagnostic {
|
1401
|
+
options: CompilerDiagnosticOptions;
|
1402
|
+
constructor(options: CompilerDiagnosticOptions);
|
1403
|
+
static create(options: Omit<CompilerDiagnosticOptions, 'details'>): CompilerDiagnostic;
|
1404
|
+
get reason(): CompilerDiagnosticOptions['reason'];
|
1405
|
+
get description(): CompilerDiagnosticOptions['description'];
|
1406
|
+
get severity(): ErrorSeverity;
|
1407
|
+
get suggestions(): CompilerDiagnosticOptions['suggestions'];
|
1408
|
+
get category(): ErrorCategory;
|
1409
|
+
withDetails(...details: Array<CompilerDiagnosticDetail>): CompilerDiagnostic;
|
1410
|
+
primaryLocation(): SourceLocation | null;
|
1411
|
+
printErrorMessage(source: string, options: PrintErrorMessageOptions): string;
|
1412
|
+
toString(): string;
|
1413
|
+
}
|
1414
|
+
declare class CompilerErrorDetail {
|
1415
|
+
options: CompilerErrorDetailOptions;
|
1416
|
+
constructor(options: CompilerErrorDetailOptions);
|
1417
|
+
get reason(): CompilerErrorDetailOptions['reason'];
|
1418
|
+
get description(): CompilerErrorDetailOptions['description'];
|
1419
|
+
get severity(): ErrorSeverity;
|
1420
|
+
get loc(): CompilerErrorDetailOptions['loc'];
|
1421
|
+
get suggestions(): CompilerErrorDetailOptions['suggestions'];
|
1422
|
+
get category(): ErrorCategory;
|
1423
|
+
primaryLocation(): SourceLocation | null;
|
1424
|
+
printErrorMessage(source: string, options: PrintErrorMessageOptions): string;
|
1425
|
+
toString(): string;
|
1426
|
+
}
|
1427
|
+
declare class CompilerError extends Error {
|
1428
|
+
details: Array<CompilerErrorDetail | CompilerDiagnostic>;
|
1429
|
+
disabledDetails: Array<CompilerErrorDetail | CompilerDiagnostic>;
|
1430
|
+
printedMessage: string | null;
|
1431
|
+
static invariant(condition: unknown, options: Omit<CompilerDiagnosticOptions, 'category'>): asserts condition;
|
1432
|
+
static throwDiagnostic(options: CompilerDiagnosticOptions): never;
|
1433
|
+
static throwTodo(options: Omit<CompilerErrorDetailOptions, 'category'>): never;
|
1434
|
+
static throwInvalidJS(options: Omit<CompilerErrorDetailOptions, 'category'>): never;
|
1435
|
+
static throwInvalidReact(options: CompilerErrorDetailOptions): never;
|
1436
|
+
static throwInvalidConfig(options: Omit<CompilerErrorDetailOptions, 'category'>): never;
|
1437
|
+
static throw(options: CompilerErrorDetailOptions): never;
|
1438
|
+
constructor(...args: Array<any>);
|
1439
|
+
get message(): string;
|
1440
|
+
set message(_message: string);
|
1441
|
+
toString(): string;
|
1442
|
+
withPrintedMessage(source: string, options: PrintErrorMessageOptions): CompilerError;
|
1443
|
+
printErrorMessage(source: string, options: PrintErrorMessageOptions): string;
|
1444
|
+
merge(other: CompilerError): void;
|
1445
|
+
pushDiagnostic(diagnostic: CompilerDiagnostic): void;
|
1446
|
+
push(options: CompilerErrorDetailOptions): CompilerErrorDetail;
|
1447
|
+
pushErrorDetail(detail: CompilerErrorDetail): CompilerErrorDetail;
|
1448
|
+
hasAnyErrors(): boolean;
|
1449
|
+
asResult(): Result<void, CompilerError>;
|
1450
|
+
hasErrors(): boolean;
|
1451
|
+
hasWarning(): boolean;
|
1452
|
+
hasHints(): boolean;
|
1453
|
+
}
|
1454
|
+
declare enum ErrorCategory {
|
1455
|
+
Hooks = "Hooks",
|
1456
|
+
CapitalizedCalls = "CapitalizedCalls",
|
1457
|
+
StaticComponents = "StaticComponents",
|
1458
|
+
UseMemo = "UseMemo",
|
1459
|
+
Factories = "Factories",
|
1460
|
+
PreserveManualMemo = "PreserveManualMemo",
|
1461
|
+
IncompatibleLibrary = "IncompatibleLibrary",
|
1462
|
+
Immutability = "Immutability",
|
1463
|
+
Globals = "Globals",
|
1464
|
+
Refs = "Refs",
|
1465
|
+
EffectDependencies = "EffectDependencies",
|
1466
|
+
EffectSetState = "EffectSetState",
|
1467
|
+
EffectDerivationsOfState = "EffectDerivationsOfState",
|
1468
|
+
ErrorBoundaries = "ErrorBoundaries",
|
1469
|
+
Purity = "Purity",
|
1470
|
+
RenderSetState = "RenderSetState",
|
1471
|
+
Invariant = "Invariant",
|
1472
|
+
Todo = "Todo",
|
1473
|
+
Syntax = "Syntax",
|
1474
|
+
UnsupportedSyntax = "UnsupportedSyntax",
|
1475
|
+
Config = "Config",
|
1476
|
+
Gating = "Gating",
|
1477
|
+
Suppression = "Suppression",
|
1478
|
+
AutomaticEffectDependencies = "AutomaticEffectDependencies",
|
1479
|
+
Fire = "Fire",
|
1480
|
+
FBT = "FBT"
|
1481
|
+
}
|
1482
|
+
type LintRule = {
|
1483
|
+
category: ErrorCategory;
|
1484
|
+
severity: ErrorSeverity;
|
1485
|
+
name: string;
|
1486
|
+
description: string;
|
1487
|
+
recommended: boolean;
|
1488
|
+
};
|
1489
|
+
declare const LintRules: Array<LintRule>;
|
1490
|
+
|
1491
|
+
type CodegenFunction = {
|
1492
|
+
type: 'CodegenFunction';
|
1493
|
+
id: t.Identifier | null;
|
1494
|
+
nameHint: string | null;
|
1495
|
+
params: t.FunctionDeclaration['params'];
|
1496
|
+
body: t.BlockStatement;
|
1497
|
+
generator: boolean;
|
1498
|
+
async: boolean;
|
1499
|
+
loc: SourceLocation;
|
1500
|
+
memoSlotsUsed: number;
|
1501
|
+
memoBlocks: number;
|
1502
|
+
memoValues: number;
|
1503
|
+
prunedMemoBlocks: number;
|
1504
|
+
prunedMemoValues: number;
|
1505
|
+
outlined: Array<{
|
1506
|
+
fn: CodegenFunction;
|
1507
|
+
type: ReactFunctionType | null;
|
1508
|
+
}>;
|
1509
|
+
hasInferredEffect: boolean;
|
1510
|
+
inferredEffectLocations: Set<SourceLocation>;
|
1511
|
+
hasFireRewrite: boolean;
|
1512
|
+
};
|
1513
|
+
|
1514
|
+
declare function printReactiveFunctionWithOutlined(fn: ReactiveFunction): string;
|
1515
|
+
declare function printReactiveFunction(fn: ReactiveFunction): string;
|
1516
|
+
|
1517
|
+
type CompilerPipelineValue = {
|
1518
|
+
kind: 'ast';
|
1519
|
+
name: string;
|
1520
|
+
value: CodegenFunction;
|
1521
|
+
} | {
|
1522
|
+
kind: 'hir';
|
1523
|
+
name: string;
|
1524
|
+
value: HIRFunction;
|
1525
|
+
} | {
|
1526
|
+
kind: 'reactive';
|
1527
|
+
name: string;
|
1528
|
+
value: ReactiveFunction;
|
1529
|
+
} | {
|
1530
|
+
kind: 'debug';
|
1531
|
+
name: string;
|
1532
|
+
value: string;
|
1533
|
+
};
|
1534
|
+
declare function compileFn(func: NodePath<t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression>, config: EnvironmentConfig, fnType: ReactFunctionType, mode: CompilerMode, programContext: ProgramContext, logger: Logger | null, filename: string | null, code: string | null): CodegenFunction;
|
1535
|
+
|
1536
|
+
declare const PanicThresholdOptionsSchema: z.ZodEnum<{
|
1537
|
+
none: "none";
|
1538
|
+
all_errors: "all_errors";
|
1539
|
+
critical_errors: "critical_errors";
|
1540
|
+
}>;
|
1541
|
+
type PanicThresholdOptions = z.infer<typeof PanicThresholdOptionsSchema>;
|
1542
|
+
declare const DynamicGatingOptionsSchema: z.ZodObject<{
|
1543
|
+
source: z.ZodString;
|
1544
|
+
}, z.core.$strip>;
|
1545
|
+
type DynamicGatingOptions = z.infer<typeof DynamicGatingOptionsSchema>;
|
1546
|
+
declare const CustomOptOutDirectiveSchema: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
1547
|
+
type CustomOptOutDirective = z.infer<typeof CustomOptOutDirectiveSchema>;
|
1548
|
+
type PluginOptions = Partial<{
|
1549
|
+
environment: Partial<EnvironmentConfig>;
|
1550
|
+
logger: Logger | null;
|
1551
|
+
gating: ExternalFunction | null;
|
1552
|
+
dynamicGating: DynamicGatingOptions | null;
|
1553
|
+
panicThreshold: PanicThresholdOptions;
|
1554
|
+
noEmit: boolean;
|
1555
|
+
compilationMode: CompilationMode;
|
1556
|
+
eslintSuppressionRules: Array<string> | null | undefined;
|
1557
|
+
flowSuppressions: boolean;
|
1558
|
+
ignoreUseNoForget: boolean;
|
1559
|
+
customOptOutDirectives: CustomOptOutDirective;
|
1560
|
+
sources: Array<string> | ((filename: string) => boolean) | null;
|
1561
|
+
enableReanimatedCheck: boolean;
|
1562
|
+
target: CompilerReactTarget;
|
1563
|
+
}>;
|
1564
|
+
type ParsedPluginOptions = Required<Omit<PluginOptions, 'environment'>> & {
|
1565
|
+
environment: EnvironmentConfig;
|
1566
|
+
};
|
1567
|
+
declare const CompilerReactTargetSchema: z.ZodUnion<readonly [z.ZodLiteral<"17">, z.ZodLiteral<"18">, z.ZodLiteral<"19">, z.ZodObject<{
|
1568
|
+
kind: z.ZodLiteral<"donotuse_meta_internal">;
|
1569
|
+
runtimeModule: z.ZodDefault<z.ZodString>;
|
1570
|
+
}, z.core.$strip>]>;
|
1571
|
+
type CompilerReactTarget = z.infer<typeof CompilerReactTargetSchema>;
|
1572
|
+
declare const CompilationModeSchema: z.ZodEnum<{
|
1573
|
+
syntax: "syntax";
|
1574
|
+
infer: "infer";
|
1575
|
+
annotation: "annotation";
|
1576
|
+
all: "all";
|
1577
|
+
}>;
|
1578
|
+
type CompilationMode = z.infer<typeof CompilationModeSchema>;
|
1579
|
+
type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent | AutoDepsDecorationsEvent | AutoDepsEligibleEvent;
|
1580
|
+
type CompileErrorEvent = {
|
1581
|
+
kind: 'CompileError';
|
1582
|
+
fnLoc: t.SourceLocation | null;
|
1583
|
+
detail: CompilerErrorDetail | CompilerDiagnostic;
|
1584
|
+
};
|
1585
|
+
type CompileDiagnosticEvent = {
|
1586
|
+
kind: 'CompileDiagnostic';
|
1587
|
+
fnLoc: t.SourceLocation | null;
|
1588
|
+
detail: Omit<Omit<CompilerErrorDetailOptions, 'severity'>, 'suggestions'>;
|
1589
|
+
};
|
1590
|
+
type CompileSuccessEvent = {
|
1591
|
+
kind: 'CompileSuccess';
|
1592
|
+
fnLoc: t.SourceLocation | null;
|
1593
|
+
fnName: string | null;
|
1594
|
+
memoSlots: number;
|
1595
|
+
memoBlocks: number;
|
1596
|
+
memoValues: number;
|
1597
|
+
prunedMemoBlocks: number;
|
1598
|
+
prunedMemoValues: number;
|
1599
|
+
};
|
1600
|
+
type CompileSkipEvent = {
|
1601
|
+
kind: 'CompileSkip';
|
1602
|
+
fnLoc: t.SourceLocation | null;
|
1603
|
+
reason: string;
|
1604
|
+
loc: t.SourceLocation | null;
|
1605
|
+
};
|
1606
|
+
type PipelineErrorEvent = {
|
1607
|
+
kind: 'PipelineError';
|
1608
|
+
fnLoc: t.SourceLocation | null;
|
1609
|
+
data: string;
|
1610
|
+
};
|
1611
|
+
type TimingEvent = {
|
1612
|
+
kind: 'Timing';
|
1613
|
+
measurement: PerformanceMeasure;
|
1614
|
+
};
|
1615
|
+
type AutoDepsDecorationsEvent = {
|
1616
|
+
kind: 'AutoDepsDecorations';
|
1617
|
+
fnLoc: t.SourceLocation;
|
1618
|
+
decorations: Array<t.SourceLocation>;
|
1619
|
+
};
|
1620
|
+
type AutoDepsEligibleEvent = {
|
1621
|
+
kind: 'AutoDepsEligible';
|
1622
|
+
fnLoc: t.SourceLocation;
|
1623
|
+
depArrayLoc: t.SourceLocation;
|
1624
|
+
};
|
1625
|
+
type Logger = {
|
1626
|
+
logEvent: (filename: string | null, event: LoggerEvent) => void;
|
1627
|
+
debugLogIRs?: (value: CompilerPipelineValue) => void;
|
1628
|
+
};
|
1629
|
+
declare function parsePluginOptions(obj: unknown): ParsedPluginOptions;
|
1630
|
+
|
1631
|
+
type CompilerPass = {
|
1632
|
+
opts: ParsedPluginOptions;
|
1633
|
+
filename: string | null;
|
1634
|
+
comments: Array<t.CommentBlock | t.CommentLine>;
|
1635
|
+
code: string | null;
|
1636
|
+
};
|
1637
|
+
declare const OPT_IN_DIRECTIVES: Set<string>;
|
1638
|
+
declare const OPT_OUT_DIRECTIVES: Set<string>;
|
1639
|
+
declare function tryFindDirectiveEnablingMemoization(directives: Array<t.Directive>, opts: ParsedPluginOptions): Result<t.Directive | null, CompilerError>;
|
1640
|
+
declare function findDirectiveDisablingMemoization(directives: Array<t.Directive>, { customOptOutDirectives }: PluginOptions): t.Directive | null;
|
1641
|
+
type BabelFn = NodePath$1<t.FunctionDeclaration> | NodePath$1<t.FunctionExpression> | NodePath$1<t.ArrowFunctionExpression>;
|
1642
|
+
type CompileProgramMetadata = {
|
1643
|
+
retryErrors: Array<{
|
1644
|
+
fn: BabelFn;
|
1645
|
+
error: CompilerError;
|
1646
|
+
}>;
|
1647
|
+
inferredEffectLocations: Set<t.SourceLocation>;
|
1648
|
+
};
|
1649
|
+
declare function compileProgram(program: NodePath$1<t.Program>, pass: CompilerPass): CompileProgramMetadata | null;
|
1650
|
+
|
1651
|
+
type SuppressionRange = {
|
1652
|
+
disableComment: t.Comment;
|
1653
|
+
enableComment: t.Comment | null;
|
1654
|
+
source: SuppressionSource;
|
1655
|
+
};
|
1656
|
+
type SuppressionSource = 'Eslint' | 'Flow';
|
1657
|
+
|
1658
|
+
type ProgramContextOptions = {
|
1659
|
+
program: NodePath$1<t.Program>;
|
1660
|
+
suppressions: Array<SuppressionRange>;
|
1661
|
+
opts: ParsedPluginOptions;
|
1662
|
+
filename: string | null;
|
1663
|
+
code: string | null;
|
1664
|
+
hasModuleScopeOptOut: boolean;
|
1665
|
+
};
|
1666
|
+
declare class ProgramContext {
|
1667
|
+
scope: Scope;
|
1668
|
+
opts: ParsedPluginOptions;
|
1669
|
+
filename: string | null;
|
1670
|
+
code: string | null;
|
1671
|
+
reactRuntimeModule: string;
|
1672
|
+
suppressions: Array<SuppressionRange>;
|
1673
|
+
hasModuleScopeOptOut: boolean;
|
1674
|
+
alreadyCompiled: WeakSet<object> | Set<object>;
|
1675
|
+
knownReferencedNames: Set<string>;
|
1676
|
+
imports: Map<string, Map<string, NonLocalImportSpecifier>>;
|
1677
|
+
retryErrors: Array<{
|
1678
|
+
fn: BabelFn;
|
1679
|
+
error: CompilerError;
|
1680
|
+
}>;
|
1681
|
+
inferredEffectLocations: Set<t.SourceLocation>;
|
1682
|
+
constructor({ program, suppressions, opts, filename, code, hasModuleScopeOptOut, }: ProgramContextOptions);
|
1683
|
+
isHookName(name: string): boolean;
|
1684
|
+
hasReference(name: string): boolean;
|
1685
|
+
newUid(name: string): string;
|
1686
|
+
addMemoCacheImport(): NonLocalImportSpecifier;
|
1687
|
+
addImportSpecifier({ source: module, importSpecifierName: specifier }: ExternalFunction, nameHint?: string): NonLocalImportSpecifier;
|
1688
|
+
addNewReference(name: string): void;
|
1689
|
+
assertGlobalBinding(name: string, localScope?: Scope): Result<void, CompilerError>;
|
1690
|
+
logEvent(event: LoggerEvent): void;
|
1691
|
+
}
|
1692
|
+
|
1693
|
+
declare function runBabelPluginReactCompiler(text: string, file: string, language: 'flow' | 'typescript', options: PluginOptions | null, includeAst?: boolean): BabelCore.BabelFileResult;
|
1694
|
+
|
1695
|
+
declare function parseConfigPragmaForTests(pragma: string, defaults: {
|
1696
|
+
compilationMode: CompilationMode;
|
1697
|
+
environment?: PartialEnvironmentConfig;
|
1698
|
+
}): PluginOptions;
|
1699
|
+
|
1700
|
+
declare function BabelPluginReactCompiler(_babel: typeof BabelCore): BabelCore.PluginObj;
|
1701
|
+
|
1702
|
+
declare global {
|
1703
|
+
}
|
1704
|
+
|
1705
|
+
export { CompilerDiagnostic, type CompilerDiagnosticDetail, type CompilerDiagnosticOptions, CompilerError, CompilerErrorDetail, type CompilerErrorDetailOptions, type CompilerPipelineValue, CompilerSuggestionOperation, Effect, type EnvironmentConfig, ErrorCategory, ErrorSeverity, type ExternalFunction, type Hook, type LintRule, LintRules, type Logger, type LoggerEvent, OPT_IN_DIRECTIVES, OPT_OUT_DIRECTIVES, type PluginOptions, ProgramContext, type SourceLocation, ValueKind, ValueReason, compileFn as compile, compileProgram, BabelPluginReactCompiler as default, findDirectiveDisablingMemoization, tryFindDirectiveEnablingMemoization as findDirectiveEnablingMemoization, parseConfigPragmaForTests, parsePluginOptions, printFunctionWithOutlined, printHIR, printReactiveFunction, printReactiveFunctionWithOutlined, runBabelPluginReactCompiler, validateEnvironmentConfig };
|