@typescript-deploys/pr-build 5.3.0-pr-56161-5 → 5.3.0-pr-55774-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/lib/tsc.js +355 -179
- package/lib/tsserver.js +374 -193
- package/lib/typescript.d.ts +13 -0
- package/lib/typescript.js +374 -193
- package/lib/typingsInstaller.js +24 -5
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.3";
|
|
38
|
-
version = `${versionMajorMinor}.0-insiders.
|
|
38
|
+
version = `${versionMajorMinor}.0-insiders.20231024`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -20769,8 +20769,9 @@ ${lanes.join("\n")}
|
|
|
20769
20769
|
ensureUseStrict,
|
|
20770
20770
|
liftToBlock,
|
|
20771
20771
|
mergeLexicalEnvironment,
|
|
20772
|
-
|
|
20773
|
-
|
|
20772
|
+
replaceModifiers,
|
|
20773
|
+
replaceDecoratorsAndModifiers,
|
|
20774
|
+
replacePropertyName
|
|
20774
20775
|
};
|
|
20775
20776
|
forEach(nodeFactoryPatchers, (fn) => fn(factory2));
|
|
20776
20777
|
return factory2;
|
|
@@ -24278,7 +24279,7 @@ ${lanes.join("\n")}
|
|
|
24278
24279
|
}
|
|
24279
24280
|
return statements;
|
|
24280
24281
|
}
|
|
24281
|
-
function
|
|
24282
|
+
function replaceModifiers(node, modifiers) {
|
|
24282
24283
|
let modifierArray;
|
|
24283
24284
|
if (typeof modifiers === "number") {
|
|
24284
24285
|
modifierArray = createModifiersFromModifierFlags(modifiers);
|
|
@@ -24287,9 +24288,27 @@ ${lanes.join("\n")}
|
|
|
24287
24288
|
}
|
|
24288
24289
|
return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node);
|
|
24289
24290
|
}
|
|
24290
|
-
function
|
|
24291
|
+
function replaceDecoratorsAndModifiers(node, modifierArray) {
|
|
24291
24292
|
return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node);
|
|
24292
24293
|
}
|
|
24294
|
+
function replacePropertyName(node, name) {
|
|
24295
|
+
switch (node.kind) {
|
|
24296
|
+
case 177 /* GetAccessor */:
|
|
24297
|
+
return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
|
|
24298
|
+
case 178 /* SetAccessor */:
|
|
24299
|
+
return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
|
|
24300
|
+
case 174 /* MethodDeclaration */:
|
|
24301
|
+
return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
24302
|
+
case 173 /* MethodSignature */:
|
|
24303
|
+
return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
|
|
24304
|
+
case 172 /* PropertyDeclaration */:
|
|
24305
|
+
return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
|
|
24306
|
+
case 171 /* PropertySignature */:
|
|
24307
|
+
return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
|
|
24308
|
+
case 303 /* PropertyAssignment */:
|
|
24309
|
+
return updatePropertyAssignment(node, name, node.initializer);
|
|
24310
|
+
}
|
|
24311
|
+
}
|
|
24293
24312
|
function asNodeArray(array) {
|
|
24294
24313
|
return array ? createNodeArray(array) : void 0;
|
|
24295
24314
|
}
|
|
@@ -52412,11 +52431,11 @@ ${lanes.join("\n")}
|
|
|
52412
52431
|
}
|
|
52413
52432
|
function addExportModifier(node) {
|
|
52414
52433
|
const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
|
|
52415
|
-
return factory.
|
|
52434
|
+
return factory.replaceModifiers(node, flags);
|
|
52416
52435
|
}
|
|
52417
52436
|
function removeExportModifier(node) {
|
|
52418
52437
|
const flags = getEffectiveModifierFlags(node) & ~1 /* Export */;
|
|
52419
|
-
return factory.
|
|
52438
|
+
return factory.replaceModifiers(node, flags);
|
|
52420
52439
|
}
|
|
52421
52440
|
function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) {
|
|
52422
52441
|
if (!suppressNewPrivateContext) {
|
|
@@ -52657,7 +52676,7 @@ ${lanes.join("\n")}
|
|
|
52657
52676
|
newModifierFlags |= 1024 /* Default */;
|
|
52658
52677
|
}
|
|
52659
52678
|
if (newModifierFlags) {
|
|
52660
|
-
node = factory.
|
|
52679
|
+
node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
|
|
52661
52680
|
}
|
|
52662
52681
|
}
|
|
52663
52682
|
results.push(node);
|
|
@@ -56619,7 +56638,13 @@ ${lanes.join("\n")}
|
|
|
56619
56638
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
56620
56639
|
const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
56621
56640
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
56622
|
-
|
|
56641
|
+
if (nameType && isTupleType(modifiersType)) {
|
|
56642
|
+
forEachType(getUnionType(getElementTypes(modifiersType).map((_, i) => getStringLiteralType("" + i))), addMemberForKeyType);
|
|
56643
|
+
} else if (isArrayType(modifiersType)) {
|
|
56644
|
+
addMemberForKeyType(numberType);
|
|
56645
|
+
} else {
|
|
56646
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
|
|
56647
|
+
}
|
|
56623
56648
|
} else {
|
|
56624
56649
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
56625
56650
|
}
|
|
@@ -58428,7 +58453,7 @@ ${lanes.join("\n")}
|
|
|
58428
58453
|
if (constraint) {
|
|
58429
58454
|
constraints = append(constraints, constraint);
|
|
58430
58455
|
}
|
|
58431
|
-
} else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && node === parent2.type) {
|
|
58456
|
+
} else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && (node === parent2.type || node === parent2.nameType)) {
|
|
58432
58457
|
const mappedType = getTypeFromTypeNode(parent2);
|
|
58433
58458
|
if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
|
|
58434
58459
|
const typeParameter = getHomomorphicTypeVariable(mappedType);
|
|
@@ -65211,6 +65236,9 @@ ${lanes.join("\n")}
|
|
|
65211
65236
|
}
|
|
65212
65237
|
function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
|
|
65213
65238
|
if (depth >= maxDepth) {
|
|
65239
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
65240
|
+
type = getMappedTargetWithSymbol(type);
|
|
65241
|
+
}
|
|
65214
65242
|
if (type.flags & 2097152 /* Intersection */) {
|
|
65215
65243
|
return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
|
|
65216
65244
|
}
|
|
@@ -65219,7 +65247,7 @@ ${lanes.join("\n")}
|
|
|
65219
65247
|
let lastTypeId = 0;
|
|
65220
65248
|
for (let i = 0; i < depth; i++) {
|
|
65221
65249
|
const t = stack[i];
|
|
65222
|
-
if (
|
|
65250
|
+
if (hasMatchingRecursionIdentity(t, identity2)) {
|
|
65223
65251
|
if (t.id >= lastTypeId) {
|
|
65224
65252
|
count++;
|
|
65225
65253
|
if (count >= maxDepth) {
|
|
@@ -65232,18 +65260,29 @@ ${lanes.join("\n")}
|
|
|
65232
65260
|
}
|
|
65233
65261
|
return false;
|
|
65234
65262
|
}
|
|
65263
|
+
function getMappedTargetWithSymbol(type) {
|
|
65264
|
+
let target;
|
|
65265
|
+
while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) {
|
|
65266
|
+
type = target;
|
|
65267
|
+
}
|
|
65268
|
+
return type;
|
|
65269
|
+
}
|
|
65270
|
+
function hasMatchingRecursionIdentity(type, identity2) {
|
|
65271
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
65272
|
+
type = getMappedTargetWithSymbol(type);
|
|
65273
|
+
}
|
|
65274
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
65275
|
+
return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2));
|
|
65276
|
+
}
|
|
65277
|
+
return getRecursionIdentity(type) === identity2;
|
|
65278
|
+
}
|
|
65235
65279
|
function getRecursionIdentity(type) {
|
|
65236
65280
|
if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
|
|
65237
65281
|
if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
|
|
65238
65282
|
return type.node;
|
|
65239
65283
|
}
|
|
65240
|
-
if (type.symbol) {
|
|
65241
|
-
|
|
65242
|
-
type = getMappedTargetWithSymbol(type);
|
|
65243
|
-
}
|
|
65244
|
-
if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
65245
|
-
return type.symbol;
|
|
65246
|
-
}
|
|
65284
|
+
if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
65285
|
+
return type.symbol;
|
|
65247
65286
|
}
|
|
65248
65287
|
if (isTupleType(type)) {
|
|
65249
65288
|
return type.target;
|
|
@@ -65263,13 +65302,6 @@ ${lanes.join("\n")}
|
|
|
65263
65302
|
}
|
|
65264
65303
|
return type;
|
|
65265
65304
|
}
|
|
65266
|
-
function getMappedTargetWithSymbol(type) {
|
|
65267
|
-
let target = type;
|
|
65268
|
-
while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) {
|
|
65269
|
-
target = getModifiersTypeFromMappedType(target);
|
|
65270
|
-
}
|
|
65271
|
-
return target.symbol ? target : type;
|
|
65272
|
-
}
|
|
65273
65305
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
65274
65306
|
return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
65275
65307
|
}
|
|
@@ -82169,7 +82201,7 @@ ${lanes.join("\n")}
|
|
|
82169
82201
|
error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
82170
82202
|
} else {
|
|
82171
82203
|
const text = getTextOfPropertyName(member.name);
|
|
82172
|
-
if (isNumericLiteralName(text)) {
|
|
82204
|
+
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
|
|
82173
82205
|
error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
82174
82206
|
}
|
|
82175
82207
|
}
|
|
@@ -100906,7 +100938,7 @@ ${lanes.join("\n")}
|
|
|
100906
100938
|
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
|
|
100907
100939
|
}
|
|
100908
100940
|
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
|
|
100909
|
-
return (hierarchyFacts & 8192 /*
|
|
100941
|
+
return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
|
|
100910
100942
|
}
|
|
100911
100943
|
function isOrMayContainReturnCompletion(node) {
|
|
100912
100944
|
return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ && (isReturnStatement(node) || isIfStatement(node) || isWithStatement(node) || isSwitchStatement(node) || isCaseBlock(node) || isCaseClause(node) || isDefaultClause(node) || isTryStatement(node) || isCatchClause(node) || isLabeledStatement(node) || isIterationStatement(
|
|
@@ -100916,7 +100948,7 @@ ${lanes.join("\n")}
|
|
|
100916
100948
|
) || isBlock(node));
|
|
100917
100949
|
}
|
|
100918
100950
|
function shouldVisitNode(node) {
|
|
100919
|
-
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /*
|
|
100951
|
+
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
|
|
100920
100952
|
node,
|
|
100921
100953
|
/*lookInLabeledStatements*/
|
|
100922
100954
|
false
|
|
@@ -100949,7 +100981,7 @@ ${lanes.join("\n")}
|
|
|
100949
100981
|
/*expressionResultIsUnused*/
|
|
100950
100982
|
false
|
|
100951
100983
|
);
|
|
100952
|
-
exitSubtree(ancestorFacts,
|
|
100984
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
100953
100985
|
return result;
|
|
100954
100986
|
}
|
|
100955
100987
|
return visitorWorker(
|
|
@@ -100963,6 +100995,7 @@ ${lanes.join("\n")}
|
|
|
100963
100995
|
function callExpressionVisitor(node) {
|
|
100964
100996
|
if (node.kind === 108 /* SuperKeyword */) {
|
|
100965
100997
|
return visitSuperKeyword(
|
|
100998
|
+
node,
|
|
100966
100999
|
/*isExpressionOfCall*/
|
|
100967
101000
|
true
|
|
100968
101001
|
);
|
|
@@ -101072,6 +101105,7 @@ ${lanes.join("\n")}
|
|
|
101072
101105
|
return visitSpreadElement(node);
|
|
101073
101106
|
case 108 /* SuperKeyword */:
|
|
101074
101107
|
return visitSuperKeyword(
|
|
101108
|
+
node,
|
|
101075
101109
|
/*isExpressionOfCall*/
|
|
101076
101110
|
false
|
|
101077
101111
|
);
|
|
@@ -101141,7 +101175,10 @@ ${lanes.join("\n")}
|
|
|
101141
101175
|
return updated;
|
|
101142
101176
|
}
|
|
101143
101177
|
function returnCapturedThis(node) {
|
|
101144
|
-
return setOriginalNode(factory2.createReturnStatement(
|
|
101178
|
+
return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
|
|
101179
|
+
}
|
|
101180
|
+
function createCapturedThis() {
|
|
101181
|
+
return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
101145
101182
|
}
|
|
101146
101183
|
function visitReturnStatement(node) {
|
|
101147
101184
|
if (convertedLoopState) {
|
|
@@ -101165,8 +101202,9 @@ ${lanes.join("\n")}
|
|
|
101165
101202
|
return visitEachChild(node, visitor, context);
|
|
101166
101203
|
}
|
|
101167
101204
|
function visitThisKeyword(node) {
|
|
101205
|
+
hierarchyFacts |= 65536 /* LexicalThis */;
|
|
101168
101206
|
if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
101169
|
-
hierarchyFacts |=
|
|
101207
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
101170
101208
|
}
|
|
101171
101209
|
if (convertedLoopState) {
|
|
101172
101210
|
if (hierarchyFacts & 2 /* ArrowFunction */) {
|
|
@@ -101305,7 +101343,7 @@ ${lanes.join("\n")}
|
|
|
101305
101343
|
void 0,
|
|
101306
101344
|
/*dotDotDotToken*/
|
|
101307
101345
|
void 0,
|
|
101308
|
-
|
|
101346
|
+
createSyntheticSuper()
|
|
101309
101347
|
)] : [],
|
|
101310
101348
|
/*type*/
|
|
101311
101349
|
void 0,
|
|
@@ -101395,7 +101433,7 @@ ${lanes.join("\n")}
|
|
|
101395
101433
|
setEmitFlags(constructorFunction, 16 /* CapturesThis */);
|
|
101396
101434
|
}
|
|
101397
101435
|
statements.push(constructorFunction);
|
|
101398
|
-
exitSubtree(ancestorFacts,
|
|
101436
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
101399
101437
|
convertedLoopState = savedConvertedLoopState;
|
|
101400
101438
|
}
|
|
101401
101439
|
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
|
|
@@ -101419,103 +101457,35 @@ ${lanes.join("\n")}
|
|
|
101419
101457
|
setEmitFlags(block, 3072 /* NoComments */);
|
|
101420
101458
|
return block;
|
|
101421
101459
|
}
|
|
101422
|
-
function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
|
|
101423
|
-
let mayReplaceThis = false;
|
|
101424
|
-
const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
|
|
101425
|
-
const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
|
|
101426
|
-
if (isFirstStatement && superStatementIndex >= 0) {
|
|
101427
|
-
let firstMaterialIndex = statementOffset;
|
|
101428
|
-
while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
|
|
101429
|
-
const statement = constructor.body.statements[firstMaterialIndex];
|
|
101430
|
-
if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
|
|
101431
|
-
break;
|
|
101432
|
-
firstMaterialIndex++;
|
|
101433
|
-
}
|
|
101434
|
-
isFirstStatement = superStatementIndex === firstMaterialIndex;
|
|
101435
|
-
}
|
|
101436
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
|
|
101437
|
-
const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
|
|
101438
|
-
if (superStatement && isTryStatement(superStatement)) {
|
|
101439
|
-
const tryBlockStatements = [];
|
|
101440
|
-
mayReplaceThis = transformConstructorBodyWorker(
|
|
101441
|
-
prologueOut,
|
|
101442
|
-
tryBlockStatements,
|
|
101443
|
-
superStatement.tryBlock.statements,
|
|
101444
|
-
/*statementOffset*/
|
|
101445
|
-
0,
|
|
101446
|
-
superPath,
|
|
101447
|
-
superPathDepth + 1,
|
|
101448
|
-
constructor,
|
|
101449
|
-
isDerivedClass,
|
|
101450
|
-
hasSynthesizedSuper,
|
|
101451
|
-
isFirstStatement
|
|
101452
|
-
);
|
|
101453
|
-
const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
|
|
101454
|
-
setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
|
|
101455
|
-
statementsOut.push(factory2.updateTryStatement(
|
|
101456
|
-
superStatement,
|
|
101457
|
-
factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
|
|
101458
|
-
visitNode(superStatement.catchClause, visitor, isCatchClause),
|
|
101459
|
-
visitNode(superStatement.finallyBlock, visitor, isBlock)
|
|
101460
|
-
));
|
|
101461
|
-
} else {
|
|
101462
|
-
const superCall = superStatement && getSuperCallFromStatement(superStatement);
|
|
101463
|
-
let superCallExpression;
|
|
101464
|
-
if (hasSynthesizedSuper) {
|
|
101465
|
-
superCallExpression = createDefaultSuperCallOrThis();
|
|
101466
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101467
|
-
} else if (superCall) {
|
|
101468
|
-
superCallExpression = visitSuperCallInBody(superCall);
|
|
101469
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101470
|
-
}
|
|
101471
|
-
if (isDerivedClass || superCallExpression) {
|
|
101472
|
-
if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
101473
|
-
const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
|
|
101474
|
-
const returnStatement = factory2.createReturnStatement(superCallExpression);
|
|
101475
|
-
setCommentRange(returnStatement, getCommentRange(superCall2));
|
|
101476
|
-
setEmitFlags(superCall2, 3072 /* NoComments */);
|
|
101477
|
-
statementsOut.push(returnStatement);
|
|
101478
|
-
return false;
|
|
101479
|
-
} else {
|
|
101480
|
-
if (isFirstStatement) {
|
|
101481
|
-
insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
|
|
101482
|
-
} else {
|
|
101483
|
-
insertCaptureThisForNode(prologueOut, constructor, createActualThis());
|
|
101484
|
-
if (superCallExpression) {
|
|
101485
|
-
addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
|
|
101486
|
-
}
|
|
101487
|
-
}
|
|
101488
|
-
mayReplaceThis = true;
|
|
101489
|
-
}
|
|
101490
|
-
} else {
|
|
101491
|
-
insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
|
|
101492
|
-
}
|
|
101493
|
-
}
|
|
101494
|
-
if (superStatementIndex >= 0) {
|
|
101495
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
|
|
101496
|
-
}
|
|
101497
|
-
return mayReplaceThis;
|
|
101498
|
-
}
|
|
101499
101460
|
function isUninitializedVariableStatement(node) {
|
|
101500
101461
|
return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
|
|
101501
101462
|
}
|
|
101502
|
-
function
|
|
101503
|
-
if (
|
|
101504
|
-
return
|
|
101505
|
-
|
|
101506
|
-
if (!
|
|
101507
|
-
return false;
|
|
101508
|
-
const initializer = varDecl.initializer;
|
|
101509
|
-
if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
|
|
101510
|
-
return false;
|
|
101511
|
-
const [stackProp, errorProp, hasErrorProp] = initializer.properties;
|
|
101512
|
-
if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
|
|
101513
|
-
return false;
|
|
101514
|
-
if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
|
|
101515
|
-
return false;
|
|
101516
|
-
if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
|
|
101463
|
+
function containsSuperCall(node) {
|
|
101464
|
+
if (isSuperCall(node)) {
|
|
101465
|
+
return true;
|
|
101466
|
+
}
|
|
101467
|
+
if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
|
|
101517
101468
|
return false;
|
|
101518
|
-
|
|
101469
|
+
}
|
|
101470
|
+
switch (node.kind) {
|
|
101471
|
+
case 219 /* ArrowFunction */:
|
|
101472
|
+
case 218 /* FunctionExpression */:
|
|
101473
|
+
case 262 /* FunctionDeclaration */:
|
|
101474
|
+
case 176 /* Constructor */:
|
|
101475
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
101476
|
+
return false;
|
|
101477
|
+
case 177 /* GetAccessor */:
|
|
101478
|
+
case 178 /* SetAccessor */:
|
|
101479
|
+
case 174 /* MethodDeclaration */:
|
|
101480
|
+
case 172 /* PropertyDeclaration */: {
|
|
101481
|
+
const named = node;
|
|
101482
|
+
if (isComputedPropertyName(named.name)) {
|
|
101483
|
+
return !!forEachChild(named.name, containsSuperCall);
|
|
101484
|
+
}
|
|
101485
|
+
return false;
|
|
101486
|
+
}
|
|
101487
|
+
}
|
|
101488
|
+
return !!forEachChild(node, containsSuperCall);
|
|
101519
101489
|
}
|
|
101520
101490
|
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
|
|
101521
101491
|
const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
|
|
@@ -101530,31 +101500,22 @@ ${lanes.join("\n")}
|
|
|
101530
101500
|
/*statementOffset*/
|
|
101531
101501
|
0
|
|
101532
101502
|
);
|
|
101533
|
-
|
|
101534
|
-
|
|
101535
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101503
|
+
if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
|
|
101504
|
+
hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
|
|
101536
101505
|
}
|
|
101537
|
-
|
|
101538
|
-
|
|
101539
|
-
statements,
|
|
101540
|
-
constructor.body.statements,
|
|
101541
|
-
standardPrologueEnd,
|
|
101542
|
-
superStatementIndices,
|
|
101543
|
-
/*superPathDepth*/
|
|
101544
|
-
0,
|
|
101545
|
-
constructor,
|
|
101546
|
-
isDerivedClass,
|
|
101547
|
-
hasSynthesizedSuper,
|
|
101548
|
-
/*isFirstStatement*/
|
|
101549
|
-
true
|
|
101550
|
-
// NOTE: this will be recalculated inside of transformConstructorBodyWorker
|
|
101551
|
-
);
|
|
101506
|
+
addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
|
|
101507
|
+
const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
|
|
101552
101508
|
addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
|
|
101553
101509
|
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
101554
101510
|
insertCaptureNewTargetIfNeeded(prologue, constructor);
|
|
101511
|
+
if (mayReplaceThis) {
|
|
101512
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
101513
|
+
} else {
|
|
101514
|
+
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
101515
|
+
}
|
|
101555
101516
|
factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
101556
101517
|
if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
101557
|
-
statements.push(factory2.createReturnStatement(
|
|
101518
|
+
statements.push(factory2.createReturnStatement(createCapturedThis()));
|
|
101558
101519
|
}
|
|
101559
101520
|
const body = factory2.createBlock(
|
|
101560
101521
|
setTextRange(
|
|
@@ -101571,6 +101532,230 @@ ${lanes.join("\n")}
|
|
|
101571
101532
|
true
|
|
101572
101533
|
);
|
|
101573
101534
|
setTextRange(body, constructor.body);
|
|
101535
|
+
return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
|
|
101536
|
+
}
|
|
101537
|
+
function isCapturedThis(node) {
|
|
101538
|
+
return isGeneratedIdentifier(node) && idText(node) === "_this";
|
|
101539
|
+
}
|
|
101540
|
+
function isSyntheticSuper(node) {
|
|
101541
|
+
return isGeneratedIdentifier(node) && idText(node) === "_super";
|
|
101542
|
+
}
|
|
101543
|
+
function isThisCapturingVariableStatement(node) {
|
|
101544
|
+
return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
|
|
101545
|
+
}
|
|
101546
|
+
function isThisCapturingVariableDeclaration(node) {
|
|
101547
|
+
return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
|
|
101548
|
+
}
|
|
101549
|
+
function isThisCapturingAssignment(node) {
|
|
101550
|
+
return isAssignmentExpression(
|
|
101551
|
+
node,
|
|
101552
|
+
/*excludeCompoundAssignment*/
|
|
101553
|
+
true
|
|
101554
|
+
) && isCapturedThis(node.left);
|
|
101555
|
+
}
|
|
101556
|
+
function isTransformedSuperCall(node) {
|
|
101557
|
+
return isCallExpression(node) && isPropertyAccessExpression(node.expression) && isSyntheticSuper(node.expression.expression) && isIdentifier(node.expression.name) && (idText(node.expression.name) === "call" || idText(node.expression.name) === "apply") && node.arguments.length >= 1 && node.arguments[0].kind === 110 /* ThisKeyword */;
|
|
101558
|
+
}
|
|
101559
|
+
function isTransformedSuperCallWithFallback(node) {
|
|
101560
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
|
|
101561
|
+
}
|
|
101562
|
+
function isImplicitSuperCall(node) {
|
|
101563
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 56 /* AmpersandAmpersandToken */ && isBinaryExpression(node.left) && node.left.operatorToken.kind === 38 /* ExclamationEqualsEqualsToken */ && isSyntheticSuper(node.left.left) && node.left.right.kind === 106 /* NullKeyword */ && isTransformedSuperCall(node.right) && idText(node.right.expression.name) === "apply";
|
|
101564
|
+
}
|
|
101565
|
+
function isImplicitSuperCallWithFallback(node) {
|
|
101566
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
|
|
101567
|
+
}
|
|
101568
|
+
function isThisCapturingTransformedSuperCallWithFallback(node) {
|
|
101569
|
+
return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
|
|
101570
|
+
}
|
|
101571
|
+
function isThisCapturingImplicitSuperCallWithFallback(node) {
|
|
101572
|
+
return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
|
|
101573
|
+
}
|
|
101574
|
+
function isTransformedSuperCallLike(node) {
|
|
101575
|
+
return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
|
|
101576
|
+
}
|
|
101577
|
+
function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
|
|
101578
|
+
for (let i = 0; i < body.statements.length - 1; i++) {
|
|
101579
|
+
const statement = body.statements[i];
|
|
101580
|
+
if (!isThisCapturingVariableStatement(statement)) {
|
|
101581
|
+
continue;
|
|
101582
|
+
}
|
|
101583
|
+
const varDecl = statement.declarationList.declarations[0];
|
|
101584
|
+
if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
|
|
101585
|
+
continue;
|
|
101586
|
+
}
|
|
101587
|
+
const thisCaptureStatementIndex = i;
|
|
101588
|
+
let superCallIndex = i + 1;
|
|
101589
|
+
while (superCallIndex < body.statements.length) {
|
|
101590
|
+
const statement2 = body.statements[superCallIndex];
|
|
101591
|
+
if (isExpressionStatement(statement2)) {
|
|
101592
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
|
|
101593
|
+
break;
|
|
101594
|
+
}
|
|
101595
|
+
}
|
|
101596
|
+
if (isUninitializedVariableStatement(statement2)) {
|
|
101597
|
+
superCallIndex++;
|
|
101598
|
+
continue;
|
|
101599
|
+
}
|
|
101600
|
+
return body;
|
|
101601
|
+
}
|
|
101602
|
+
const following = body.statements[superCallIndex];
|
|
101603
|
+
let expression = following.expression;
|
|
101604
|
+
if (isThisCapturingAssignment(expression)) {
|
|
101605
|
+
expression = expression.right;
|
|
101606
|
+
}
|
|
101607
|
+
const newVarDecl = factory2.updateVariableDeclaration(
|
|
101608
|
+
varDecl,
|
|
101609
|
+
varDecl.name,
|
|
101610
|
+
/*exclamationToken*/
|
|
101611
|
+
void 0,
|
|
101612
|
+
/*type*/
|
|
101613
|
+
void 0,
|
|
101614
|
+
expression
|
|
101615
|
+
);
|
|
101616
|
+
const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
|
|
101617
|
+
const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
|
|
101618
|
+
setOriginalNode(newVarStatement, following);
|
|
101619
|
+
setTextRange(newVarStatement, following);
|
|
101620
|
+
const newStatements = factory2.createNodeArray([
|
|
101621
|
+
...body.statements.slice(0, thisCaptureStatementIndex),
|
|
101622
|
+
// copy statements preceding to `var _this`
|
|
101623
|
+
...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
|
|
101624
|
+
// copy intervening temp variables
|
|
101625
|
+
newVarStatement,
|
|
101626
|
+
...body.statements.slice(superCallIndex + 1)
|
|
101627
|
+
// copy statements following `super.call(this, ...)`
|
|
101628
|
+
]);
|
|
101629
|
+
setTextRange(newStatements, body.statements);
|
|
101630
|
+
return factory2.updateBlock(body, newStatements);
|
|
101631
|
+
}
|
|
101632
|
+
return body;
|
|
101633
|
+
}
|
|
101634
|
+
function simplifyConstructorInlineSuperReturn(body, original) {
|
|
101635
|
+
for (const statement of original.statements) {
|
|
101636
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
101637
|
+
return body;
|
|
101638
|
+
}
|
|
101639
|
+
}
|
|
101640
|
+
const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
|
|
101641
|
+
for (let i = body.statements.length - 1; i > 0; i--) {
|
|
101642
|
+
const statement = body.statements[i];
|
|
101643
|
+
if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
|
|
101644
|
+
const preceding = body.statements[i - 1];
|
|
101645
|
+
let expression;
|
|
101646
|
+
if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
|
|
101647
|
+
expression = preceding.expression;
|
|
101648
|
+
} else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
|
|
101649
|
+
const varDecl = preceding.declarationList.declarations[0];
|
|
101650
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
|
|
101651
|
+
expression = factory2.createAssignment(
|
|
101652
|
+
createCapturedThis(),
|
|
101653
|
+
varDecl.initializer
|
|
101654
|
+
);
|
|
101655
|
+
}
|
|
101656
|
+
}
|
|
101657
|
+
if (!expression) {
|
|
101658
|
+
break;
|
|
101659
|
+
}
|
|
101660
|
+
const newReturnStatement = factory2.createReturnStatement(expression);
|
|
101661
|
+
setOriginalNode(newReturnStatement, preceding);
|
|
101662
|
+
setTextRange(newReturnStatement, preceding);
|
|
101663
|
+
const newStatements = factory2.createNodeArray([
|
|
101664
|
+
...body.statements.slice(0, i - 1),
|
|
101665
|
+
// copy all statements preceding `_super.call(this, ...)`
|
|
101666
|
+
newReturnStatement,
|
|
101667
|
+
...body.statements.slice(i + 1)
|
|
101668
|
+
// copy all statements following `return _this;`
|
|
101669
|
+
]);
|
|
101670
|
+
setTextRange(newStatements, body.statements);
|
|
101671
|
+
return factory2.updateBlock(body, newStatements);
|
|
101672
|
+
}
|
|
101673
|
+
}
|
|
101674
|
+
return body;
|
|
101675
|
+
}
|
|
101676
|
+
function elideUnusedThisCaptureWorker(node) {
|
|
101677
|
+
if (isThisCapturingVariableStatement(node)) {
|
|
101678
|
+
const varDecl = node.declarationList.declarations[0];
|
|
101679
|
+
if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
|
|
101680
|
+
return void 0;
|
|
101681
|
+
}
|
|
101682
|
+
} else if (isThisCapturingAssignment(node)) {
|
|
101683
|
+
return factory2.createPartiallyEmittedExpression(node.right, node);
|
|
101684
|
+
}
|
|
101685
|
+
switch (node.kind) {
|
|
101686
|
+
case 219 /* ArrowFunction */:
|
|
101687
|
+
case 218 /* FunctionExpression */:
|
|
101688
|
+
case 262 /* FunctionDeclaration */:
|
|
101689
|
+
case 176 /* Constructor */:
|
|
101690
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
101691
|
+
return node;
|
|
101692
|
+
case 177 /* GetAccessor */:
|
|
101693
|
+
case 178 /* SetAccessor */:
|
|
101694
|
+
case 174 /* MethodDeclaration */:
|
|
101695
|
+
case 172 /* PropertyDeclaration */: {
|
|
101696
|
+
const named = node;
|
|
101697
|
+
if (isComputedPropertyName(named.name)) {
|
|
101698
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
|
|
101699
|
+
}
|
|
101700
|
+
return node;
|
|
101701
|
+
}
|
|
101702
|
+
}
|
|
101703
|
+
return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
|
|
101704
|
+
}
|
|
101705
|
+
function simplifyConstructorElideUnusedThisCapture(body, original) {
|
|
101706
|
+
if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
|
|
101707
|
+
return body;
|
|
101708
|
+
}
|
|
101709
|
+
for (const statement of original.statements) {
|
|
101710
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
101711
|
+
return body;
|
|
101712
|
+
}
|
|
101713
|
+
}
|
|
101714
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
|
|
101715
|
+
}
|
|
101716
|
+
function injectSuperPresenceCheckWorker(node) {
|
|
101717
|
+
if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
|
|
101718
|
+
return factory2.createLogicalAnd(
|
|
101719
|
+
factory2.createStrictInequality(
|
|
101720
|
+
createSyntheticSuper(),
|
|
101721
|
+
factory2.createNull()
|
|
101722
|
+
),
|
|
101723
|
+
node
|
|
101724
|
+
);
|
|
101725
|
+
}
|
|
101726
|
+
switch (node.kind) {
|
|
101727
|
+
case 219 /* ArrowFunction */:
|
|
101728
|
+
case 218 /* FunctionExpression */:
|
|
101729
|
+
case 262 /* FunctionDeclaration */:
|
|
101730
|
+
case 176 /* Constructor */:
|
|
101731
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
101732
|
+
return node;
|
|
101733
|
+
case 177 /* GetAccessor */:
|
|
101734
|
+
case 178 /* SetAccessor */:
|
|
101735
|
+
case 174 /* MethodDeclaration */:
|
|
101736
|
+
case 172 /* PropertyDeclaration */: {
|
|
101737
|
+
const named = node;
|
|
101738
|
+
if (isComputedPropertyName(named.name)) {
|
|
101739
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
|
|
101740
|
+
}
|
|
101741
|
+
return node;
|
|
101742
|
+
}
|
|
101743
|
+
}
|
|
101744
|
+
return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
|
|
101745
|
+
}
|
|
101746
|
+
function complicateConstructorInjectSuperPresenceCheck(body) {
|
|
101747
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
|
|
101748
|
+
}
|
|
101749
|
+
function simplifyConstructor(body, original, hasSynthesizedSuper) {
|
|
101750
|
+
const inputBody = body;
|
|
101751
|
+
body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
|
|
101752
|
+
body = simplifyConstructorInlineSuperReturn(body, original);
|
|
101753
|
+
if (body !== inputBody) {
|
|
101754
|
+
body = simplifyConstructorElideUnusedThisCapture(body, original);
|
|
101755
|
+
}
|
|
101756
|
+
if (hasSynthesizedSuper) {
|
|
101757
|
+
body = complicateConstructorInjectSuperPresenceCheck(body);
|
|
101758
|
+
}
|
|
101574
101759
|
return body;
|
|
101575
101760
|
}
|
|
101576
101761
|
function isSufficientlyCoveredByReturnStatements(statement) {
|
|
@@ -101596,11 +101781,11 @@ ${lanes.join("\n")}
|
|
|
101596
101781
|
return factory2.createLogicalOr(
|
|
101597
101782
|
factory2.createLogicalAnd(
|
|
101598
101783
|
factory2.createStrictInequality(
|
|
101599
|
-
|
|
101784
|
+
createSyntheticSuper(),
|
|
101600
101785
|
factory2.createNull()
|
|
101601
101786
|
),
|
|
101602
101787
|
factory2.createFunctionApplyCall(
|
|
101603
|
-
|
|
101788
|
+
createSyntheticSuper(),
|
|
101604
101789
|
createActualThis(),
|
|
101605
101790
|
factory2.createIdentifier("arguments")
|
|
101606
101791
|
)
|
|
@@ -101855,24 +102040,12 @@ ${lanes.join("\n")}
|
|
|
101855
102040
|
return true;
|
|
101856
102041
|
}
|
|
101857
102042
|
function insertCaptureThisForNodeIfNeeded(statements, node) {
|
|
101858
|
-
if (hierarchyFacts &
|
|
102043
|
+
if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
|
|
101859
102044
|
insertCaptureThisForNode(statements, node, factory2.createThis());
|
|
101860
102045
|
return true;
|
|
101861
102046
|
}
|
|
101862
102047
|
return false;
|
|
101863
102048
|
}
|
|
101864
|
-
function addSuperThisCaptureThisForNode(statements, superExpression) {
|
|
101865
|
-
enableSubstitutionsForCapturedThis();
|
|
101866
|
-
const assignSuperExpression = factory2.createExpressionStatement(
|
|
101867
|
-
factory2.createBinaryExpression(
|
|
101868
|
-
factory2.createThis(),
|
|
101869
|
-
64 /* EqualsToken */,
|
|
101870
|
-
superExpression
|
|
101871
|
-
)
|
|
101872
|
-
);
|
|
101873
|
-
statements.push(assignSuperExpression);
|
|
101874
|
-
setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
|
|
101875
|
-
}
|
|
101876
102049
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
101877
102050
|
enableSubstitutionsForCapturedThis();
|
|
101878
102051
|
const captureThisStatement = factory2.createVariableStatement(
|
|
@@ -101880,7 +102053,7 @@ ${lanes.join("\n")}
|
|
|
101880
102053
|
void 0,
|
|
101881
102054
|
factory2.createVariableDeclarationList([
|
|
101882
102055
|
factory2.createVariableDeclaration(
|
|
101883
|
-
|
|
102056
|
+
createCapturedThis(),
|
|
101884
102057
|
/*exclamationToken*/
|
|
101885
102058
|
void 0,
|
|
101886
102059
|
/*type*/
|
|
@@ -102101,7 +102274,7 @@ ${lanes.join("\n")}
|
|
|
102101
102274
|
}
|
|
102102
102275
|
function visitArrowFunction(node) {
|
|
102103
102276
|
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
102104
|
-
hierarchyFacts |=
|
|
102277
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
102105
102278
|
}
|
|
102106
102279
|
const savedConvertedLoopState = convertedLoopState;
|
|
102107
102280
|
convertedLoopState = void 0;
|
|
@@ -102134,7 +102307,7 @@ ${lanes.join("\n")}
|
|
|
102134
102307
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
102135
102308
|
const body = transformFunctionBody2(node);
|
|
102136
102309
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
102137
|
-
exitSubtree(ancestorFacts,
|
|
102310
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102138
102311
|
convertedLoopState = savedConvertedLoopState;
|
|
102139
102312
|
return factory2.updateFunctionExpression(
|
|
102140
102313
|
node,
|
|
@@ -102157,7 +102330,7 @@ ${lanes.join("\n")}
|
|
|
102157
102330
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
102158
102331
|
const body = transformFunctionBody2(node);
|
|
102159
102332
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
102160
|
-
exitSubtree(ancestorFacts,
|
|
102333
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102161
102334
|
convertedLoopState = savedConvertedLoopState;
|
|
102162
102335
|
return factory2.updateFunctionDeclaration(
|
|
102163
102336
|
node,
|
|
@@ -102181,7 +102354,7 @@ ${lanes.join("\n")}
|
|
|
102181
102354
|
if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
|
|
102182
102355
|
name = factory2.getGeneratedNameForNode(node);
|
|
102183
102356
|
}
|
|
102184
|
-
exitSubtree(ancestorFacts,
|
|
102357
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102185
102358
|
convertedLoopState = savedConvertedLoopState;
|
|
102186
102359
|
return setOriginalNode(
|
|
102187
102360
|
setTextRange(
|
|
@@ -103590,7 +103763,7 @@ ${lanes.join("\n")}
|
|
|
103590
103763
|
} else {
|
|
103591
103764
|
updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
|
|
103592
103765
|
}
|
|
103593
|
-
exitSubtree(ancestorFacts,
|
|
103766
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
103594
103767
|
convertedLoopState = savedConvertedLoopState;
|
|
103595
103768
|
return updated;
|
|
103596
103769
|
}
|
|
@@ -103740,13 +103913,6 @@ ${lanes.join("\n")}
|
|
|
103740
103913
|
)
|
|
103741
103914
|
);
|
|
103742
103915
|
}
|
|
103743
|
-
function visitSuperCallInBody(node) {
|
|
103744
|
-
return visitCallExpressionWithPotentialCapturedThisAssignment(
|
|
103745
|
-
node,
|
|
103746
|
-
/*assignToCapturedThis*/
|
|
103747
|
-
false
|
|
103748
|
-
);
|
|
103749
|
-
}
|
|
103750
103916
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
103751
103917
|
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
|
|
103752
103918
|
const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
|
|
@@ -103783,10 +103949,13 @@ ${lanes.join("\n")}
|
|
|
103783
103949
|
resultingCall,
|
|
103784
103950
|
createActualThis()
|
|
103785
103951
|
);
|
|
103786
|
-
resultingCall = assignToCapturedThis ? factory2.createAssignment(
|
|
103952
|
+
resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
|
|
103787
103953
|
}
|
|
103788
103954
|
return setOriginalNode(resultingCall, node);
|
|
103789
103955
|
}
|
|
103956
|
+
if (isSuperCall(node)) {
|
|
103957
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
103958
|
+
}
|
|
103790
103959
|
return visitEachChild(node, visitor, context);
|
|
103791
103960
|
}
|
|
103792
103961
|
function visitNewExpression(node) {
|
|
@@ -103913,8 +104082,15 @@ ${lanes.join("\n")}
|
|
|
103913
104082
|
}
|
|
103914
104083
|
return setTextRange(expression, node);
|
|
103915
104084
|
}
|
|
103916
|
-
function
|
|
103917
|
-
return
|
|
104085
|
+
function createSyntheticSuper() {
|
|
104086
|
+
return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104087
|
+
}
|
|
104088
|
+
function visitSuperKeyword(node, isExpressionOfCall) {
|
|
104089
|
+
const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
|
|
104090
|
+
setOriginalNode(expression, node);
|
|
104091
|
+
setCommentRange(expression, node);
|
|
104092
|
+
setSourceMapRange(expression, node);
|
|
104093
|
+
return expression;
|
|
103918
104094
|
}
|
|
103919
104095
|
function visitMetaProperty(node) {
|
|
103920
104096
|
if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
|
|
@@ -104020,7 +104196,7 @@ ${lanes.join("\n")}
|
|
|
104020
104196
|
}
|
|
104021
104197
|
function substituteThisKeyword(node) {
|
|
104022
104198
|
if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
|
|
104023
|
-
return setTextRange(
|
|
104199
|
+
return setTextRange(createCapturedThis(), node);
|
|
104024
104200
|
}
|
|
104025
104201
|
return node;
|
|
104026
104202
|
}
|
|
@@ -111166,7 +111342,7 @@ ${lanes.join("\n")}
|
|
|
111166
111342
|
return statement;
|
|
111167
111343
|
}
|
|
111168
111344
|
const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
|
|
111169
|
-
return factory2.
|
|
111345
|
+
return factory2.replaceModifiers(statement, modifiers);
|
|
111170
111346
|
}
|
|
111171
111347
|
function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
|
|
111172
111348
|
const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
|
|
@@ -111297,7 +111473,7 @@ ${lanes.join("\n")}
|
|
|
111297
111473
|
return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
|
|
111298
111474
|
});
|
|
111299
111475
|
if (!exportMappings.length) {
|
|
111300
|
-
declarations = mapDefined(declarations, (declaration) => factory2.
|
|
111476
|
+
declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
|
|
111301
111477
|
} else {
|
|
111302
111478
|
declarations.push(factory2.createExportDeclaration(
|
|
111303
111479
|
/*modifiers*/
|
|
@@ -145503,7 +145679,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
145503
145679
|
}
|
|
145504
145680
|
}
|
|
145505
145681
|
fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite));
|
|
145506
|
-
const cloneWithModifier = factory.
|
|
145682
|
+
const cloneWithModifier = factory.replaceModifiers(
|
|
145507
145683
|
getSynthesizedDeepClone(
|
|
145508
145684
|
insertionSite,
|
|
145509
145685
|
/*includeTrivia*/
|
|
@@ -148682,7 +148858,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
148682
148858
|
defaultImport,
|
|
148683
148859
|
namedImports && arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
|
|
148684
148860
|
namespaceLikeImport,
|
|
148685
|
-
compilerOptions
|
|
148861
|
+
compilerOptions,
|
|
148862
|
+
preferences
|
|
148686
148863
|
);
|
|
148687
148864
|
newDeclarations = combine(newDeclarations, declarations);
|
|
148688
148865
|
});
|
|
@@ -149387,7 +149564,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
149387
149564
|
defaultImport,
|
|
149388
149565
|
namedImports,
|
|
149389
149566
|
namespaceLikeImport,
|
|
149390
|
-
program.getCompilerOptions()
|
|
149567
|
+
program.getCompilerOptions(),
|
|
149568
|
+
preferences
|
|
149391
149569
|
),
|
|
149392
149570
|
/*blankLineBetween*/
|
|
149393
149571
|
true,
|
|
@@ -149519,7 +149697,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
149519
149697
|
const newSpecifiers = stableSort(
|
|
149520
149698
|
namedImports.map(
|
|
149521
149699
|
(namedImport) => factory.createImportSpecifier(
|
|
149522
|
-
(!clause.isTypeOnly || promoteFromTypeOnly2) &&
|
|
149700
|
+
(!clause.isTypeOnly || promoteFromTypeOnly2) && shouldUseTypeOnly(namedImport, preferences),
|
|
149523
149701
|
/*propertyName*/
|
|
149524
149702
|
void 0,
|
|
149525
149703
|
factory.createIdentifier(namedImport.name)
|
|
@@ -149583,21 +149761,24 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
149583
149761
|
function needsTypeOnly({ addAsTypeOnly }) {
|
|
149584
149762
|
return addAsTypeOnly === 2 /* Required */;
|
|
149585
149763
|
}
|
|
149586
|
-
function
|
|
149764
|
+
function shouldUseTypeOnly(info, preferences) {
|
|
149765
|
+
return needsTypeOnly(info) || !!preferences.preferTypeOnlyAutoImports && info.addAsTypeOnly !== 4 /* NotAllowed */;
|
|
149766
|
+
}
|
|
149767
|
+
function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions, preferences) {
|
|
149587
149768
|
const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
|
|
149588
149769
|
let statements;
|
|
149589
149770
|
if (defaultImport !== void 0 || (namedImports == null ? void 0 : namedImports.length)) {
|
|
149590
|
-
const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || compilerOptions.verbatimModuleSyntax && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */);
|
|
149771
|
+
const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || (compilerOptions.verbatimModuleSyntax || preferences.preferTypeOnlyAutoImports) && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */);
|
|
149591
149772
|
statements = combine(
|
|
149592
149773
|
statements,
|
|
149593
149774
|
makeImport(
|
|
149594
149775
|
defaultImport && factory.createIdentifier(defaultImport.name),
|
|
149595
149776
|
namedImports == null ? void 0 : namedImports.map(
|
|
149596
|
-
(
|
|
149597
|
-
!topLevelTypeOnly &&
|
|
149777
|
+
(namedImport) => factory.createImportSpecifier(
|
|
149778
|
+
!topLevelTypeOnly && shouldUseTypeOnly(namedImport, preferences),
|
|
149598
149779
|
/*propertyName*/
|
|
149599
149780
|
void 0,
|
|
149600
|
-
factory.createIdentifier(name)
|
|
149781
|
+
factory.createIdentifier(namedImport.name)
|
|
149601
149782
|
)
|
|
149602
149783
|
),
|
|
149603
149784
|
moduleSpecifier,
|
|
@@ -149610,14 +149791,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
149610
149791
|
const declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ ? factory.createImportEqualsDeclaration(
|
|
149611
149792
|
/*modifiers*/
|
|
149612
149793
|
void 0,
|
|
149613
|
-
|
|
149794
|
+
shouldUseTypeOnly(namespaceLikeImport, preferences),
|
|
149614
149795
|
factory.createIdentifier(namespaceLikeImport.name),
|
|
149615
149796
|
factory.createExternalModuleReference(quotedModuleSpecifier)
|
|
149616
149797
|
) : factory.createImportDeclaration(
|
|
149617
149798
|
/*modifiers*/
|
|
149618
149799
|
void 0,
|
|
149619
149800
|
factory.createImportClause(
|
|
149620
|
-
|
|
149801
|
+
shouldUseTypeOnly(namespaceLikeImport, preferences),
|
|
149621
149802
|
/*name*/
|
|
149622
149803
|
void 0,
|
|
149623
149804
|
factory.createNamespaceImport(factory.createIdentifier(namespaceLikeImport.name))
|
|
@@ -157081,7 +157262,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
157081
157262
|
if (!completionNodes.length) {
|
|
157082
157263
|
modifiers = node.modifierFlagsCache | requiredModifiers;
|
|
157083
157264
|
}
|
|
157084
|
-
node = factory.
|
|
157265
|
+
node = factory.replaceModifiers(node, modifiers);
|
|
157085
157266
|
completionNodes.push(node);
|
|
157086
157267
|
},
|
|
157087
157268
|
body,
|
|
@@ -157107,11 +157288,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
157107
157288
|
modifiers &= ~4 /* Public */;
|
|
157108
157289
|
}
|
|
157109
157290
|
modifiers |= allowedAndPresent;
|
|
157110
|
-
completionNodes = completionNodes.map((node) => factory.
|
|
157291
|
+
completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers));
|
|
157111
157292
|
if (presentDecorators == null ? void 0 : presentDecorators.length) {
|
|
157112
157293
|
const lastNode = completionNodes[completionNodes.length - 1];
|
|
157113
157294
|
if (canHaveDecorators(lastNode)) {
|
|
157114
|
-
completionNodes[completionNodes.length - 1] = factory.
|
|
157295
|
+
completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
|
|
157115
157296
|
}
|
|
157116
157297
|
}
|
|
157117
157298
|
const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|