@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/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.3";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20231024`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -18747,8 +18747,9 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
18747
18747
|
ensureUseStrict,
|
|
18748
18748
|
liftToBlock,
|
|
18749
18749
|
mergeLexicalEnvironment,
|
|
18750
|
-
|
|
18751
|
-
|
|
18750
|
+
replaceModifiers,
|
|
18751
|
+
replaceDecoratorsAndModifiers,
|
|
18752
|
+
replacePropertyName
|
|
18752
18753
|
};
|
|
18753
18754
|
forEach(nodeFactoryPatchers, (fn) => fn(factory2));
|
|
18754
18755
|
return factory2;
|
|
@@ -22256,7 +22257,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22256
22257
|
}
|
|
22257
22258
|
return statements;
|
|
22258
22259
|
}
|
|
22259
|
-
function
|
|
22260
|
+
function replaceModifiers(node, modifiers) {
|
|
22260
22261
|
let modifierArray;
|
|
22261
22262
|
if (typeof modifiers === "number") {
|
|
22262
22263
|
modifierArray = createModifiersFromModifierFlags(modifiers);
|
|
@@ -22265,9 +22266,27 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22265
22266
|
}
|
|
22266
22267
|
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) ? updatePropertyDeclaration(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);
|
|
22267
22268
|
}
|
|
22268
|
-
function
|
|
22269
|
+
function replaceDecoratorsAndModifiers(node, modifierArray) {
|
|
22269
22270
|
return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration(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);
|
|
22270
22271
|
}
|
|
22272
|
+
function replacePropertyName(node, name) {
|
|
22273
|
+
switch (node.kind) {
|
|
22274
|
+
case 177 /* GetAccessor */:
|
|
22275
|
+
return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
|
|
22276
|
+
case 178 /* SetAccessor */:
|
|
22277
|
+
return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
|
|
22278
|
+
case 174 /* MethodDeclaration */:
|
|
22279
|
+
return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
22280
|
+
case 173 /* MethodSignature */:
|
|
22281
|
+
return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
|
|
22282
|
+
case 172 /* PropertyDeclaration */:
|
|
22283
|
+
return updatePropertyDeclaration(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
|
|
22284
|
+
case 171 /* PropertySignature */:
|
|
22285
|
+
return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
|
|
22286
|
+
case 303 /* PropertyAssignment */:
|
|
22287
|
+
return updatePropertyAssignment(node, name, node.initializer);
|
|
22288
|
+
}
|
|
22289
|
+
}
|
|
22271
22290
|
function asNodeArray(array) {
|
|
22272
22291
|
return array ? createNodeArray(array) : void 0;
|
|
22273
22292
|
}
|
|
@@ -49933,11 +49952,11 @@ function createTypeChecker(host) {
|
|
|
49933
49952
|
}
|
|
49934
49953
|
function addExportModifier(node) {
|
|
49935
49954
|
const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
|
|
49936
|
-
return factory.
|
|
49955
|
+
return factory.replaceModifiers(node, flags);
|
|
49937
49956
|
}
|
|
49938
49957
|
function removeExportModifier(node) {
|
|
49939
49958
|
const flags = getEffectiveModifierFlags(node) & ~1 /* Export */;
|
|
49940
|
-
return factory.
|
|
49959
|
+
return factory.replaceModifiers(node, flags);
|
|
49941
49960
|
}
|
|
49942
49961
|
function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) {
|
|
49943
49962
|
if (!suppressNewPrivateContext) {
|
|
@@ -50178,7 +50197,7 @@ function createTypeChecker(host) {
|
|
|
50178
50197
|
newModifierFlags |= 1024 /* Default */;
|
|
50179
50198
|
}
|
|
50180
50199
|
if (newModifierFlags) {
|
|
50181
|
-
node = factory.
|
|
50200
|
+
node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
|
|
50182
50201
|
}
|
|
50183
50202
|
}
|
|
50184
50203
|
results.push(node);
|
|
@@ -54051,18 +54070,6 @@ function createTypeChecker(host) {
|
|
|
54051
54070
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
54052
54071
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
54053
54072
|
}
|
|
54054
|
-
function getLimitedConstraint(type) {
|
|
54055
|
-
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
54056
|
-
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
54057
|
-
return;
|
|
54058
|
-
}
|
|
54059
|
-
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
54060
|
-
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
54061
|
-
return;
|
|
54062
|
-
}
|
|
54063
|
-
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
54064
|
-
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
54065
|
-
}
|
|
54066
54073
|
function resolveReverseMappedTypeMembers(type) {
|
|
54067
54074
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
54068
54075
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -54070,14 +54077,7 @@ function createTypeChecker(host) {
|
|
|
54070
54077
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
54071
54078
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
54072
54079
|
const members = createSymbolTable();
|
|
54073
|
-
const limitedConstraint = getLimitedConstraint(type);
|
|
54074
54080
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
54075
|
-
if (limitedConstraint) {
|
|
54076
|
-
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
54077
|
-
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
54078
|
-
continue;
|
|
54079
|
-
}
|
|
54080
|
-
}
|
|
54081
54081
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
54082
54082
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
54083
54083
|
inferredProp.declarations = prop.declarations;
|
|
@@ -54159,7 +54159,13 @@ function createTypeChecker(host) {
|
|
|
54159
54159
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
54160
54160
|
const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
54161
54161
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
54162
|
-
|
|
54162
|
+
if (nameType && isTupleType(modifiersType)) {
|
|
54163
|
+
forEachType(getUnionType(getElementTypes(modifiersType).map((_, i) => getStringLiteralType("" + i))), addMemberForKeyType);
|
|
54164
|
+
} else if (isArrayType(modifiersType)) {
|
|
54165
|
+
addMemberForKeyType(numberType);
|
|
54166
|
+
} else {
|
|
54167
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
|
|
54168
|
+
}
|
|
54163
54169
|
} else {
|
|
54164
54170
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
54165
54171
|
}
|
|
@@ -55968,7 +55974,7 @@ function createTypeChecker(host) {
|
|
|
55968
55974
|
if (constraint) {
|
|
55969
55975
|
constraints = append(constraints, constraint);
|
|
55970
55976
|
}
|
|
55971
|
-
} else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && node === parent.type) {
|
|
55977
|
+
} else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && (node === parent.type || node === parent.nameType)) {
|
|
55972
55978
|
const mappedType = getTypeFromTypeNode(parent);
|
|
55973
55979
|
if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
|
|
55974
55980
|
const typeParameter = getHomomorphicTypeVariable(mappedType);
|
|
@@ -64198,7 +64204,7 @@ function createTypeChecker(host) {
|
|
|
64198
64204
|
}
|
|
64199
64205
|
}
|
|
64200
64206
|
function inferToMappedType(source, target, constraintType) {
|
|
64201
|
-
if (constraintType.flags & 1048576 /* Union */
|
|
64207
|
+
if (constraintType.flags & 1048576 /* Union */) {
|
|
64202
64208
|
let result = false;
|
|
64203
64209
|
for (const type of constraintType.types) {
|
|
64204
64210
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -98021,7 +98027,7 @@ function transformES2015(context) {
|
|
|
98021
98027
|
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
|
|
98022
98028
|
}
|
|
98023
98029
|
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
|
|
98024
|
-
return (hierarchyFacts & 8192 /*
|
|
98030
|
+
return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
|
|
98025
98031
|
}
|
|
98026
98032
|
function isOrMayContainReturnCompletion(node) {
|
|
98027
98033
|
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(
|
|
@@ -98031,7 +98037,7 @@ function transformES2015(context) {
|
|
|
98031
98037
|
) || isBlock(node));
|
|
98032
98038
|
}
|
|
98033
98039
|
function shouldVisitNode(node) {
|
|
98034
|
-
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /*
|
|
98040
|
+
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
|
|
98035
98041
|
node,
|
|
98036
98042
|
/*lookInLabeledStatements*/
|
|
98037
98043
|
false
|
|
@@ -98064,7 +98070,7 @@ function transformES2015(context) {
|
|
|
98064
98070
|
/*expressionResultIsUnused*/
|
|
98065
98071
|
false
|
|
98066
98072
|
);
|
|
98067
|
-
exitSubtree(ancestorFacts,
|
|
98073
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
98068
98074
|
return result;
|
|
98069
98075
|
}
|
|
98070
98076
|
return visitorWorker(
|
|
@@ -98078,6 +98084,7 @@ function transformES2015(context) {
|
|
|
98078
98084
|
function callExpressionVisitor(node) {
|
|
98079
98085
|
if (node.kind === 108 /* SuperKeyword */) {
|
|
98080
98086
|
return visitSuperKeyword(
|
|
98087
|
+
node,
|
|
98081
98088
|
/*isExpressionOfCall*/
|
|
98082
98089
|
true
|
|
98083
98090
|
);
|
|
@@ -98187,6 +98194,7 @@ function transformES2015(context) {
|
|
|
98187
98194
|
return visitSpreadElement(node);
|
|
98188
98195
|
case 108 /* SuperKeyword */:
|
|
98189
98196
|
return visitSuperKeyword(
|
|
98197
|
+
node,
|
|
98190
98198
|
/*isExpressionOfCall*/
|
|
98191
98199
|
false
|
|
98192
98200
|
);
|
|
@@ -98256,7 +98264,10 @@ function transformES2015(context) {
|
|
|
98256
98264
|
return updated;
|
|
98257
98265
|
}
|
|
98258
98266
|
function returnCapturedThis(node) {
|
|
98259
|
-
return setOriginalNode(factory2.createReturnStatement(
|
|
98267
|
+
return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
|
|
98268
|
+
}
|
|
98269
|
+
function createCapturedThis() {
|
|
98270
|
+
return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
98260
98271
|
}
|
|
98261
98272
|
function visitReturnStatement(node) {
|
|
98262
98273
|
if (convertedLoopState) {
|
|
@@ -98280,8 +98291,9 @@ function transformES2015(context) {
|
|
|
98280
98291
|
return visitEachChild(node, visitor, context);
|
|
98281
98292
|
}
|
|
98282
98293
|
function visitThisKeyword(node) {
|
|
98294
|
+
hierarchyFacts |= 65536 /* LexicalThis */;
|
|
98283
98295
|
if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
98284
|
-
hierarchyFacts |=
|
|
98296
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
98285
98297
|
}
|
|
98286
98298
|
if (convertedLoopState) {
|
|
98287
98299
|
if (hierarchyFacts & 2 /* ArrowFunction */) {
|
|
@@ -98420,7 +98432,7 @@ function transformES2015(context) {
|
|
|
98420
98432
|
void 0,
|
|
98421
98433
|
/*dotDotDotToken*/
|
|
98422
98434
|
void 0,
|
|
98423
|
-
|
|
98435
|
+
createSyntheticSuper()
|
|
98424
98436
|
)] : [],
|
|
98425
98437
|
/*type*/
|
|
98426
98438
|
void 0,
|
|
@@ -98510,7 +98522,7 @@ function transformES2015(context) {
|
|
|
98510
98522
|
setEmitFlags(constructorFunction, 16 /* CapturesThis */);
|
|
98511
98523
|
}
|
|
98512
98524
|
statements.push(constructorFunction);
|
|
98513
|
-
exitSubtree(ancestorFacts,
|
|
98525
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
98514
98526
|
convertedLoopState = savedConvertedLoopState;
|
|
98515
98527
|
}
|
|
98516
98528
|
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
|
|
@@ -98534,103 +98546,35 @@ function transformES2015(context) {
|
|
|
98534
98546
|
setEmitFlags(block, 3072 /* NoComments */);
|
|
98535
98547
|
return block;
|
|
98536
98548
|
}
|
|
98537
|
-
function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
|
|
98538
|
-
let mayReplaceThis = false;
|
|
98539
|
-
const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
|
|
98540
|
-
const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
|
|
98541
|
-
if (isFirstStatement && superStatementIndex >= 0) {
|
|
98542
|
-
let firstMaterialIndex = statementOffset;
|
|
98543
|
-
while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
|
|
98544
|
-
const statement = constructor.body.statements[firstMaterialIndex];
|
|
98545
|
-
if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
|
|
98546
|
-
break;
|
|
98547
|
-
firstMaterialIndex++;
|
|
98548
|
-
}
|
|
98549
|
-
isFirstStatement = superStatementIndex === firstMaterialIndex;
|
|
98550
|
-
}
|
|
98551
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
|
|
98552
|
-
const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
|
|
98553
|
-
if (superStatement && isTryStatement(superStatement)) {
|
|
98554
|
-
const tryBlockStatements = [];
|
|
98555
|
-
mayReplaceThis = transformConstructorBodyWorker(
|
|
98556
|
-
prologueOut,
|
|
98557
|
-
tryBlockStatements,
|
|
98558
|
-
superStatement.tryBlock.statements,
|
|
98559
|
-
/*statementOffset*/
|
|
98560
|
-
0,
|
|
98561
|
-
superPath,
|
|
98562
|
-
superPathDepth + 1,
|
|
98563
|
-
constructor,
|
|
98564
|
-
isDerivedClass,
|
|
98565
|
-
hasSynthesizedSuper,
|
|
98566
|
-
isFirstStatement
|
|
98567
|
-
);
|
|
98568
|
-
const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
|
|
98569
|
-
setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
|
|
98570
|
-
statementsOut.push(factory2.updateTryStatement(
|
|
98571
|
-
superStatement,
|
|
98572
|
-
factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
|
|
98573
|
-
visitNode(superStatement.catchClause, visitor, isCatchClause),
|
|
98574
|
-
visitNode(superStatement.finallyBlock, visitor, isBlock)
|
|
98575
|
-
));
|
|
98576
|
-
} else {
|
|
98577
|
-
const superCall = superStatement && getSuperCallFromStatement(superStatement);
|
|
98578
|
-
let superCallExpression;
|
|
98579
|
-
if (hasSynthesizedSuper) {
|
|
98580
|
-
superCallExpression = createDefaultSuperCallOrThis();
|
|
98581
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98582
|
-
} else if (superCall) {
|
|
98583
|
-
superCallExpression = visitSuperCallInBody(superCall);
|
|
98584
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98585
|
-
}
|
|
98586
|
-
if (isDerivedClass || superCallExpression) {
|
|
98587
|
-
if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
98588
|
-
const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
|
|
98589
|
-
const returnStatement = factory2.createReturnStatement(superCallExpression);
|
|
98590
|
-
setCommentRange(returnStatement, getCommentRange(superCall2));
|
|
98591
|
-
setEmitFlags(superCall2, 3072 /* NoComments */);
|
|
98592
|
-
statementsOut.push(returnStatement);
|
|
98593
|
-
return false;
|
|
98594
|
-
} else {
|
|
98595
|
-
if (isFirstStatement) {
|
|
98596
|
-
insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
|
|
98597
|
-
} else {
|
|
98598
|
-
insertCaptureThisForNode(prologueOut, constructor, createActualThis());
|
|
98599
|
-
if (superCallExpression) {
|
|
98600
|
-
addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
|
|
98601
|
-
}
|
|
98602
|
-
}
|
|
98603
|
-
mayReplaceThis = true;
|
|
98604
|
-
}
|
|
98605
|
-
} else {
|
|
98606
|
-
insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
|
|
98607
|
-
}
|
|
98608
|
-
}
|
|
98609
|
-
if (superStatementIndex >= 0) {
|
|
98610
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
|
|
98611
|
-
}
|
|
98612
|
-
return mayReplaceThis;
|
|
98613
|
-
}
|
|
98614
98549
|
function isUninitializedVariableStatement(node) {
|
|
98615
98550
|
return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
|
|
98616
98551
|
}
|
|
98617
|
-
function
|
|
98618
|
-
if (
|
|
98619
|
-
return
|
|
98620
|
-
|
|
98621
|
-
if (!
|
|
98622
|
-
return false;
|
|
98623
|
-
const initializer = varDecl.initializer;
|
|
98624
|
-
if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
|
|
98625
|
-
return false;
|
|
98626
|
-
const [stackProp, errorProp, hasErrorProp] = initializer.properties;
|
|
98627
|
-
if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
|
|
98628
|
-
return false;
|
|
98629
|
-
if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
|
|
98630
|
-
return false;
|
|
98631
|
-
if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
|
|
98552
|
+
function containsSuperCall(node) {
|
|
98553
|
+
if (isSuperCall(node)) {
|
|
98554
|
+
return true;
|
|
98555
|
+
}
|
|
98556
|
+
if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
|
|
98632
98557
|
return false;
|
|
98633
|
-
|
|
98558
|
+
}
|
|
98559
|
+
switch (node.kind) {
|
|
98560
|
+
case 219 /* ArrowFunction */:
|
|
98561
|
+
case 218 /* FunctionExpression */:
|
|
98562
|
+
case 262 /* FunctionDeclaration */:
|
|
98563
|
+
case 176 /* Constructor */:
|
|
98564
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98565
|
+
return false;
|
|
98566
|
+
case 177 /* GetAccessor */:
|
|
98567
|
+
case 178 /* SetAccessor */:
|
|
98568
|
+
case 174 /* MethodDeclaration */:
|
|
98569
|
+
case 172 /* PropertyDeclaration */: {
|
|
98570
|
+
const named = node;
|
|
98571
|
+
if (isComputedPropertyName(named.name)) {
|
|
98572
|
+
return !!forEachChild(named.name, containsSuperCall);
|
|
98573
|
+
}
|
|
98574
|
+
return false;
|
|
98575
|
+
}
|
|
98576
|
+
}
|
|
98577
|
+
return !!forEachChild(node, containsSuperCall);
|
|
98634
98578
|
}
|
|
98635
98579
|
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
|
|
98636
98580
|
const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
|
|
@@ -98645,31 +98589,22 @@ function transformES2015(context) {
|
|
|
98645
98589
|
/*statementOffset*/
|
|
98646
98590
|
0
|
|
98647
98591
|
);
|
|
98648
|
-
|
|
98649
|
-
|
|
98650
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98592
|
+
if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
|
|
98593
|
+
hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
|
|
98651
98594
|
}
|
|
98652
|
-
|
|
98653
|
-
|
|
98654
|
-
statements,
|
|
98655
|
-
constructor.body.statements,
|
|
98656
|
-
standardPrologueEnd,
|
|
98657
|
-
superStatementIndices,
|
|
98658
|
-
/*superPathDepth*/
|
|
98659
|
-
0,
|
|
98660
|
-
constructor,
|
|
98661
|
-
isDerivedClass,
|
|
98662
|
-
hasSynthesizedSuper,
|
|
98663
|
-
/*isFirstStatement*/
|
|
98664
|
-
true
|
|
98665
|
-
// NOTE: this will be recalculated inside of transformConstructorBodyWorker
|
|
98666
|
-
);
|
|
98595
|
+
addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
|
|
98596
|
+
const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
|
|
98667
98597
|
addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
|
|
98668
98598
|
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
98669
98599
|
insertCaptureNewTargetIfNeeded(prologue, constructor);
|
|
98600
|
+
if (mayReplaceThis) {
|
|
98601
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
98602
|
+
} else {
|
|
98603
|
+
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98604
|
+
}
|
|
98670
98605
|
factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
98671
98606
|
if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
98672
|
-
statements.push(factory2.createReturnStatement(
|
|
98607
|
+
statements.push(factory2.createReturnStatement(createCapturedThis()));
|
|
98673
98608
|
}
|
|
98674
98609
|
const body = factory2.createBlock(
|
|
98675
98610
|
setTextRange(
|
|
@@ -98686,6 +98621,230 @@ function transformES2015(context) {
|
|
|
98686
98621
|
true
|
|
98687
98622
|
);
|
|
98688
98623
|
setTextRange(body, constructor.body);
|
|
98624
|
+
return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
|
|
98625
|
+
}
|
|
98626
|
+
function isCapturedThis(node) {
|
|
98627
|
+
return isGeneratedIdentifier(node) && idText(node) === "_this";
|
|
98628
|
+
}
|
|
98629
|
+
function isSyntheticSuper(node) {
|
|
98630
|
+
return isGeneratedIdentifier(node) && idText(node) === "_super";
|
|
98631
|
+
}
|
|
98632
|
+
function isThisCapturingVariableStatement(node) {
|
|
98633
|
+
return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
|
|
98634
|
+
}
|
|
98635
|
+
function isThisCapturingVariableDeclaration(node) {
|
|
98636
|
+
return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
|
|
98637
|
+
}
|
|
98638
|
+
function isThisCapturingAssignment(node) {
|
|
98639
|
+
return isAssignmentExpression(
|
|
98640
|
+
node,
|
|
98641
|
+
/*excludeCompoundAssignment*/
|
|
98642
|
+
true
|
|
98643
|
+
) && isCapturedThis(node.left);
|
|
98644
|
+
}
|
|
98645
|
+
function isTransformedSuperCall(node) {
|
|
98646
|
+
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 */;
|
|
98647
|
+
}
|
|
98648
|
+
function isTransformedSuperCallWithFallback(node) {
|
|
98649
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
|
|
98650
|
+
}
|
|
98651
|
+
function isImplicitSuperCall(node) {
|
|
98652
|
+
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";
|
|
98653
|
+
}
|
|
98654
|
+
function isImplicitSuperCallWithFallback(node) {
|
|
98655
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
|
|
98656
|
+
}
|
|
98657
|
+
function isThisCapturingTransformedSuperCallWithFallback(node) {
|
|
98658
|
+
return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
|
|
98659
|
+
}
|
|
98660
|
+
function isThisCapturingImplicitSuperCallWithFallback(node) {
|
|
98661
|
+
return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
|
|
98662
|
+
}
|
|
98663
|
+
function isTransformedSuperCallLike(node) {
|
|
98664
|
+
return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
|
|
98665
|
+
}
|
|
98666
|
+
function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
|
|
98667
|
+
for (let i = 0; i < body.statements.length - 1; i++) {
|
|
98668
|
+
const statement = body.statements[i];
|
|
98669
|
+
if (!isThisCapturingVariableStatement(statement)) {
|
|
98670
|
+
continue;
|
|
98671
|
+
}
|
|
98672
|
+
const varDecl = statement.declarationList.declarations[0];
|
|
98673
|
+
if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
|
|
98674
|
+
continue;
|
|
98675
|
+
}
|
|
98676
|
+
const thisCaptureStatementIndex = i;
|
|
98677
|
+
let superCallIndex = i + 1;
|
|
98678
|
+
while (superCallIndex < body.statements.length) {
|
|
98679
|
+
const statement2 = body.statements[superCallIndex];
|
|
98680
|
+
if (isExpressionStatement(statement2)) {
|
|
98681
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
|
|
98682
|
+
break;
|
|
98683
|
+
}
|
|
98684
|
+
}
|
|
98685
|
+
if (isUninitializedVariableStatement(statement2)) {
|
|
98686
|
+
superCallIndex++;
|
|
98687
|
+
continue;
|
|
98688
|
+
}
|
|
98689
|
+
return body;
|
|
98690
|
+
}
|
|
98691
|
+
const following = body.statements[superCallIndex];
|
|
98692
|
+
let expression = following.expression;
|
|
98693
|
+
if (isThisCapturingAssignment(expression)) {
|
|
98694
|
+
expression = expression.right;
|
|
98695
|
+
}
|
|
98696
|
+
const newVarDecl = factory2.updateVariableDeclaration(
|
|
98697
|
+
varDecl,
|
|
98698
|
+
varDecl.name,
|
|
98699
|
+
/*exclamationToken*/
|
|
98700
|
+
void 0,
|
|
98701
|
+
/*type*/
|
|
98702
|
+
void 0,
|
|
98703
|
+
expression
|
|
98704
|
+
);
|
|
98705
|
+
const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
|
|
98706
|
+
const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
|
|
98707
|
+
setOriginalNode(newVarStatement, following);
|
|
98708
|
+
setTextRange(newVarStatement, following);
|
|
98709
|
+
const newStatements = factory2.createNodeArray([
|
|
98710
|
+
...body.statements.slice(0, thisCaptureStatementIndex),
|
|
98711
|
+
// copy statements preceding to `var _this`
|
|
98712
|
+
...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
|
|
98713
|
+
// copy intervening temp variables
|
|
98714
|
+
newVarStatement,
|
|
98715
|
+
...body.statements.slice(superCallIndex + 1)
|
|
98716
|
+
// copy statements following `super.call(this, ...)`
|
|
98717
|
+
]);
|
|
98718
|
+
setTextRange(newStatements, body.statements);
|
|
98719
|
+
return factory2.updateBlock(body, newStatements);
|
|
98720
|
+
}
|
|
98721
|
+
return body;
|
|
98722
|
+
}
|
|
98723
|
+
function simplifyConstructorInlineSuperReturn(body, original) {
|
|
98724
|
+
for (const statement of original.statements) {
|
|
98725
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
98726
|
+
return body;
|
|
98727
|
+
}
|
|
98728
|
+
}
|
|
98729
|
+
const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
|
|
98730
|
+
for (let i = body.statements.length - 1; i > 0; i--) {
|
|
98731
|
+
const statement = body.statements[i];
|
|
98732
|
+
if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
|
|
98733
|
+
const preceding = body.statements[i - 1];
|
|
98734
|
+
let expression;
|
|
98735
|
+
if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
|
|
98736
|
+
expression = preceding.expression;
|
|
98737
|
+
} else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
|
|
98738
|
+
const varDecl = preceding.declarationList.declarations[0];
|
|
98739
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
|
|
98740
|
+
expression = factory2.createAssignment(
|
|
98741
|
+
createCapturedThis(),
|
|
98742
|
+
varDecl.initializer
|
|
98743
|
+
);
|
|
98744
|
+
}
|
|
98745
|
+
}
|
|
98746
|
+
if (!expression) {
|
|
98747
|
+
break;
|
|
98748
|
+
}
|
|
98749
|
+
const newReturnStatement = factory2.createReturnStatement(expression);
|
|
98750
|
+
setOriginalNode(newReturnStatement, preceding);
|
|
98751
|
+
setTextRange(newReturnStatement, preceding);
|
|
98752
|
+
const newStatements = factory2.createNodeArray([
|
|
98753
|
+
...body.statements.slice(0, i - 1),
|
|
98754
|
+
// copy all statements preceding `_super.call(this, ...)`
|
|
98755
|
+
newReturnStatement,
|
|
98756
|
+
...body.statements.slice(i + 1)
|
|
98757
|
+
// copy all statements following `return _this;`
|
|
98758
|
+
]);
|
|
98759
|
+
setTextRange(newStatements, body.statements);
|
|
98760
|
+
return factory2.updateBlock(body, newStatements);
|
|
98761
|
+
}
|
|
98762
|
+
}
|
|
98763
|
+
return body;
|
|
98764
|
+
}
|
|
98765
|
+
function elideUnusedThisCaptureWorker(node) {
|
|
98766
|
+
if (isThisCapturingVariableStatement(node)) {
|
|
98767
|
+
const varDecl = node.declarationList.declarations[0];
|
|
98768
|
+
if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
|
|
98769
|
+
return void 0;
|
|
98770
|
+
}
|
|
98771
|
+
} else if (isThisCapturingAssignment(node)) {
|
|
98772
|
+
return factory2.createPartiallyEmittedExpression(node.right, node);
|
|
98773
|
+
}
|
|
98774
|
+
switch (node.kind) {
|
|
98775
|
+
case 219 /* ArrowFunction */:
|
|
98776
|
+
case 218 /* FunctionExpression */:
|
|
98777
|
+
case 262 /* FunctionDeclaration */:
|
|
98778
|
+
case 176 /* Constructor */:
|
|
98779
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98780
|
+
return node;
|
|
98781
|
+
case 177 /* GetAccessor */:
|
|
98782
|
+
case 178 /* SetAccessor */:
|
|
98783
|
+
case 174 /* MethodDeclaration */:
|
|
98784
|
+
case 172 /* PropertyDeclaration */: {
|
|
98785
|
+
const named = node;
|
|
98786
|
+
if (isComputedPropertyName(named.name)) {
|
|
98787
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
|
|
98788
|
+
}
|
|
98789
|
+
return node;
|
|
98790
|
+
}
|
|
98791
|
+
}
|
|
98792
|
+
return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
|
|
98793
|
+
}
|
|
98794
|
+
function simplifyConstructorElideUnusedThisCapture(body, original) {
|
|
98795
|
+
if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
|
|
98796
|
+
return body;
|
|
98797
|
+
}
|
|
98798
|
+
for (const statement of original.statements) {
|
|
98799
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
98800
|
+
return body;
|
|
98801
|
+
}
|
|
98802
|
+
}
|
|
98803
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
|
|
98804
|
+
}
|
|
98805
|
+
function injectSuperPresenceCheckWorker(node) {
|
|
98806
|
+
if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
|
|
98807
|
+
return factory2.createLogicalAnd(
|
|
98808
|
+
factory2.createStrictInequality(
|
|
98809
|
+
createSyntheticSuper(),
|
|
98810
|
+
factory2.createNull()
|
|
98811
|
+
),
|
|
98812
|
+
node
|
|
98813
|
+
);
|
|
98814
|
+
}
|
|
98815
|
+
switch (node.kind) {
|
|
98816
|
+
case 219 /* ArrowFunction */:
|
|
98817
|
+
case 218 /* FunctionExpression */:
|
|
98818
|
+
case 262 /* FunctionDeclaration */:
|
|
98819
|
+
case 176 /* Constructor */:
|
|
98820
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98821
|
+
return node;
|
|
98822
|
+
case 177 /* GetAccessor */:
|
|
98823
|
+
case 178 /* SetAccessor */:
|
|
98824
|
+
case 174 /* MethodDeclaration */:
|
|
98825
|
+
case 172 /* PropertyDeclaration */: {
|
|
98826
|
+
const named = node;
|
|
98827
|
+
if (isComputedPropertyName(named.name)) {
|
|
98828
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
|
|
98829
|
+
}
|
|
98830
|
+
return node;
|
|
98831
|
+
}
|
|
98832
|
+
}
|
|
98833
|
+
return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
|
|
98834
|
+
}
|
|
98835
|
+
function complicateConstructorInjectSuperPresenceCheck(body) {
|
|
98836
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
|
|
98837
|
+
}
|
|
98838
|
+
function simplifyConstructor(body, original, hasSynthesizedSuper) {
|
|
98839
|
+
const inputBody = body;
|
|
98840
|
+
body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
|
|
98841
|
+
body = simplifyConstructorInlineSuperReturn(body, original);
|
|
98842
|
+
if (body !== inputBody) {
|
|
98843
|
+
body = simplifyConstructorElideUnusedThisCapture(body, original);
|
|
98844
|
+
}
|
|
98845
|
+
if (hasSynthesizedSuper) {
|
|
98846
|
+
body = complicateConstructorInjectSuperPresenceCheck(body);
|
|
98847
|
+
}
|
|
98689
98848
|
return body;
|
|
98690
98849
|
}
|
|
98691
98850
|
function isSufficientlyCoveredByReturnStatements(statement) {
|
|
@@ -98711,11 +98870,11 @@ function transformES2015(context) {
|
|
|
98711
98870
|
return factory2.createLogicalOr(
|
|
98712
98871
|
factory2.createLogicalAnd(
|
|
98713
98872
|
factory2.createStrictInequality(
|
|
98714
|
-
|
|
98873
|
+
createSyntheticSuper(),
|
|
98715
98874
|
factory2.createNull()
|
|
98716
98875
|
),
|
|
98717
98876
|
factory2.createFunctionApplyCall(
|
|
98718
|
-
|
|
98877
|
+
createSyntheticSuper(),
|
|
98719
98878
|
createActualThis(),
|
|
98720
98879
|
factory2.createIdentifier("arguments")
|
|
98721
98880
|
)
|
|
@@ -98970,24 +99129,12 @@ function transformES2015(context) {
|
|
|
98970
99129
|
return true;
|
|
98971
99130
|
}
|
|
98972
99131
|
function insertCaptureThisForNodeIfNeeded(statements, node) {
|
|
98973
|
-
if (hierarchyFacts &
|
|
99132
|
+
if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
|
|
98974
99133
|
insertCaptureThisForNode(statements, node, factory2.createThis());
|
|
98975
99134
|
return true;
|
|
98976
99135
|
}
|
|
98977
99136
|
return false;
|
|
98978
99137
|
}
|
|
98979
|
-
function addSuperThisCaptureThisForNode(statements, superExpression) {
|
|
98980
|
-
enableSubstitutionsForCapturedThis();
|
|
98981
|
-
const assignSuperExpression = factory2.createExpressionStatement(
|
|
98982
|
-
factory2.createBinaryExpression(
|
|
98983
|
-
factory2.createThis(),
|
|
98984
|
-
64 /* EqualsToken */,
|
|
98985
|
-
superExpression
|
|
98986
|
-
)
|
|
98987
|
-
);
|
|
98988
|
-
statements.push(assignSuperExpression);
|
|
98989
|
-
setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
|
|
98990
|
-
}
|
|
98991
99138
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
98992
99139
|
enableSubstitutionsForCapturedThis();
|
|
98993
99140
|
const captureThisStatement = factory2.createVariableStatement(
|
|
@@ -98995,7 +99142,7 @@ function transformES2015(context) {
|
|
|
98995
99142
|
void 0,
|
|
98996
99143
|
factory2.createVariableDeclarationList([
|
|
98997
99144
|
factory2.createVariableDeclaration(
|
|
98998
|
-
|
|
99145
|
+
createCapturedThis(),
|
|
98999
99146
|
/*exclamationToken*/
|
|
99000
99147
|
void 0,
|
|
99001
99148
|
/*type*/
|
|
@@ -99216,7 +99363,7 @@ function transformES2015(context) {
|
|
|
99216
99363
|
}
|
|
99217
99364
|
function visitArrowFunction(node) {
|
|
99218
99365
|
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
99219
|
-
hierarchyFacts |=
|
|
99366
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
99220
99367
|
}
|
|
99221
99368
|
const savedConvertedLoopState = convertedLoopState;
|
|
99222
99369
|
convertedLoopState = void 0;
|
|
@@ -99249,7 +99396,7 @@ function transformES2015(context) {
|
|
|
99249
99396
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
99250
99397
|
const body = transformFunctionBody(node);
|
|
99251
99398
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
99252
|
-
exitSubtree(ancestorFacts,
|
|
99399
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99253
99400
|
convertedLoopState = savedConvertedLoopState;
|
|
99254
99401
|
return factory2.updateFunctionExpression(
|
|
99255
99402
|
node,
|
|
@@ -99272,7 +99419,7 @@ function transformES2015(context) {
|
|
|
99272
99419
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
99273
99420
|
const body = transformFunctionBody(node);
|
|
99274
99421
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
99275
|
-
exitSubtree(ancestorFacts,
|
|
99422
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99276
99423
|
convertedLoopState = savedConvertedLoopState;
|
|
99277
99424
|
return factory2.updateFunctionDeclaration(
|
|
99278
99425
|
node,
|
|
@@ -99296,7 +99443,7 @@ function transformES2015(context) {
|
|
|
99296
99443
|
if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
|
|
99297
99444
|
name = factory2.getGeneratedNameForNode(node);
|
|
99298
99445
|
}
|
|
99299
|
-
exitSubtree(ancestorFacts,
|
|
99446
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99300
99447
|
convertedLoopState = savedConvertedLoopState;
|
|
99301
99448
|
return setOriginalNode(
|
|
99302
99449
|
setTextRange(
|
|
@@ -100705,7 +100852,7 @@ function transformES2015(context) {
|
|
|
100705
100852
|
} else {
|
|
100706
100853
|
updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
|
|
100707
100854
|
}
|
|
100708
|
-
exitSubtree(ancestorFacts,
|
|
100855
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
100709
100856
|
convertedLoopState = savedConvertedLoopState;
|
|
100710
100857
|
return updated;
|
|
100711
100858
|
}
|
|
@@ -100855,13 +101002,6 @@ function transformES2015(context) {
|
|
|
100855
101002
|
)
|
|
100856
101003
|
);
|
|
100857
101004
|
}
|
|
100858
|
-
function visitSuperCallInBody(node) {
|
|
100859
|
-
return visitCallExpressionWithPotentialCapturedThisAssignment(
|
|
100860
|
-
node,
|
|
100861
|
-
/*assignToCapturedThis*/
|
|
100862
|
-
false
|
|
100863
|
-
);
|
|
100864
|
-
}
|
|
100865
101005
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
100866
101006
|
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
|
|
100867
101007
|
const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
|
|
@@ -100898,10 +101038,13 @@ function transformES2015(context) {
|
|
|
100898
101038
|
resultingCall,
|
|
100899
101039
|
createActualThis()
|
|
100900
101040
|
);
|
|
100901
|
-
resultingCall = assignToCapturedThis ? factory2.createAssignment(
|
|
101041
|
+
resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
|
|
100902
101042
|
}
|
|
100903
101043
|
return setOriginalNode(resultingCall, node);
|
|
100904
101044
|
}
|
|
101045
|
+
if (isSuperCall(node)) {
|
|
101046
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
101047
|
+
}
|
|
100905
101048
|
return visitEachChild(node, visitor, context);
|
|
100906
101049
|
}
|
|
100907
101050
|
function visitNewExpression(node) {
|
|
@@ -101028,8 +101171,15 @@ function transformES2015(context) {
|
|
|
101028
101171
|
}
|
|
101029
101172
|
return setTextRange(expression, node);
|
|
101030
101173
|
}
|
|
101031
|
-
function
|
|
101032
|
-
return
|
|
101174
|
+
function createSyntheticSuper() {
|
|
101175
|
+
return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
101176
|
+
}
|
|
101177
|
+
function visitSuperKeyword(node, isExpressionOfCall) {
|
|
101178
|
+
const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
|
|
101179
|
+
setOriginalNode(expression, node);
|
|
101180
|
+
setCommentRange(expression, node);
|
|
101181
|
+
setSourceMapRange(expression, node);
|
|
101182
|
+
return expression;
|
|
101033
101183
|
}
|
|
101034
101184
|
function visitMetaProperty(node) {
|
|
101035
101185
|
if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
|
|
@@ -101135,7 +101285,7 @@ function transformES2015(context) {
|
|
|
101135
101285
|
}
|
|
101136
101286
|
function substituteThisKeyword(node) {
|
|
101137
101287
|
if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
|
|
101138
|
-
return setTextRange(
|
|
101288
|
+
return setTextRange(createCapturedThis(), node);
|
|
101139
101289
|
}
|
|
101140
101290
|
return node;
|
|
101141
101291
|
}
|
|
@@ -108233,7 +108383,7 @@ function transformDeclarations(context) {
|
|
|
108233
108383
|
return statement;
|
|
108234
108384
|
}
|
|
108235
108385
|
const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
|
|
108236
|
-
return factory2.
|
|
108386
|
+
return factory2.replaceModifiers(statement, modifiers);
|
|
108237
108387
|
}
|
|
108238
108388
|
function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
|
|
108239
108389
|
const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
|
|
@@ -108364,7 +108514,7 @@ function transformDeclarations(context) {
|
|
|
108364
108514
|
return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
|
|
108365
108515
|
});
|
|
108366
108516
|
if (!exportMappings.length) {
|
|
108367
|
-
declarations = mapDefined(declarations, (declaration) => factory2.
|
|
108517
|
+
declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
|
|
108368
108518
|
} else {
|
|
108369
108519
|
declarations.push(factory2.createExportDeclaration(
|
|
108370
108520
|
/*modifiers*/
|