@typescript-deploys/pr-build 5.3.0-pr-55811-15 → 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 +333 -183
- package/lib/tsserver.js +337 -187
- package/lib/typescript.d.ts +12 -0
- package/lib/typescript.js +337 -187
- 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);
|
|
@@ -56530,18 +56549,6 @@ ${lanes.join("\n")}
|
|
|
56530
56549
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
56531
56550
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
56532
56551
|
}
|
|
56533
|
-
function getLimitedConstraint(type) {
|
|
56534
|
-
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
56535
|
-
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
56536
|
-
return;
|
|
56537
|
-
}
|
|
56538
|
-
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
56539
|
-
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
56540
|
-
return;
|
|
56541
|
-
}
|
|
56542
|
-
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
56543
|
-
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
56544
|
-
}
|
|
56545
56552
|
function resolveReverseMappedTypeMembers(type) {
|
|
56546
56553
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
56547
56554
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -56549,14 +56556,7 @@ ${lanes.join("\n")}
|
|
|
56549
56556
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
56550
56557
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
56551
56558
|
const members = createSymbolTable();
|
|
56552
|
-
const limitedConstraint = getLimitedConstraint(type);
|
|
56553
56559
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
56554
|
-
if (limitedConstraint) {
|
|
56555
|
-
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
56556
|
-
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
56557
|
-
continue;
|
|
56558
|
-
}
|
|
56559
|
-
}
|
|
56560
56560
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
56561
56561
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
56562
56562
|
inferredProp.declarations = prop.declarations;
|
|
@@ -56638,7 +56638,13 @@ ${lanes.join("\n")}
|
|
|
56638
56638
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
56639
56639
|
const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
56640
56640
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
56641
|
-
|
|
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
|
+
}
|
|
56642
56648
|
} else {
|
|
56643
56649
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
56644
56650
|
}
|
|
@@ -58447,7 +58453,7 @@ ${lanes.join("\n")}
|
|
|
58447
58453
|
if (constraint) {
|
|
58448
58454
|
constraints = append(constraints, constraint);
|
|
58449
58455
|
}
|
|
58450
|
-
} 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)) {
|
|
58451
58457
|
const mappedType = getTypeFromTypeNode(parent2);
|
|
58452
58458
|
if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
|
|
58453
58459
|
const typeParameter = getHomomorphicTypeVariable(mappedType);
|
|
@@ -66677,7 +66683,7 @@ ${lanes.join("\n")}
|
|
|
66677
66683
|
}
|
|
66678
66684
|
}
|
|
66679
66685
|
function inferToMappedType(source, target, constraintType) {
|
|
66680
|
-
if (constraintType.flags & 1048576 /* Union */
|
|
66686
|
+
if (constraintType.flags & 1048576 /* Union */) {
|
|
66681
66687
|
let result = false;
|
|
66682
66688
|
for (const type of constraintType.types) {
|
|
66683
66689
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -100932,7 +100938,7 @@ ${lanes.join("\n")}
|
|
|
100932
100938
|
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
|
|
100933
100939
|
}
|
|
100934
100940
|
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
|
|
100935
|
-
return (hierarchyFacts & 8192 /*
|
|
100941
|
+
return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
|
|
100936
100942
|
}
|
|
100937
100943
|
function isOrMayContainReturnCompletion(node) {
|
|
100938
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(
|
|
@@ -100942,7 +100948,7 @@ ${lanes.join("\n")}
|
|
|
100942
100948
|
) || isBlock(node));
|
|
100943
100949
|
}
|
|
100944
100950
|
function shouldVisitNode(node) {
|
|
100945
|
-
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(
|
|
100946
100952
|
node,
|
|
100947
100953
|
/*lookInLabeledStatements*/
|
|
100948
100954
|
false
|
|
@@ -100975,7 +100981,7 @@ ${lanes.join("\n")}
|
|
|
100975
100981
|
/*expressionResultIsUnused*/
|
|
100976
100982
|
false
|
|
100977
100983
|
);
|
|
100978
|
-
exitSubtree(ancestorFacts,
|
|
100984
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
100979
100985
|
return result;
|
|
100980
100986
|
}
|
|
100981
100987
|
return visitorWorker(
|
|
@@ -100989,6 +100995,7 @@ ${lanes.join("\n")}
|
|
|
100989
100995
|
function callExpressionVisitor(node) {
|
|
100990
100996
|
if (node.kind === 108 /* SuperKeyword */) {
|
|
100991
100997
|
return visitSuperKeyword(
|
|
100998
|
+
node,
|
|
100992
100999
|
/*isExpressionOfCall*/
|
|
100993
101000
|
true
|
|
100994
101001
|
);
|
|
@@ -101098,6 +101105,7 @@ ${lanes.join("\n")}
|
|
|
101098
101105
|
return visitSpreadElement(node);
|
|
101099
101106
|
case 108 /* SuperKeyword */:
|
|
101100
101107
|
return visitSuperKeyword(
|
|
101108
|
+
node,
|
|
101101
101109
|
/*isExpressionOfCall*/
|
|
101102
101110
|
false
|
|
101103
101111
|
);
|
|
@@ -101167,7 +101175,10 @@ ${lanes.join("\n")}
|
|
|
101167
101175
|
return updated;
|
|
101168
101176
|
}
|
|
101169
101177
|
function returnCapturedThis(node) {
|
|
101170
|
-
return setOriginalNode(factory2.createReturnStatement(
|
|
101178
|
+
return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
|
|
101179
|
+
}
|
|
101180
|
+
function createCapturedThis() {
|
|
101181
|
+
return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
101171
101182
|
}
|
|
101172
101183
|
function visitReturnStatement(node) {
|
|
101173
101184
|
if (convertedLoopState) {
|
|
@@ -101191,8 +101202,9 @@ ${lanes.join("\n")}
|
|
|
101191
101202
|
return visitEachChild(node, visitor, context);
|
|
101192
101203
|
}
|
|
101193
101204
|
function visitThisKeyword(node) {
|
|
101205
|
+
hierarchyFacts |= 65536 /* LexicalThis */;
|
|
101194
101206
|
if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
101195
|
-
hierarchyFacts |=
|
|
101207
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
101196
101208
|
}
|
|
101197
101209
|
if (convertedLoopState) {
|
|
101198
101210
|
if (hierarchyFacts & 2 /* ArrowFunction */) {
|
|
@@ -101331,7 +101343,7 @@ ${lanes.join("\n")}
|
|
|
101331
101343
|
void 0,
|
|
101332
101344
|
/*dotDotDotToken*/
|
|
101333
101345
|
void 0,
|
|
101334
|
-
|
|
101346
|
+
createSyntheticSuper()
|
|
101335
101347
|
)] : [],
|
|
101336
101348
|
/*type*/
|
|
101337
101349
|
void 0,
|
|
@@ -101421,7 +101433,7 @@ ${lanes.join("\n")}
|
|
|
101421
101433
|
setEmitFlags(constructorFunction, 16 /* CapturesThis */);
|
|
101422
101434
|
}
|
|
101423
101435
|
statements.push(constructorFunction);
|
|
101424
|
-
exitSubtree(ancestorFacts,
|
|
101436
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
101425
101437
|
convertedLoopState = savedConvertedLoopState;
|
|
101426
101438
|
}
|
|
101427
101439
|
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
|
|
@@ -101445,103 +101457,35 @@ ${lanes.join("\n")}
|
|
|
101445
101457
|
setEmitFlags(block, 3072 /* NoComments */);
|
|
101446
101458
|
return block;
|
|
101447
101459
|
}
|
|
101448
|
-
function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
|
|
101449
|
-
let mayReplaceThis = false;
|
|
101450
|
-
const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
|
|
101451
|
-
const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
|
|
101452
|
-
if (isFirstStatement && superStatementIndex >= 0) {
|
|
101453
|
-
let firstMaterialIndex = statementOffset;
|
|
101454
|
-
while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
|
|
101455
|
-
const statement = constructor.body.statements[firstMaterialIndex];
|
|
101456
|
-
if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
|
|
101457
|
-
break;
|
|
101458
|
-
firstMaterialIndex++;
|
|
101459
|
-
}
|
|
101460
|
-
isFirstStatement = superStatementIndex === firstMaterialIndex;
|
|
101461
|
-
}
|
|
101462
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
|
|
101463
|
-
const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
|
|
101464
|
-
if (superStatement && isTryStatement(superStatement)) {
|
|
101465
|
-
const tryBlockStatements = [];
|
|
101466
|
-
mayReplaceThis = transformConstructorBodyWorker(
|
|
101467
|
-
prologueOut,
|
|
101468
|
-
tryBlockStatements,
|
|
101469
|
-
superStatement.tryBlock.statements,
|
|
101470
|
-
/*statementOffset*/
|
|
101471
|
-
0,
|
|
101472
|
-
superPath,
|
|
101473
|
-
superPathDepth + 1,
|
|
101474
|
-
constructor,
|
|
101475
|
-
isDerivedClass,
|
|
101476
|
-
hasSynthesizedSuper,
|
|
101477
|
-
isFirstStatement
|
|
101478
|
-
);
|
|
101479
|
-
const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
|
|
101480
|
-
setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
|
|
101481
|
-
statementsOut.push(factory2.updateTryStatement(
|
|
101482
|
-
superStatement,
|
|
101483
|
-
factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
|
|
101484
|
-
visitNode(superStatement.catchClause, visitor, isCatchClause),
|
|
101485
|
-
visitNode(superStatement.finallyBlock, visitor, isBlock)
|
|
101486
|
-
));
|
|
101487
|
-
} else {
|
|
101488
|
-
const superCall = superStatement && getSuperCallFromStatement(superStatement);
|
|
101489
|
-
let superCallExpression;
|
|
101490
|
-
if (hasSynthesizedSuper) {
|
|
101491
|
-
superCallExpression = createDefaultSuperCallOrThis();
|
|
101492
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101493
|
-
} else if (superCall) {
|
|
101494
|
-
superCallExpression = visitSuperCallInBody(superCall);
|
|
101495
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101496
|
-
}
|
|
101497
|
-
if (isDerivedClass || superCallExpression) {
|
|
101498
|
-
if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
101499
|
-
const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
|
|
101500
|
-
const returnStatement = factory2.createReturnStatement(superCallExpression);
|
|
101501
|
-
setCommentRange(returnStatement, getCommentRange(superCall2));
|
|
101502
|
-
setEmitFlags(superCall2, 3072 /* NoComments */);
|
|
101503
|
-
statementsOut.push(returnStatement);
|
|
101504
|
-
return false;
|
|
101505
|
-
} else {
|
|
101506
|
-
if (isFirstStatement) {
|
|
101507
|
-
insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
|
|
101508
|
-
} else {
|
|
101509
|
-
insertCaptureThisForNode(prologueOut, constructor, createActualThis());
|
|
101510
|
-
if (superCallExpression) {
|
|
101511
|
-
addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
|
|
101512
|
-
}
|
|
101513
|
-
}
|
|
101514
|
-
mayReplaceThis = true;
|
|
101515
|
-
}
|
|
101516
|
-
} else {
|
|
101517
|
-
insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
|
|
101518
|
-
}
|
|
101519
|
-
}
|
|
101520
|
-
if (superStatementIndex >= 0) {
|
|
101521
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
|
|
101522
|
-
}
|
|
101523
|
-
return mayReplaceThis;
|
|
101524
|
-
}
|
|
101525
101460
|
function isUninitializedVariableStatement(node) {
|
|
101526
101461
|
return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
|
|
101527
101462
|
}
|
|
101528
|
-
function
|
|
101529
|
-
if (
|
|
101530
|
-
return
|
|
101531
|
-
|
|
101532
|
-
if (!
|
|
101533
|
-
return false;
|
|
101534
|
-
const initializer = varDecl.initializer;
|
|
101535
|
-
if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
|
|
101536
|
-
return false;
|
|
101537
|
-
const [stackProp, errorProp, hasErrorProp] = initializer.properties;
|
|
101538
|
-
if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
|
|
101539
|
-
return false;
|
|
101540
|
-
if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
|
|
101541
|
-
return false;
|
|
101542
|
-
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 */)) {
|
|
101543
101468
|
return false;
|
|
101544
|
-
|
|
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);
|
|
101545
101489
|
}
|
|
101546
101490
|
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
|
|
101547
101491
|
const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
|
|
@@ -101556,31 +101500,22 @@ ${lanes.join("\n")}
|
|
|
101556
101500
|
/*statementOffset*/
|
|
101557
101501
|
0
|
|
101558
101502
|
);
|
|
101559
|
-
|
|
101560
|
-
|
|
101561
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
101503
|
+
if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
|
|
101504
|
+
hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
|
|
101562
101505
|
}
|
|
101563
|
-
|
|
101564
|
-
|
|
101565
|
-
statements,
|
|
101566
|
-
constructor.body.statements,
|
|
101567
|
-
standardPrologueEnd,
|
|
101568
|
-
superStatementIndices,
|
|
101569
|
-
/*superPathDepth*/
|
|
101570
|
-
0,
|
|
101571
|
-
constructor,
|
|
101572
|
-
isDerivedClass,
|
|
101573
|
-
hasSynthesizedSuper,
|
|
101574
|
-
/*isFirstStatement*/
|
|
101575
|
-
true
|
|
101576
|
-
// NOTE: this will be recalculated inside of transformConstructorBodyWorker
|
|
101577
|
-
);
|
|
101506
|
+
addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
|
|
101507
|
+
const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
|
|
101578
101508
|
addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
|
|
101579
101509
|
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
101580
101510
|
insertCaptureNewTargetIfNeeded(prologue, constructor);
|
|
101511
|
+
if (mayReplaceThis) {
|
|
101512
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
101513
|
+
} else {
|
|
101514
|
+
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
101515
|
+
}
|
|
101581
101516
|
factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
101582
101517
|
if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
101583
|
-
statements.push(factory2.createReturnStatement(
|
|
101518
|
+
statements.push(factory2.createReturnStatement(createCapturedThis()));
|
|
101584
101519
|
}
|
|
101585
101520
|
const body = factory2.createBlock(
|
|
101586
101521
|
setTextRange(
|
|
@@ -101597,6 +101532,230 @@ ${lanes.join("\n")}
|
|
|
101597
101532
|
true
|
|
101598
101533
|
);
|
|
101599
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
|
+
}
|
|
101600
101759
|
return body;
|
|
101601
101760
|
}
|
|
101602
101761
|
function isSufficientlyCoveredByReturnStatements(statement) {
|
|
@@ -101622,11 +101781,11 @@ ${lanes.join("\n")}
|
|
|
101622
101781
|
return factory2.createLogicalOr(
|
|
101623
101782
|
factory2.createLogicalAnd(
|
|
101624
101783
|
factory2.createStrictInequality(
|
|
101625
|
-
|
|
101784
|
+
createSyntheticSuper(),
|
|
101626
101785
|
factory2.createNull()
|
|
101627
101786
|
),
|
|
101628
101787
|
factory2.createFunctionApplyCall(
|
|
101629
|
-
|
|
101788
|
+
createSyntheticSuper(),
|
|
101630
101789
|
createActualThis(),
|
|
101631
101790
|
factory2.createIdentifier("arguments")
|
|
101632
101791
|
)
|
|
@@ -101881,24 +102040,12 @@ ${lanes.join("\n")}
|
|
|
101881
102040
|
return true;
|
|
101882
102041
|
}
|
|
101883
102042
|
function insertCaptureThisForNodeIfNeeded(statements, node) {
|
|
101884
|
-
if (hierarchyFacts &
|
|
102043
|
+
if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
|
|
101885
102044
|
insertCaptureThisForNode(statements, node, factory2.createThis());
|
|
101886
102045
|
return true;
|
|
101887
102046
|
}
|
|
101888
102047
|
return false;
|
|
101889
102048
|
}
|
|
101890
|
-
function addSuperThisCaptureThisForNode(statements, superExpression) {
|
|
101891
|
-
enableSubstitutionsForCapturedThis();
|
|
101892
|
-
const assignSuperExpression = factory2.createExpressionStatement(
|
|
101893
|
-
factory2.createBinaryExpression(
|
|
101894
|
-
factory2.createThis(),
|
|
101895
|
-
64 /* EqualsToken */,
|
|
101896
|
-
superExpression
|
|
101897
|
-
)
|
|
101898
|
-
);
|
|
101899
|
-
statements.push(assignSuperExpression);
|
|
101900
|
-
setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
|
|
101901
|
-
}
|
|
101902
102049
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
101903
102050
|
enableSubstitutionsForCapturedThis();
|
|
101904
102051
|
const captureThisStatement = factory2.createVariableStatement(
|
|
@@ -101906,7 +102053,7 @@ ${lanes.join("\n")}
|
|
|
101906
102053
|
void 0,
|
|
101907
102054
|
factory2.createVariableDeclarationList([
|
|
101908
102055
|
factory2.createVariableDeclaration(
|
|
101909
|
-
|
|
102056
|
+
createCapturedThis(),
|
|
101910
102057
|
/*exclamationToken*/
|
|
101911
102058
|
void 0,
|
|
101912
102059
|
/*type*/
|
|
@@ -102127,7 +102274,7 @@ ${lanes.join("\n")}
|
|
|
102127
102274
|
}
|
|
102128
102275
|
function visitArrowFunction(node) {
|
|
102129
102276
|
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
102130
|
-
hierarchyFacts |=
|
|
102277
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
102131
102278
|
}
|
|
102132
102279
|
const savedConvertedLoopState = convertedLoopState;
|
|
102133
102280
|
convertedLoopState = void 0;
|
|
@@ -102160,7 +102307,7 @@ ${lanes.join("\n")}
|
|
|
102160
102307
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
102161
102308
|
const body = transformFunctionBody2(node);
|
|
102162
102309
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
102163
|
-
exitSubtree(ancestorFacts,
|
|
102310
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102164
102311
|
convertedLoopState = savedConvertedLoopState;
|
|
102165
102312
|
return factory2.updateFunctionExpression(
|
|
102166
102313
|
node,
|
|
@@ -102183,7 +102330,7 @@ ${lanes.join("\n")}
|
|
|
102183
102330
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
102184
102331
|
const body = transformFunctionBody2(node);
|
|
102185
102332
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
102186
|
-
exitSubtree(ancestorFacts,
|
|
102333
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102187
102334
|
convertedLoopState = savedConvertedLoopState;
|
|
102188
102335
|
return factory2.updateFunctionDeclaration(
|
|
102189
102336
|
node,
|
|
@@ -102207,7 +102354,7 @@ ${lanes.join("\n")}
|
|
|
102207
102354
|
if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
|
|
102208
102355
|
name = factory2.getGeneratedNameForNode(node);
|
|
102209
102356
|
}
|
|
102210
|
-
exitSubtree(ancestorFacts,
|
|
102357
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102211
102358
|
convertedLoopState = savedConvertedLoopState;
|
|
102212
102359
|
return setOriginalNode(
|
|
102213
102360
|
setTextRange(
|
|
@@ -103616,7 +103763,7 @@ ${lanes.join("\n")}
|
|
|
103616
103763
|
} else {
|
|
103617
103764
|
updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
|
|
103618
103765
|
}
|
|
103619
|
-
exitSubtree(ancestorFacts,
|
|
103766
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
103620
103767
|
convertedLoopState = savedConvertedLoopState;
|
|
103621
103768
|
return updated;
|
|
103622
103769
|
}
|
|
@@ -103766,13 +103913,6 @@ ${lanes.join("\n")}
|
|
|
103766
103913
|
)
|
|
103767
103914
|
);
|
|
103768
103915
|
}
|
|
103769
|
-
function visitSuperCallInBody(node) {
|
|
103770
|
-
return visitCallExpressionWithPotentialCapturedThisAssignment(
|
|
103771
|
-
node,
|
|
103772
|
-
/*assignToCapturedThis*/
|
|
103773
|
-
false
|
|
103774
|
-
);
|
|
103775
|
-
}
|
|
103776
103916
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
103777
103917
|
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
|
|
103778
103918
|
const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
|
|
@@ -103809,10 +103949,13 @@ ${lanes.join("\n")}
|
|
|
103809
103949
|
resultingCall,
|
|
103810
103950
|
createActualThis()
|
|
103811
103951
|
);
|
|
103812
|
-
resultingCall = assignToCapturedThis ? factory2.createAssignment(
|
|
103952
|
+
resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
|
|
103813
103953
|
}
|
|
103814
103954
|
return setOriginalNode(resultingCall, node);
|
|
103815
103955
|
}
|
|
103956
|
+
if (isSuperCall(node)) {
|
|
103957
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
103958
|
+
}
|
|
103816
103959
|
return visitEachChild(node, visitor, context);
|
|
103817
103960
|
}
|
|
103818
103961
|
function visitNewExpression(node) {
|
|
@@ -103939,8 +104082,15 @@ ${lanes.join("\n")}
|
|
|
103939
104082
|
}
|
|
103940
104083
|
return setTextRange(expression, node);
|
|
103941
104084
|
}
|
|
103942
|
-
function
|
|
103943
|
-
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;
|
|
103944
104094
|
}
|
|
103945
104095
|
function visitMetaProperty(node) {
|
|
103946
104096
|
if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
|
|
@@ -104046,7 +104196,7 @@ ${lanes.join("\n")}
|
|
|
104046
104196
|
}
|
|
104047
104197
|
function substituteThisKeyword(node) {
|
|
104048
104198
|
if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
|
|
104049
|
-
return setTextRange(
|
|
104199
|
+
return setTextRange(createCapturedThis(), node);
|
|
104050
104200
|
}
|
|
104051
104201
|
return node;
|
|
104052
104202
|
}
|
|
@@ -111192,7 +111342,7 @@ ${lanes.join("\n")}
|
|
|
111192
111342
|
return statement;
|
|
111193
111343
|
}
|
|
111194
111344
|
const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
|
|
111195
|
-
return factory2.
|
|
111345
|
+
return factory2.replaceModifiers(statement, modifiers);
|
|
111196
111346
|
}
|
|
111197
111347
|
function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
|
|
111198
111348
|
const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
|
|
@@ -111323,7 +111473,7 @@ ${lanes.join("\n")}
|
|
|
111323
111473
|
return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
|
|
111324
111474
|
});
|
|
111325
111475
|
if (!exportMappings.length) {
|
|
111326
|
-
declarations = mapDefined(declarations, (declaration) => factory2.
|
|
111476
|
+
declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
|
|
111327
111477
|
} else {
|
|
111328
111478
|
declarations.push(factory2.createExportDeclaration(
|
|
111329
111479
|
/*modifiers*/
|
|
@@ -145529,7 +145679,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
145529
145679
|
}
|
|
145530
145680
|
}
|
|
145531
145681
|
fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite));
|
|
145532
|
-
const cloneWithModifier = factory.
|
|
145682
|
+
const cloneWithModifier = factory.replaceModifiers(
|
|
145533
145683
|
getSynthesizedDeepClone(
|
|
145534
145684
|
insertionSite,
|
|
145535
145685
|
/*includeTrivia*/
|
|
@@ -157112,7 +157262,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
157112
157262
|
if (!completionNodes.length) {
|
|
157113
157263
|
modifiers = node.modifierFlagsCache | requiredModifiers;
|
|
157114
157264
|
}
|
|
157115
|
-
node = factory.
|
|
157265
|
+
node = factory.replaceModifiers(node, modifiers);
|
|
157116
157266
|
completionNodes.push(node);
|
|
157117
157267
|
},
|
|
157118
157268
|
body,
|
|
@@ -157138,11 +157288,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
157138
157288
|
modifiers &= ~4 /* Public */;
|
|
157139
157289
|
}
|
|
157140
157290
|
modifiers |= allowedAndPresent;
|
|
157141
|
-
completionNodes = completionNodes.map((node) => factory.
|
|
157291
|
+
completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers));
|
|
157142
157292
|
if (presentDecorators == null ? void 0 : presentDecorators.length) {
|
|
157143
157293
|
const lastNode = completionNodes[completionNodes.length - 1];
|
|
157144
157294
|
if (canHaveDecorators(lastNode)) {
|
|
157145
|
-
completionNodes[completionNodes.length - 1] = factory.
|
|
157295
|
+
completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
|
|
157146
157296
|
}
|
|
157147
157297
|
}
|
|
157148
157298
|
const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|