@octanejs/codemod 0.2.2 → 0.2.4
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 +10 -0
- package/dist/forwarded-props.d.ts +1 -0
- package/dist/forwarded-props.js +9 -9
- package/dist/local-react-hook.d.ts +1 -1
- package/dist/local-react-hook.js +7 -6
- package/dist/project.js +234 -47
- package/dist/react-island-sources.d.ts +6 -0
- package/dist/react-island-sources.js +210 -22
- package/dist/transform.js +406 -77
- package/dist/types.d.ts +5 -1
- package/package.json +2 -2
package/dist/transform.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { svgDataAttribute, svgLiteralRootOverride } from './path-svg.js';
|
|
2
|
-
import { forwardedProps, hasEval, literalJsxAttribute, nativeOutputOwner, returnedTextReceiver, renderUses, rootHandleEscapes, svgLocalReads, } from './forwarded-props.js';
|
|
2
|
+
import { contains, forwardedProps, hasEval, hasPrototypeAccess, literalJsxAttribute, nativeOutputOwner, returnedTextReceiver, renderUses, rootHandleEscapes, svgLocalReads, } from './forwarded-props.js';
|
|
3
3
|
import { reactRenderer, staticReactProps, unreadServerStream } from './react-renderer.js';
|
|
4
4
|
import { linkedRenderState } from './linked-state.js';
|
|
5
5
|
import { nativeSetupHook } from './local-react-hook.js';
|
|
@@ -38,6 +38,22 @@ function directMember(receiver) {
|
|
|
38
38
|
return parent.right;
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
+
function literalDisplayNameAssignment(ref, declaration) {
|
|
42
|
+
const member = ref.parent;
|
|
43
|
+
if (!ts.isPropertyAccessExpression(member) ||
|
|
44
|
+
member.expression !== ref ||
|
|
45
|
+
member.questionDotToken ||
|
|
46
|
+
member.name.text !== 'displayName')
|
|
47
|
+
return false;
|
|
48
|
+
const assignment = member.parent;
|
|
49
|
+
return (ts.isBinaryExpression(assignment) &&
|
|
50
|
+
assignment.left === member &&
|
|
51
|
+
assignment.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
52
|
+
ts.isExpressionStatement(assignment.parent) &&
|
|
53
|
+
assignment.parent.parent === declaration.parent &&
|
|
54
|
+
assignment.getStart() >= declaration.end &&
|
|
55
|
+
ts.isStringLiteralLike(skipWrappers(assignment.right)));
|
|
56
|
+
}
|
|
41
57
|
// React Router applications can augment this loader type on the original module.
|
|
42
58
|
function routerLoadContext(module, name) {
|
|
43
59
|
return name === 'AppLoadContext' && (module === 'react-router' || module === 'react-router-dom');
|
|
@@ -694,6 +710,7 @@ class ModuleTransform {
|
|
|
694
710
|
changeSpreads = new Set();
|
|
695
711
|
/** Proven element slots on converted top-level declarations, for the project caller pass. */
|
|
696
712
|
elementChildren = [];
|
|
713
|
+
ordinaryElementMetadata;
|
|
697
714
|
/** Components to mark `descriptorChildren`. */
|
|
698
715
|
descriptorComponents = new Set();
|
|
699
716
|
/** Whether a `declare module` now augments `octane/jsx-runtime`. */
|
|
@@ -800,6 +817,8 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
800
817
|
const reexports = [];
|
|
801
818
|
const isExported = (statement) => ts.canHaveModifiers(statement) &&
|
|
802
819
|
ts.getModifiers(statement)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
820
|
+
const elementChildren = [...this.elementChildren];
|
|
821
|
+
let safeElementAliases;
|
|
803
822
|
const descriptorChildren = [...this.descriptorComponents].flatMap((d) => {
|
|
804
823
|
const statement = ts.isVariableDeclaration(d) ? d.parent.parent : d;
|
|
805
824
|
return d.name && isExported(statement) ? [d.name.getText(this.sf)] : [];
|
|
@@ -828,7 +847,9 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
828
847
|
for (const element of statement.exportClause.elements) {
|
|
829
848
|
if (contexts.has((element.propertyName ?? element.name).text))
|
|
830
849
|
exported.add(element.name.text);
|
|
831
|
-
if (!this.descriptorComponents.size
|
|
850
|
+
if ((!this.descriptorComponents.size && !this.elementChildren.length) ||
|
|
851
|
+
statement.isTypeOnly ||
|
|
852
|
+
element.isTypeOnly)
|
|
832
853
|
continue;
|
|
833
854
|
const local = this.checker.getExportSpecifierLocalTargetSymbol(element)?.valueDeclaration;
|
|
834
855
|
if (local &&
|
|
@@ -836,6 +857,22 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
836
857
|
this.descriptorComponents.has(local)) {
|
|
837
858
|
descriptorChildren.push(element.name.text);
|
|
838
859
|
}
|
|
860
|
+
if (local && ts.isFunctionDeclaration(local) && local.name) {
|
|
861
|
+
const start = local.getStart(this.sf);
|
|
862
|
+
if (this.elementChildren.some((slot) => slot.start === start) &&
|
|
863
|
+
this.localUses(local.name).every((ref) => inTypeNode(ref) ||
|
|
864
|
+
componentTagOrExport(ref) ||
|
|
865
|
+
this.isOrdinaryElementMetadata(ref, local)) &&
|
|
866
|
+
(safeElementAliases ??=
|
|
867
|
+
this.options.mutableExports?.() !== true &&
|
|
868
|
+
!contains(this.sf, (node) => node.kind === ts.SyntaxKind.ThisKeyword ||
|
|
869
|
+
(ts.isIdentifier(node) &&
|
|
870
|
+
/^(?:eval|module|exports|require|arguments)$/.test(node.text) &&
|
|
871
|
+
!isPropertyName(node) &&
|
|
872
|
+
!declaresName(node) &&
|
|
873
|
+
!inTypeNode(node)))))
|
|
874
|
+
elementChildren.push({ start, exported: element.name.text });
|
|
875
|
+
}
|
|
839
876
|
}
|
|
840
877
|
}
|
|
841
878
|
}
|
|
@@ -857,11 +894,18 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
857
894
|
continue;
|
|
858
895
|
if (nativeSetupHook(ref, this.localUses, this.checker, undefined, true) !== 'first')
|
|
859
896
|
continue;
|
|
860
|
-
const component = ts.findAncestor(ref, ts.
|
|
861
|
-
if (component
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
897
|
+
const component = ts.findAncestor(ref, ts.isFunctionLike);
|
|
898
|
+
if (component && ts.isFunctionDeclaration(component)) {
|
|
899
|
+
if (component.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword))
|
|
900
|
+
storeHookComponents.add('default');
|
|
901
|
+
else if (component.name)
|
|
902
|
+
storeHookComponents.add(component.name.text);
|
|
903
|
+
}
|
|
904
|
+
else if (component && ts.isVariableDeclaration(component.parent)) {
|
|
905
|
+
const name = component.parent.name;
|
|
906
|
+
if (ts.isIdentifier(name))
|
|
907
|
+
storeHookComponents.add(name.text);
|
|
908
|
+
}
|
|
865
909
|
}
|
|
866
910
|
}
|
|
867
911
|
return {
|
|
@@ -869,7 +913,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
869
913
|
reexports,
|
|
870
914
|
...(descriptorChildren.length ? { descriptorChildren } : {}),
|
|
871
915
|
...(storeHookComponents.size ? { storeHookComponents: [...storeHookComponents] } : {}),
|
|
872
|
-
...(
|
|
916
|
+
...(elementChildren.length ? { elementChildren } : {}),
|
|
873
917
|
};
|
|
874
918
|
}
|
|
875
919
|
// ---------------------------------------------------------------- analysis
|
|
@@ -2262,20 +2306,31 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
2262
2306
|
if (ts.isFunctionDeclaration(fn) &&
|
|
2263
2307
|
fn.name &&
|
|
2264
2308
|
fn.parent === this.sf &&
|
|
2265
|
-
this.checker.getSymbolAtLocation(fn.name)?.declarations?.length === 1 &&
|
|
2266
2309
|
this.acceptsSingleElement(declaration.type)) {
|
|
2267
2310
|
const flags = ts.getCombinedModifierFlags(fn);
|
|
2268
|
-
this.
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2311
|
+
const declarations = this.checker.getSymbolAtLocation(fn.name)?.declarations;
|
|
2312
|
+
// TypeScript records a property written on the function as an additional
|
|
2313
|
+
// declaration. Ordinary displayName assignments still have one function body.
|
|
2314
|
+
if (declarations?.includes(fn) &&
|
|
2315
|
+
declarations.every((item) => item === fn ||
|
|
2316
|
+
(!(flags & ts.ModifierFlags.Export) &&
|
|
2317
|
+
ts.isIdentifier(item) &&
|
|
2318
|
+
this.isOrdinaryElementMetadata(item, fn))))
|
|
2319
|
+
this.elementChildren.push({
|
|
2320
|
+
start: fn.getStart(this.sf),
|
|
2321
|
+
exported: flags & ts.ModifierFlags.Export
|
|
2322
|
+
? flags & ts.ModifierFlags.Default
|
|
2323
|
+
? 'default'
|
|
2324
|
+
: fn.name.text
|
|
2325
|
+
: undefined,
|
|
2326
|
+
});
|
|
2276
2327
|
}
|
|
2277
2328
|
this.note(RULE.elementChildren, 'warning', fn, 'Nested TSRX children arrive as a render block. Pass element values explicitly with `children={...}` to keep this slot’s element type. If it only renders content and should accept nested templates, include `ChildrenBlock` from `octane/tsrx-boundary` in the children type.');
|
|
2278
2329
|
}
|
|
2330
|
+
isOrdinaryElementMetadata(ref, fn) {
|
|
2331
|
+
return (literalDisplayNameAssignment(ref, fn) &&
|
|
2332
|
+
(this.ordinaryElementMetadata ??= !hasPrototypeAccess(this.sf)));
|
|
2333
|
+
}
|
|
2279
2334
|
// The caller already established that this is an element-only slot. Array-only
|
|
2280
2335
|
// and parameterized element types still need the author's review.
|
|
2281
2336
|
acceptsSingleElement(type) {
|
|
@@ -3499,6 +3554,11 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
3499
3554
|
retained.push(text);
|
|
3500
3555
|
continue;
|
|
3501
3556
|
}
|
|
3557
|
+
if (!typeOnly && !mapped && Object.hasOwn(UNSUPPORTED_VALUES, name)) {
|
|
3558
|
+
retained.push(text);
|
|
3559
|
+
this.note(RULE.unsupported, 'error', item, `${UNSUPPORTED_VALUES[name]} This re-export stays on React.`);
|
|
3560
|
+
continue;
|
|
3561
|
+
}
|
|
3502
3562
|
if (name === 'SubmitEvent' ||
|
|
3503
3563
|
name === 'SubmitEventHandler' ||
|
|
3504
3564
|
name === 'ReactEventHandler') {
|
|
@@ -4393,8 +4453,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4393
4453
|
return null;
|
|
4394
4454
|
}
|
|
4395
4455
|
checkIntlProviderResources(tag) {
|
|
4396
|
-
|
|
4397
|
-
if (!resourceHint)
|
|
4456
|
+
if (!this.options.initializerResourceHint)
|
|
4398
4457
|
return;
|
|
4399
4458
|
// Provider admission already excludes spreads. JSX takes the last duplicate prop.
|
|
4400
4459
|
const attribute = (name) => tag.attributes.properties.findLast((attr) => ts.isJsxAttribute(attr) && ts.isIdentifier(attr.name) && attr.name.text === name);
|
|
@@ -4407,20 +4466,106 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4407
4466
|
const handler = callback?.initializer;
|
|
4408
4467
|
if (!callback || !handler || !ts.isJsxExpression(handler) || !handler.expression)
|
|
4409
4468
|
return;
|
|
4410
|
-
const
|
|
4411
|
-
if (
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
imported.typeOnly ||
|
|
4418
|
-
imported.namespace ||
|
|
4419
|
-
ts.findAncestor(declaration, ts.isImportDeclaration)?.attributes)
|
|
4469
|
+
const resource = this.intlCallbackResource(handler.expression);
|
|
4470
|
+
if (resource)
|
|
4471
|
+
this.note(RULE.bindings, 'error', callback, `IntlProvider can call \`${resource.name}\` for an empty locale. The retained callback uses React DOM ${resource.hint} outside the original React server request. Move it into Octane-compiled code or retain the React provider.`);
|
|
4472
|
+
}
|
|
4473
|
+
intlCallbackResource(handler) {
|
|
4474
|
+
const imported = this.directImportedValue(skipWrappers(handler))?.entry;
|
|
4475
|
+
if (!imported)
|
|
4420
4476
|
return;
|
|
4421
|
-
const hint =
|
|
4477
|
+
const hint = this.options.initializerResourceHint?.(imported.module, imported.imported, true);
|
|
4422
4478
|
if (hint)
|
|
4423
|
-
|
|
4479
|
+
return { name: imported.imported, hint };
|
|
4480
|
+
}
|
|
4481
|
+
checkIntlFactoryResources(setup) {
|
|
4482
|
+
if (!this.options.initializerResourceHint ||
|
|
4483
|
+
!this.options.reactIntlAdapter ||
|
|
4484
|
+
!this.options.automaticReactJsx)
|
|
4485
|
+
return;
|
|
4486
|
+
const firstConst = (statement) => {
|
|
4487
|
+
if (!statement || !ts.isVariableStatement(statement))
|
|
4488
|
+
return;
|
|
4489
|
+
const list = statement.declarationList;
|
|
4490
|
+
if (list.flags & ts.NodeFlags.Const && list.declarations.length === 1)
|
|
4491
|
+
return list.declarations[0];
|
|
4492
|
+
};
|
|
4493
|
+
const formatter = firstConst(setup[0]);
|
|
4494
|
+
if (!formatter || !ts.isIdentifier(formatter.name))
|
|
4495
|
+
return;
|
|
4496
|
+
const factory = formatter.initializer && skipWrappers(formatter.initializer);
|
|
4497
|
+
if (!factory ||
|
|
4498
|
+
!ts.isCallExpression(factory) ||
|
|
4499
|
+
ts.isOptionalChain(factory) ||
|
|
4500
|
+
factory.arguments.length !== 1)
|
|
4501
|
+
return;
|
|
4502
|
+
const binding = this.directImportedValue(skipWrappers(factory.expression))?.entry;
|
|
4503
|
+
if (binding?.module !== 'react-intl' || binding.imported !== 'createIntl')
|
|
4504
|
+
return;
|
|
4505
|
+
const options = skipWrappers(factory.arguments[0]);
|
|
4506
|
+
if (!options || !ts.isObjectLiteralExpression(options))
|
|
4507
|
+
return;
|
|
4508
|
+
const fields = new Map();
|
|
4509
|
+
for (const field of options.properties) {
|
|
4510
|
+
if (!field.name || !(ts.isIdentifier(field.name) || ts.isStringLiteral(field.name)))
|
|
4511
|
+
return;
|
|
4512
|
+
const key = field.name.text;
|
|
4513
|
+
if (key !== 'locale' && key !== 'messages' && key !== 'onError')
|
|
4514
|
+
return;
|
|
4515
|
+
if (fields.has(key))
|
|
4516
|
+
return;
|
|
4517
|
+
if (ts.isPropertyAssignment(field))
|
|
4518
|
+
fields.set(key, skipWrappers(field.initializer));
|
|
4519
|
+
else if (ts.isShorthandPropertyAssignment(field) && !field.objectAssignmentInitializer)
|
|
4520
|
+
fields.set(key, field.name);
|
|
4521
|
+
else
|
|
4522
|
+
return;
|
|
4523
|
+
}
|
|
4524
|
+
const locale = fields.get('locale');
|
|
4525
|
+
const handler = fields.get('onError');
|
|
4526
|
+
if (!locale || !ts.isStringLiteralLike(locale) || !handler)
|
|
4527
|
+
return;
|
|
4528
|
+
const messages = fields.get('messages');
|
|
4529
|
+
if (messages && (!ts.isObjectLiteralExpression(messages) || messages.properties.length))
|
|
4530
|
+
return;
|
|
4531
|
+
if (!this.options.originalIntlFactory?.())
|
|
4532
|
+
return;
|
|
4533
|
+
const resource = this.intlCallbackResource(handler);
|
|
4534
|
+
if (!resource)
|
|
4535
|
+
return;
|
|
4536
|
+
const report = (site, operation) => this.note(RULE.bindings, 'error', site, `${operation} can call \`${resource.name}\`. The retained callback uses React DOM ${resource.hint} outside the original React server request in standalone Octane SSR. Move it into Octane-compiled code or keep the formatting under React.`);
|
|
4537
|
+
if (locale.text === '') {
|
|
4538
|
+
report(factory, 'createIntl with an empty locale');
|
|
4539
|
+
return;
|
|
4540
|
+
}
|
|
4541
|
+
if (!messages)
|
|
4542
|
+
return;
|
|
4543
|
+
const read = firstConst(setup[1]);
|
|
4544
|
+
const format = read?.initializer;
|
|
4545
|
+
const call = format && skipWrappers(format);
|
|
4546
|
+
if (!call ||
|
|
4547
|
+
!ts.isCallExpression(call) ||
|
|
4548
|
+
ts.isOptionalChain(call) ||
|
|
4549
|
+
call.arguments.length !== 1)
|
|
4550
|
+
return;
|
|
4551
|
+
const method = call.expression;
|
|
4552
|
+
if (!ts.isPropertyAccessExpression(method) ||
|
|
4553
|
+
method.name.text !== 'formatMessage' ||
|
|
4554
|
+
!ts.isIdentifier(method.expression) ||
|
|
4555
|
+
this.declarationOf(method.expression) !== formatter)
|
|
4556
|
+
return;
|
|
4557
|
+
const value = skipWrappers(call.arguments[0]);
|
|
4558
|
+
if (!ts.isObjectLiteralExpression(value))
|
|
4559
|
+
return;
|
|
4560
|
+
const [id, extra] = value.properties;
|
|
4561
|
+
if (id &&
|
|
4562
|
+
!extra &&
|
|
4563
|
+
ts.isPropertyAssignment(id) &&
|
|
4564
|
+
(ts.isIdentifier(id.name) || ts.isStringLiteral(id.name)) &&
|
|
4565
|
+
id.name.text === 'id' &&
|
|
4566
|
+
ts.isStringLiteralLike(id.initializer) &&
|
|
4567
|
+
id.initializer.text)
|
|
4568
|
+
report(call, 'formatMessage with a missing translation');
|
|
4424
4569
|
}
|
|
4425
4570
|
checkInitializerResourceHints(initializer) {
|
|
4426
4571
|
const resourceHint = this.options.initializerResourceHint;
|
|
@@ -4780,7 +4925,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4780
4925
|
return false;
|
|
4781
4926
|
const simpleName = (name) => ts.isIdentifier(name) || ts.isStringLiteral(name) ? name.text : undefined;
|
|
4782
4927
|
const required = new Set([key]);
|
|
4783
|
-
const
|
|
4928
|
+
const coerced = new Set();
|
|
4784
4929
|
const addField = (name) => {
|
|
4785
4930
|
if (name === undefined || name === '__proto__')
|
|
4786
4931
|
return false;
|
|
@@ -4812,7 +4957,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4812
4957
|
outer.operator !== ts.SyntaxKind.PlusPlusToken &&
|
|
4813
4958
|
outer.operator !== ts.SyntaxKind.MinusMinusToken) {
|
|
4814
4959
|
if (outer.operator !== ts.SyntaxKind.ExclamationToken)
|
|
4815
|
-
|
|
4960
|
+
coerced.add(parent.name.text);
|
|
4816
4961
|
return true;
|
|
4817
4962
|
}
|
|
4818
4963
|
if (ts.isTypeOfExpression(outer) ||
|
|
@@ -4824,11 +4969,11 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4824
4969
|
(ts.isJsxExpression(outer) && ts.isJsxAttribute(outer.parent)) ||
|
|
4825
4970
|
outer === dependencies)
|
|
4826
4971
|
return true;
|
|
4827
|
-
const
|
|
4828
|
-
if (
|
|
4972
|
+
const coercesValue = nestedRead(parent);
|
|
4973
|
+
if (coercesValue === undefined)
|
|
4829
4974
|
return false;
|
|
4830
|
-
if (
|
|
4831
|
-
|
|
4975
|
+
if (coercesValue)
|
|
4976
|
+
coerced.add(parent.name.text);
|
|
4832
4977
|
return true;
|
|
4833
4978
|
});
|
|
4834
4979
|
if (!closed)
|
|
@@ -4855,7 +5000,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4855
5000
|
const name = simpleName(field.name);
|
|
4856
5001
|
if (name === undefined || name === '__proto__')
|
|
4857
5002
|
return false;
|
|
4858
|
-
if (
|
|
5003
|
+
if (coerced.has(name) && !isPrimitiveLiteral(field.initializer))
|
|
4859
5004
|
return false;
|
|
4860
5005
|
missing.delete(name);
|
|
4861
5006
|
}
|
|
@@ -4889,7 +5034,7 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4889
5034
|
ownsFields(next.body, prior.name));
|
|
4890
5035
|
});
|
|
4891
5036
|
}
|
|
4892
|
-
ownDataDependency(member, hook, dependencies,
|
|
5037
|
+
ownDataDependency(member, hook, dependencies, coercesValue, nestedRead) {
|
|
4893
5038
|
const receiver = skipWrappers(member.expression);
|
|
4894
5039
|
const name = ts.isPropertyAccessExpression(member)
|
|
4895
5040
|
? member.name
|
|
@@ -4921,25 +5066,119 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4921
5066
|
return false;
|
|
4922
5067
|
if (!name || (!ts.isIdentifier(name) && !ts.isStringLiteralLike(name))) {
|
|
4923
5068
|
// A numeric name can override the corresponding string name.
|
|
4924
|
-
if (
|
|
5069
|
+
if (coercesValue)
|
|
4925
5070
|
return false;
|
|
4926
5071
|
continue;
|
|
4927
5072
|
}
|
|
4928
5073
|
if (name.text !== key)
|
|
4929
5074
|
continue;
|
|
4930
5075
|
owns = true;
|
|
4931
|
-
if (
|
|
4932
|
-
!(ts.isPropertyAssignment(field) &&
|
|
5076
|
+
if (coercesValue &&
|
|
5077
|
+
!(ts.isPropertyAssignment(field) && isPrimitiveLiteral(field.initializer)))
|
|
4933
5078
|
return false;
|
|
4934
5079
|
}
|
|
4935
5080
|
return owns;
|
|
4936
5081
|
}
|
|
5082
|
+
copiesOwnGetter(spread, hook) {
|
|
5083
|
+
let object = skipWrappers(spread.expression);
|
|
5084
|
+
// An inline operand can invoke a getter before the outer copy begins.
|
|
5085
|
+
if (ts.isObjectLiteralExpression(object) &&
|
|
5086
|
+
object.properties.some((field) => ts.isSpreadAssignment(field) && this.copiesOwnGetter(field, hook)))
|
|
5087
|
+
return true;
|
|
5088
|
+
if (ts.isIdentifier(object)) {
|
|
5089
|
+
const owner = ts.findAncestor(hook, ts.isFunctionLike);
|
|
5090
|
+
const init = this.constValue(object);
|
|
5091
|
+
if (!init ||
|
|
5092
|
+
!owner ||
|
|
5093
|
+
!fixedBinding(this.checker, object, hook) ||
|
|
5094
|
+
!initializedBefore(this.checker, object, hook) ||
|
|
5095
|
+
this.localUses(object).some((name) => !declaresName(name) && !inTypeNode(name)) ||
|
|
5096
|
+
reads(owner, (name) => name.text === 'eval'))
|
|
5097
|
+
return false;
|
|
5098
|
+
object = skipWrappers(init);
|
|
5099
|
+
}
|
|
5100
|
+
if (!ts.isObjectLiteralExpression(object))
|
|
5101
|
+
return false;
|
|
5102
|
+
const overwritten = new Set();
|
|
5103
|
+
for (let i = object.properties.length - 1; i >= 0; i--) {
|
|
5104
|
+
const field = object.properties[i];
|
|
5105
|
+
// A later setter preserves an existing getter for its key.
|
|
5106
|
+
if (ts.isSetAccessorDeclaration(field))
|
|
5107
|
+
continue;
|
|
5108
|
+
if (ts.isGetAccessorDeclaration(field) && overwritten.size === 0)
|
|
5109
|
+
return true;
|
|
5110
|
+
const computed = field.name && ts.isComputedPropertyName(field.name);
|
|
5111
|
+
const name = computed ? skipWrappers(field.name.expression) : field.name;
|
|
5112
|
+
if (!name ||
|
|
5113
|
+
!((!computed && ts.isIdentifier(name)) ||
|
|
5114
|
+
ts.isStringLiteralLike(name) ||
|
|
5115
|
+
ts.isNumericLiteral(name)))
|
|
5116
|
+
return false;
|
|
5117
|
+
if (!computed && ts.isPropertyAssignment(field) && name.text === '__proto__')
|
|
5118
|
+
continue;
|
|
5119
|
+
if (ts.isGetAccessorDeclaration(field) && !overwritten.has(name.text))
|
|
5120
|
+
return true;
|
|
5121
|
+
overwritten.add(name.text);
|
|
5122
|
+
}
|
|
5123
|
+
return false;
|
|
5124
|
+
}
|
|
4937
5125
|
checkHookDependencyReads(node, deps) {
|
|
4938
5126
|
const list = skipWrappers(deps);
|
|
4939
5127
|
if (!this.emitsTsrx || !ts.isArrayLiteralExpression(list))
|
|
4940
5128
|
return;
|
|
4941
|
-
|
|
5129
|
+
let memberReads;
|
|
5130
|
+
const recordStateRead = (member, coercesValue) => {
|
|
5131
|
+
memberReads?.set(member, coercesValue);
|
|
5132
|
+
return undefined;
|
|
5133
|
+
};
|
|
5134
|
+
const read = (expr, visit, coercesValue = false) => {
|
|
4942
5135
|
const member = skipWrappers(expr);
|
|
5136
|
+
if (ts.isSpreadElement(member)) {
|
|
5137
|
+
const value = skipWrappers(member.expression);
|
|
5138
|
+
const stateProof = visit === recordStateRead;
|
|
5139
|
+
if (stateProof && !ts.isArrayLiteralExpression(value))
|
|
5140
|
+
return;
|
|
5141
|
+
// A custom iterator can observe elements of a fresh array.
|
|
5142
|
+
return read(value, visit, coercesValue || stateProof);
|
|
5143
|
+
}
|
|
5144
|
+
if (ts.isArrayLiteralExpression(member)) {
|
|
5145
|
+
for (const item of member.elements) {
|
|
5146
|
+
const found = read(item, visit, coercesValue);
|
|
5147
|
+
if (found)
|
|
5148
|
+
return found;
|
|
5149
|
+
}
|
|
5150
|
+
return;
|
|
5151
|
+
}
|
|
5152
|
+
if (ts.isObjectLiteralExpression(member)) {
|
|
5153
|
+
for (const property of member.properties) {
|
|
5154
|
+
if (ts.isSpreadAssignment(property)) {
|
|
5155
|
+
if (visit !== recordStateRead && this.copiesOwnGetter(property, node))
|
|
5156
|
+
return property;
|
|
5157
|
+
continue;
|
|
5158
|
+
}
|
|
5159
|
+
const name = property.name;
|
|
5160
|
+
if (name && ts.isComputedPropertyName(name)) {
|
|
5161
|
+
const found = read(name.expression, visit, true);
|
|
5162
|
+
if (found)
|
|
5163
|
+
return found;
|
|
5164
|
+
}
|
|
5165
|
+
// Method and accessor bodies are deferred. Outer coercion or iteration can read any field.
|
|
5166
|
+
if (ts.isPropertyAssignment(property)) {
|
|
5167
|
+
const found = read(property.initializer, visit, coercesValue);
|
|
5168
|
+
if (found)
|
|
5169
|
+
return found;
|
|
5170
|
+
}
|
|
5171
|
+
}
|
|
5172
|
+
return;
|
|
5173
|
+
}
|
|
5174
|
+
if (ts.isTemplateExpression(member)) {
|
|
5175
|
+
for (const span of member.templateSpans) {
|
|
5176
|
+
const found = read(span.expression, visit, true);
|
|
5177
|
+
if (found)
|
|
5178
|
+
return found;
|
|
5179
|
+
}
|
|
5180
|
+
return;
|
|
5181
|
+
}
|
|
4943
5182
|
if (ts.isTypeOfExpression(member) || ts.isVoidExpression(member))
|
|
4944
5183
|
return read(member.expression, visit);
|
|
4945
5184
|
if (ts.isPrefixUnaryExpression(member) &&
|
|
@@ -4949,20 +5188,33 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4949
5188
|
if (ts.isConditionalExpression(member)) {
|
|
4950
5189
|
const condition = skipWrappers(member.condition);
|
|
4951
5190
|
if (condition.kind === ts.SyntaxKind.TrueKeyword)
|
|
4952
|
-
return read(member.whenTrue, visit,
|
|
5191
|
+
return read(member.whenTrue, visit, coercesValue);
|
|
4953
5192
|
if (condition.kind === ts.SyntaxKind.FalseKeyword)
|
|
4954
|
-
return read(member.whenFalse, visit,
|
|
5193
|
+
return read(member.whenFalse, visit, coercesValue);
|
|
4955
5194
|
return (read(condition, visit) ??
|
|
4956
|
-
read(member.whenTrue, visit,
|
|
4957
|
-
read(member.whenFalse, visit,
|
|
5195
|
+
read(member.whenTrue, visit, coercesValue) ??
|
|
5196
|
+
read(member.whenFalse, visit, coercesValue));
|
|
4958
5197
|
}
|
|
4959
5198
|
if (ts.isBinaryExpression(member)) {
|
|
4960
5199
|
const op = member.operatorToken.kind;
|
|
5200
|
+
// The left value is read and discarded. Only the right value reaches outer coercion.
|
|
5201
|
+
if (op === ts.SyntaxKind.CommaToken)
|
|
5202
|
+
return read(member.left, visit) ?? read(member.right, visit, coercesValue);
|
|
5203
|
+
// Strict comparison reads both operands and does not coerce either.
|
|
5204
|
+
if (op === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
5205
|
+
op === ts.SyntaxKind.ExclamationEqualsEqualsToken)
|
|
5206
|
+
return read(member.left, visit) ?? read(member.right, visit);
|
|
5207
|
+
// Relational comparison can coerce either operand through user code.
|
|
5208
|
+
if (op === ts.SyntaxKind.LessThanToken ||
|
|
5209
|
+
op === ts.SyntaxKind.LessThanEqualsToken ||
|
|
5210
|
+
op === ts.SyntaxKind.GreaterThanToken ||
|
|
5211
|
+
op === ts.SyntaxKind.GreaterThanEqualsToken)
|
|
5212
|
+
return read(member.left, visit, true) ?? read(member.right, visit, true);
|
|
4961
5213
|
if (op === ts.SyntaxKind.AmpersandAmpersandToken ||
|
|
4962
5214
|
op === ts.SyntaxKind.BarBarToken ||
|
|
4963
5215
|
op === ts.SyntaxKind.QuestionQuestionToken) {
|
|
4964
5216
|
// Only a falsy left value can become the result of &&.
|
|
4965
|
-
const left = read(member.left, visit,
|
|
5217
|
+
const left = read(member.left, visit, coercesValue && op !== ts.SyntaxKind.AmpersandAmpersandToken);
|
|
4966
5218
|
if (left)
|
|
4967
5219
|
return left;
|
|
4968
5220
|
const condition = literalCondition(member.left);
|
|
@@ -4970,31 +5222,25 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
4970
5222
|
(op === ts.SyntaxKind.AmpersandAmpersandToken && condition === 'truthy') ||
|
|
4971
5223
|
(op === ts.SyntaxKind.BarBarToken && condition !== 'truthy') ||
|
|
4972
5224
|
(op === ts.SyntaxKind.QuestionQuestionToken && condition === 'nullish'))
|
|
4973
|
-
return read(member.right, visit,
|
|
5225
|
+
return read(member.right, visit, coercesValue);
|
|
4974
5226
|
}
|
|
4975
5227
|
}
|
|
4976
5228
|
if (ts.isPropertyAccessExpression(member) || ts.isElementAccessExpression(member))
|
|
4977
|
-
return visit(member,
|
|
5229
|
+
return visit(member, coercesValue);
|
|
4978
5230
|
};
|
|
4979
5231
|
// The closed-state proof must account for every field read in this list.
|
|
4980
|
-
let members;
|
|
4981
5232
|
const nestedRead = (member) => {
|
|
4982
|
-
if (!
|
|
4983
|
-
|
|
4984
|
-
for (const entry of list.elements)
|
|
4985
|
-
read(entry,
|
|
4986
|
-
reachable.set(dep, coercesNumber);
|
|
4987
|
-
return undefined;
|
|
4988
|
-
});
|
|
4989
|
-
}
|
|
4990
|
-
members = reachable;
|
|
5233
|
+
if (!memberReads) {
|
|
5234
|
+
memberReads = new Map();
|
|
5235
|
+
for (const entry of list.elements)
|
|
5236
|
+
read(entry, recordStateRead);
|
|
4991
5237
|
}
|
|
4992
|
-
return
|
|
5238
|
+
return memberReads.get(member);
|
|
4993
5239
|
};
|
|
4994
5240
|
let opaqueCoercion = false;
|
|
4995
|
-
const check = (member,
|
|
4996
|
-
if (!this.ownDataDependency(member, node, list,
|
|
4997
|
-
opaqueCoercion =
|
|
5241
|
+
const check = (member, coercesValue) => {
|
|
5242
|
+
if (!this.ownDataDependency(member, node, list, coercesValue, nestedRead)) {
|
|
5243
|
+
opaqueCoercion = coercesValue;
|
|
4998
5244
|
return member;
|
|
4999
5245
|
}
|
|
5000
5246
|
};
|
|
@@ -5005,9 +5251,11 @@ function ${this.nativeRefStoreFactory}<T>(initial: T) {
|
|
|
5005
5251
|
break;
|
|
5006
5252
|
}
|
|
5007
5253
|
if (opaque)
|
|
5008
|
-
this.note(RULE.deps, 'error', opaque,
|
|
5009
|
-
? 'This hook dependency
|
|
5010
|
-
:
|
|
5254
|
+
this.note(RULE.deps, 'error', opaque, ts.isSpreadAssignment(opaque)
|
|
5255
|
+
? 'This hook dependency can invoke an own getter while spreading an object. Keep the component in React or verify the getter before moving it to native SSR.'
|
|
5256
|
+
: opaqueCoercion
|
|
5257
|
+
? 'This hook dependency reads a property during render. It may run a getter owned by React or execute user code during value coercion. Keep the component in React or verify the property before moving it to native SSR.'
|
|
5258
|
+
: 'This hook dependency reads a property during render and may run a getter owned by React. Keep the component in React or verify the getter before moving it to native SSR.');
|
|
5011
5259
|
}
|
|
5012
5260
|
/**
|
|
5013
5261
|
* React runs a hook with an omitted or undefined list on every render.
|
|
@@ -5814,7 +6062,8 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
5814
6062
|
this.count(RULE.className);
|
|
5815
6063
|
out += 'class' + this.emitInitializer(attribute);
|
|
5816
6064
|
}
|
|
5817
|
-
else if ((name === 'onChange' || name === 'onChangeCapture') &&
|
|
6065
|
+
else if ((name === 'onChange' || name === 'onChangeCapture') &&
|
|
6066
|
+
this.isTextEntry(element, name === 'onChange')) {
|
|
5818
6067
|
const input = name === 'onChange' ? 'onInput' : 'onInputCapture';
|
|
5819
6068
|
const existing = attributeOf(element, input);
|
|
5820
6069
|
const changesOrder = !spread &&
|
|
@@ -5867,11 +6116,60 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
5867
6116
|
return (this.source.slice(attribute.name.end, attribute.initializer.getStart(this.sf)) +
|
|
5868
6117
|
this.emit(attribute.initializer, PLAIN));
|
|
5869
6118
|
}
|
|
6119
|
+
textInputResult(expression) {
|
|
6120
|
+
if (!expression)
|
|
6121
|
+
return false;
|
|
6122
|
+
const value = skipWrappers(expression);
|
|
6123
|
+
if (ts.isConditionalExpression(value))
|
|
6124
|
+
return this.textInputResult(value.whenTrue) && this.textInputResult(value.whenFalse);
|
|
6125
|
+
return (ts.isStringLiteralLike(value) && (value.text === 'date' || TEXT_INPUT_TYPES.has(value.text)));
|
|
6126
|
+
}
|
|
6127
|
+
textInputTypeCall(call) {
|
|
6128
|
+
if (!ts.isIdentifier(call.expression) || !ts.isExternalModule(this.sf))
|
|
6129
|
+
return false;
|
|
6130
|
+
const symbol = this.checker.getSymbolAtLocation(call.expression);
|
|
6131
|
+
const fn = symbol?.valueDeclaration;
|
|
6132
|
+
if (symbol?.declarations?.length !== 1 ||
|
|
6133
|
+
!fn ||
|
|
6134
|
+
!ts.isFunctionDeclaration(fn) ||
|
|
6135
|
+
!fn.name ||
|
|
6136
|
+
!fn.body ||
|
|
6137
|
+
fn.parent !== this.sf ||
|
|
6138
|
+
fn.asteriskToken ||
|
|
6139
|
+
fn.modifiers?.length)
|
|
6140
|
+
return false;
|
|
6141
|
+
const [statement] = fn.body.statements;
|
|
6142
|
+
// Unmatched switch values and empty trailing clauses return undefined, the default text type.
|
|
6143
|
+
const knownResult = this.textInputResult(singleCallbackExpression(fn.body)) ||
|
|
6144
|
+
(fn.body.statements.length === 1 &&
|
|
6145
|
+
ts.isSwitchStatement(statement) &&
|
|
6146
|
+
statement.caseBlock.clauses.every(({ statements }) => {
|
|
6147
|
+
const [first] = statements;
|
|
6148
|
+
return (!first ||
|
|
6149
|
+
(statements.length === 1 &&
|
|
6150
|
+
ts.isReturnStatement(first) &&
|
|
6151
|
+
this.textInputResult(first.expression)));
|
|
6152
|
+
}));
|
|
6153
|
+
return (knownResult &&
|
|
6154
|
+
(!/eval|\\u/.test(this.source) || !hasEval(this.sf)) &&
|
|
6155
|
+
this.localUses(fn.name).every((ref) => inTypeNode(ref) || (ts.isCallExpression(ref.parent) && ref.parent.expression === ref)));
|
|
6156
|
+
}
|
|
6157
|
+
hasAncestorInputHandler(element) {
|
|
6158
|
+
for (let parent = element.parent; !ts.isFunctionLike(parent) && !ts.isSourceFile(parent); parent = parent.parent) {
|
|
6159
|
+
if (!ts.isJsxElement(parent) || parent.openingElement === element)
|
|
6160
|
+
continue;
|
|
6161
|
+
if (parent.openingElement.attributes.properties.some((attribute) => ts.isJsxSpreadAttribute(attribute) ||
|
|
6162
|
+
(ts.isIdentifier(attribute.name) &&
|
|
6163
|
+
/^on(?:Input|Change)(?:Capture)?$/.test(attribute.name.text))))
|
|
6164
|
+
return true;
|
|
6165
|
+
}
|
|
6166
|
+
return false;
|
|
6167
|
+
}
|
|
5870
6168
|
/**
|
|
5871
6169
|
* Whether `element` is a text-entry control, where React's `onChange` fires
|
|
5872
6170
|
* per edit and the native `change` fires on commit.
|
|
5873
6171
|
*/
|
|
5874
|
-
isTextEntry(element) {
|
|
6172
|
+
isTextEntry(element, ordinaryChange) {
|
|
5875
6173
|
const tag = element.tagName.getText(this.sf);
|
|
5876
6174
|
if (tag === 'textarea')
|
|
5877
6175
|
return true;
|
|
@@ -5886,13 +6184,21 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
5886
6184
|
if (tag === 'input' && value && ts.isJsxExpression(value) && value.expression) {
|
|
5887
6185
|
const expression = skipWrappers(value.expression);
|
|
5888
6186
|
// A spread can also supply the input handler that a rename would overwrite.
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
6187
|
+
const fixedType = !element.attributes.properties.some((attribute) => ts.isJsxSpreadAttribute(attribute) ||
|
|
6188
|
+
(attribute !== type && ts.isIdentifier(attribute.name) && attribute.name.text === 'type'));
|
|
6189
|
+
if (fixedType) {
|
|
6190
|
+
if (ts.isStringLiteralLike(expression) && TEXT_INPUT_TYPES.has(expression.text))
|
|
6191
|
+
return true;
|
|
6192
|
+
// React dispatches native input and synthetic change in separate passes.
|
|
6193
|
+
if (this.target === 'tsrx' &&
|
|
6194
|
+
ordinaryChange &&
|
|
6195
|
+
!attributeOf(element, 'ref') &&
|
|
6196
|
+
!attributeOf(element, 'onInputCapture') &&
|
|
6197
|
+
!attributeOf(element, 'onChangeCapture') &&
|
|
6198
|
+
((ts.isConditionalExpression(expression) && this.textInputResult(expression)) ||
|
|
6199
|
+
(ts.isCallExpression(expression) && this.textInputTypeCall(expression))) &&
|
|
6200
|
+
!this.hasAncestorInputHandler(element))
|
|
6201
|
+
return true;
|
|
5896
6202
|
}
|
|
5897
6203
|
}
|
|
5898
6204
|
this.note(RULE.nativeChange, 'warning', element, 'This `<input>` has a dynamic `type`; if it can be a text field, use `onInput` for per-edit updates.');
|
|
@@ -5970,7 +6276,7 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
5970
6276
|
if (!entry || entry.namespace || entry.typeOnly)
|
|
5971
6277
|
return false;
|
|
5972
6278
|
const name = entry.imported === 'default' ? entry.local : entry.imported;
|
|
5973
|
-
const context = this.options.isContext?.(entry.module, entry.imported, entry.local);
|
|
6279
|
+
const context = this.options.isContext?.(entry.module, entry.imported, entry.local, declaration != null && !!ts.findAncestor(declaration, ts.isImportDeclaration)?.attributes);
|
|
5974
6280
|
if (context !== 'review-alias')
|
|
5975
6281
|
return context ?? /Context$/.test(name);
|
|
5976
6282
|
if (member && !ts.isJsxClosingElement(member.parent))
|
|
@@ -6620,6 +6926,16 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
6620
6926
|
this.note(RULE.for, 'error', node, 'An @for row would discard this callback’s promise or iterator. Review the retained .map() call for suspension or iteration.');
|
|
6621
6927
|
return null;
|
|
6622
6928
|
}
|
|
6929
|
+
if (ts.isFunctionExpression(fn) &&
|
|
6930
|
+
fn.name &&
|
|
6931
|
+
(this.localUses(fn.name).length ||
|
|
6932
|
+
reads(fn, (name) => name.text === 'eval' &&
|
|
6933
|
+
!isPropertyName(name) &&
|
|
6934
|
+
!declaresName(name) &&
|
|
6935
|
+
!inTypeNode(name)))) {
|
|
6936
|
+
this.note(MAP_CALLBACK_SCOPE, 'error', node, 'An @for row cannot preserve this map callback’s local function name. Keep the original map callback until these references are migrated explicitly.');
|
|
6937
|
+
return null;
|
|
6938
|
+
}
|
|
6623
6939
|
if (fn.parameters.some((parameter) => readsFunctionContext(parameter, this.checker))) {
|
|
6624
6940
|
this.note(MAP_CALLBACK_SCOPE, 'error', node, 'An @for row cannot preserve this callback’s access to this, arguments, or new.target. Keep the original map callback until these reads are migrated explicitly.');
|
|
6625
6941
|
return null;
|
|
@@ -6800,6 +7116,17 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
6800
7116
|
(!ts.isBinaryExpression(receiver) && literalCondition(receiver) !== 'nullish')) &&
|
|
6801
7117
|
readsOrdinal(read.argumentExpression));
|
|
6802
7118
|
}
|
|
7119
|
+
if (ts.isNewExpression(read)) {
|
|
7120
|
+
const constructor = skipWrappers(read.expression);
|
|
7121
|
+
// A plain inline class finishes defining itself before the arguments run.
|
|
7122
|
+
return (ts.isClassExpression(constructor) &&
|
|
7123
|
+
!constructor.heritageClauses?.length &&
|
|
7124
|
+
!constructor.modifiers?.length &&
|
|
7125
|
+
constructor.members.every((member) => ts.isConstructorDeclaration(member) &&
|
|
7126
|
+
!member.modifiers?.length &&
|
|
7127
|
+
member.parameters.every((parameter) => !ts.getDecorators(parameter)?.length)) &&
|
|
7128
|
+
readsInOrder(read.arguments ?? []));
|
|
7129
|
+
}
|
|
6803
7130
|
if (ts.isCallExpression(read)) {
|
|
6804
7131
|
if (readsOrdinal(read.expression))
|
|
6805
7132
|
return true;
|
|
@@ -7060,6 +7387,7 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
7060
7387
|
let output = this.output(inner);
|
|
7061
7388
|
if (output === null)
|
|
7062
7389
|
return null;
|
|
7390
|
+
this.checkIntlFactoryResources(setupStatements);
|
|
7063
7391
|
const head = this.head(node, body.getStart(this.sf));
|
|
7064
7392
|
this.markTemplate();
|
|
7065
7393
|
if (this.startsLine(inner)) {
|
|
@@ -7105,6 +7433,7 @@ type ${handler}<T = unknown> = { listener(event: ${event}<T>): void }['listener'
|
|
|
7105
7433
|
const output = this.arm(last.expression, checkRoot && terminal === -1);
|
|
7106
7434
|
if (output === null)
|
|
7107
7435
|
return null;
|
|
7436
|
+
this.checkIntlFactoryResources(statements.slice(0, first));
|
|
7108
7437
|
const chain = (from) => {
|
|
7109
7438
|
let at = from;
|
|
7110
7439
|
while (at < statements.length - 1 && !guardReturn(statements[at]))
|