typescript 5.3.0-dev.20231023 → 5.3.0-dev.20231024
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 +346 -176
- package/lib/tsserver.js +350 -180
- package/lib/typescript.d.ts +12 -0
- package/lib/typescript.js +350 -180
- 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-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.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);
|
|
@@ -62732,6 +62751,9 @@ function createTypeChecker(host) {
|
|
|
62732
62751
|
}
|
|
62733
62752
|
function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
|
|
62734
62753
|
if (depth >= maxDepth) {
|
|
62754
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
62755
|
+
type = getMappedTargetWithSymbol(type);
|
|
62756
|
+
}
|
|
62735
62757
|
if (type.flags & 2097152 /* Intersection */) {
|
|
62736
62758
|
return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
|
|
62737
62759
|
}
|
|
@@ -62740,7 +62762,7 @@ function createTypeChecker(host) {
|
|
|
62740
62762
|
let lastTypeId = 0;
|
|
62741
62763
|
for (let i = 0; i < depth; i++) {
|
|
62742
62764
|
const t = stack[i];
|
|
62743
|
-
if (
|
|
62765
|
+
if (hasMatchingRecursionIdentity(t, identity2)) {
|
|
62744
62766
|
if (t.id >= lastTypeId) {
|
|
62745
62767
|
count++;
|
|
62746
62768
|
if (count >= maxDepth) {
|
|
@@ -62753,18 +62775,29 @@ function createTypeChecker(host) {
|
|
|
62753
62775
|
}
|
|
62754
62776
|
return false;
|
|
62755
62777
|
}
|
|
62778
|
+
function getMappedTargetWithSymbol(type) {
|
|
62779
|
+
let target;
|
|
62780
|
+
while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) {
|
|
62781
|
+
type = target;
|
|
62782
|
+
}
|
|
62783
|
+
return type;
|
|
62784
|
+
}
|
|
62785
|
+
function hasMatchingRecursionIdentity(type, identity2) {
|
|
62786
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
62787
|
+
type = getMappedTargetWithSymbol(type);
|
|
62788
|
+
}
|
|
62789
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
62790
|
+
return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2));
|
|
62791
|
+
}
|
|
62792
|
+
return getRecursionIdentity(type) === identity2;
|
|
62793
|
+
}
|
|
62756
62794
|
function getRecursionIdentity(type) {
|
|
62757
62795
|
if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
|
|
62758
62796
|
if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
|
|
62759
62797
|
return type.node;
|
|
62760
62798
|
}
|
|
62761
|
-
if (type.symbol) {
|
|
62762
|
-
|
|
62763
|
-
type = getMappedTargetWithSymbol(type);
|
|
62764
|
-
}
|
|
62765
|
-
if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
62766
|
-
return type.symbol;
|
|
62767
|
-
}
|
|
62799
|
+
if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
62800
|
+
return type.symbol;
|
|
62768
62801
|
}
|
|
62769
62802
|
if (isTupleType(type)) {
|
|
62770
62803
|
return type.target;
|
|
@@ -62784,13 +62817,6 @@ function createTypeChecker(host) {
|
|
|
62784
62817
|
}
|
|
62785
62818
|
return type;
|
|
62786
62819
|
}
|
|
62787
|
-
function getMappedTargetWithSymbol(type) {
|
|
62788
|
-
let target = type;
|
|
62789
|
-
while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) {
|
|
62790
|
-
target = getModifiersTypeFromMappedType(target);
|
|
62791
|
-
}
|
|
62792
|
-
return target.symbol ? target : type;
|
|
62793
|
-
}
|
|
62794
62820
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
62795
62821
|
return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
62796
62822
|
}
|
|
@@ -97995,7 +98021,7 @@ function transformES2015(context) {
|
|
|
97995
98021
|
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
|
|
97996
98022
|
}
|
|
97997
98023
|
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
|
|
97998
|
-
return (hierarchyFacts & 8192 /*
|
|
98024
|
+
return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
|
|
97999
98025
|
}
|
|
98000
98026
|
function isOrMayContainReturnCompletion(node) {
|
|
98001
98027
|
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(
|
|
@@ -98005,7 +98031,7 @@ function transformES2015(context) {
|
|
|
98005
98031
|
) || isBlock(node));
|
|
98006
98032
|
}
|
|
98007
98033
|
function shouldVisitNode(node) {
|
|
98008
|
-
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /*
|
|
98034
|
+
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
|
|
98009
98035
|
node,
|
|
98010
98036
|
/*lookInLabeledStatements*/
|
|
98011
98037
|
false
|
|
@@ -98038,7 +98064,7 @@ function transformES2015(context) {
|
|
|
98038
98064
|
/*expressionResultIsUnused*/
|
|
98039
98065
|
false
|
|
98040
98066
|
);
|
|
98041
|
-
exitSubtree(ancestorFacts,
|
|
98067
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
98042
98068
|
return result;
|
|
98043
98069
|
}
|
|
98044
98070
|
return visitorWorker(
|
|
@@ -98052,6 +98078,7 @@ function transformES2015(context) {
|
|
|
98052
98078
|
function callExpressionVisitor(node) {
|
|
98053
98079
|
if (node.kind === 108 /* SuperKeyword */) {
|
|
98054
98080
|
return visitSuperKeyword(
|
|
98081
|
+
node,
|
|
98055
98082
|
/*isExpressionOfCall*/
|
|
98056
98083
|
true
|
|
98057
98084
|
);
|
|
@@ -98161,6 +98188,7 @@ function transformES2015(context) {
|
|
|
98161
98188
|
return visitSpreadElement(node);
|
|
98162
98189
|
case 108 /* SuperKeyword */:
|
|
98163
98190
|
return visitSuperKeyword(
|
|
98191
|
+
node,
|
|
98164
98192
|
/*isExpressionOfCall*/
|
|
98165
98193
|
false
|
|
98166
98194
|
);
|
|
@@ -98230,7 +98258,10 @@ function transformES2015(context) {
|
|
|
98230
98258
|
return updated;
|
|
98231
98259
|
}
|
|
98232
98260
|
function returnCapturedThis(node) {
|
|
98233
|
-
return setOriginalNode(factory2.createReturnStatement(
|
|
98261
|
+
return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
|
|
98262
|
+
}
|
|
98263
|
+
function createCapturedThis() {
|
|
98264
|
+
return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
98234
98265
|
}
|
|
98235
98266
|
function visitReturnStatement(node) {
|
|
98236
98267
|
if (convertedLoopState) {
|
|
@@ -98254,8 +98285,9 @@ function transformES2015(context) {
|
|
|
98254
98285
|
return visitEachChild(node, visitor, context);
|
|
98255
98286
|
}
|
|
98256
98287
|
function visitThisKeyword(node) {
|
|
98288
|
+
hierarchyFacts |= 65536 /* LexicalThis */;
|
|
98257
98289
|
if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
98258
|
-
hierarchyFacts |=
|
|
98290
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
98259
98291
|
}
|
|
98260
98292
|
if (convertedLoopState) {
|
|
98261
98293
|
if (hierarchyFacts & 2 /* ArrowFunction */) {
|
|
@@ -98394,7 +98426,7 @@ function transformES2015(context) {
|
|
|
98394
98426
|
void 0,
|
|
98395
98427
|
/*dotDotDotToken*/
|
|
98396
98428
|
void 0,
|
|
98397
|
-
|
|
98429
|
+
createSyntheticSuper()
|
|
98398
98430
|
)] : [],
|
|
98399
98431
|
/*type*/
|
|
98400
98432
|
void 0,
|
|
@@ -98484,7 +98516,7 @@ function transformES2015(context) {
|
|
|
98484
98516
|
setEmitFlags(constructorFunction, 16 /* CapturesThis */);
|
|
98485
98517
|
}
|
|
98486
98518
|
statements.push(constructorFunction);
|
|
98487
|
-
exitSubtree(ancestorFacts,
|
|
98519
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
98488
98520
|
convertedLoopState = savedConvertedLoopState;
|
|
98489
98521
|
}
|
|
98490
98522
|
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
|
|
@@ -98508,103 +98540,35 @@ function transformES2015(context) {
|
|
|
98508
98540
|
setEmitFlags(block, 3072 /* NoComments */);
|
|
98509
98541
|
return block;
|
|
98510
98542
|
}
|
|
98511
|
-
function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
|
|
98512
|
-
let mayReplaceThis = false;
|
|
98513
|
-
const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
|
|
98514
|
-
const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
|
|
98515
|
-
if (isFirstStatement && superStatementIndex >= 0) {
|
|
98516
|
-
let firstMaterialIndex = statementOffset;
|
|
98517
|
-
while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
|
|
98518
|
-
const statement = constructor.body.statements[firstMaterialIndex];
|
|
98519
|
-
if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
|
|
98520
|
-
break;
|
|
98521
|
-
firstMaterialIndex++;
|
|
98522
|
-
}
|
|
98523
|
-
isFirstStatement = superStatementIndex === firstMaterialIndex;
|
|
98524
|
-
}
|
|
98525
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
|
|
98526
|
-
const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
|
|
98527
|
-
if (superStatement && isTryStatement(superStatement)) {
|
|
98528
|
-
const tryBlockStatements = [];
|
|
98529
|
-
mayReplaceThis = transformConstructorBodyWorker(
|
|
98530
|
-
prologueOut,
|
|
98531
|
-
tryBlockStatements,
|
|
98532
|
-
superStatement.tryBlock.statements,
|
|
98533
|
-
/*statementOffset*/
|
|
98534
|
-
0,
|
|
98535
|
-
superPath,
|
|
98536
|
-
superPathDepth + 1,
|
|
98537
|
-
constructor,
|
|
98538
|
-
isDerivedClass,
|
|
98539
|
-
hasSynthesizedSuper,
|
|
98540
|
-
isFirstStatement
|
|
98541
|
-
);
|
|
98542
|
-
const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
|
|
98543
|
-
setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
|
|
98544
|
-
statementsOut.push(factory2.updateTryStatement(
|
|
98545
|
-
superStatement,
|
|
98546
|
-
factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
|
|
98547
|
-
visitNode(superStatement.catchClause, visitor, isCatchClause),
|
|
98548
|
-
visitNode(superStatement.finallyBlock, visitor, isBlock)
|
|
98549
|
-
));
|
|
98550
|
-
} else {
|
|
98551
|
-
const superCall = superStatement && getSuperCallFromStatement(superStatement);
|
|
98552
|
-
let superCallExpression;
|
|
98553
|
-
if (hasSynthesizedSuper) {
|
|
98554
|
-
superCallExpression = createDefaultSuperCallOrThis();
|
|
98555
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98556
|
-
} else if (superCall) {
|
|
98557
|
-
superCallExpression = visitSuperCallInBody(superCall);
|
|
98558
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98559
|
-
}
|
|
98560
|
-
if (isDerivedClass || superCallExpression) {
|
|
98561
|
-
if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
98562
|
-
const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
|
|
98563
|
-
const returnStatement = factory2.createReturnStatement(superCallExpression);
|
|
98564
|
-
setCommentRange(returnStatement, getCommentRange(superCall2));
|
|
98565
|
-
setEmitFlags(superCall2, 3072 /* NoComments */);
|
|
98566
|
-
statementsOut.push(returnStatement);
|
|
98567
|
-
return false;
|
|
98568
|
-
} else {
|
|
98569
|
-
if (isFirstStatement) {
|
|
98570
|
-
insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
|
|
98571
|
-
} else {
|
|
98572
|
-
insertCaptureThisForNode(prologueOut, constructor, createActualThis());
|
|
98573
|
-
if (superCallExpression) {
|
|
98574
|
-
addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
|
|
98575
|
-
}
|
|
98576
|
-
}
|
|
98577
|
-
mayReplaceThis = true;
|
|
98578
|
-
}
|
|
98579
|
-
} else {
|
|
98580
|
-
insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
|
|
98581
|
-
}
|
|
98582
|
-
}
|
|
98583
|
-
if (superStatementIndex >= 0) {
|
|
98584
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
|
|
98585
|
-
}
|
|
98586
|
-
return mayReplaceThis;
|
|
98587
|
-
}
|
|
98588
98543
|
function isUninitializedVariableStatement(node) {
|
|
98589
98544
|
return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
|
|
98590
98545
|
}
|
|
98591
|
-
function
|
|
98592
|
-
if (
|
|
98593
|
-
return
|
|
98594
|
-
|
|
98595
|
-
if (!
|
|
98596
|
-
return false;
|
|
98597
|
-
const initializer = varDecl.initializer;
|
|
98598
|
-
if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
|
|
98599
|
-
return false;
|
|
98600
|
-
const [stackProp, errorProp, hasErrorProp] = initializer.properties;
|
|
98601
|
-
if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
|
|
98602
|
-
return false;
|
|
98603
|
-
if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
|
|
98604
|
-
return false;
|
|
98605
|
-
if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
|
|
98546
|
+
function containsSuperCall(node) {
|
|
98547
|
+
if (isSuperCall(node)) {
|
|
98548
|
+
return true;
|
|
98549
|
+
}
|
|
98550
|
+
if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
|
|
98606
98551
|
return false;
|
|
98607
|
-
|
|
98552
|
+
}
|
|
98553
|
+
switch (node.kind) {
|
|
98554
|
+
case 219 /* ArrowFunction */:
|
|
98555
|
+
case 218 /* FunctionExpression */:
|
|
98556
|
+
case 262 /* FunctionDeclaration */:
|
|
98557
|
+
case 176 /* Constructor */:
|
|
98558
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98559
|
+
return false;
|
|
98560
|
+
case 177 /* GetAccessor */:
|
|
98561
|
+
case 178 /* SetAccessor */:
|
|
98562
|
+
case 174 /* MethodDeclaration */:
|
|
98563
|
+
case 172 /* PropertyDeclaration */: {
|
|
98564
|
+
const named = node;
|
|
98565
|
+
if (isComputedPropertyName(named.name)) {
|
|
98566
|
+
return !!forEachChild(named.name, containsSuperCall);
|
|
98567
|
+
}
|
|
98568
|
+
return false;
|
|
98569
|
+
}
|
|
98570
|
+
}
|
|
98571
|
+
return !!forEachChild(node, containsSuperCall);
|
|
98608
98572
|
}
|
|
98609
98573
|
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
|
|
98610
98574
|
const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
|
|
@@ -98619,31 +98583,22 @@ function transformES2015(context) {
|
|
|
98619
98583
|
/*statementOffset*/
|
|
98620
98584
|
0
|
|
98621
98585
|
);
|
|
98622
|
-
|
|
98623
|
-
|
|
98624
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
98586
|
+
if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
|
|
98587
|
+
hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
|
|
98625
98588
|
}
|
|
98626
|
-
|
|
98627
|
-
|
|
98628
|
-
statements,
|
|
98629
|
-
constructor.body.statements,
|
|
98630
|
-
standardPrologueEnd,
|
|
98631
|
-
superStatementIndices,
|
|
98632
|
-
/*superPathDepth*/
|
|
98633
|
-
0,
|
|
98634
|
-
constructor,
|
|
98635
|
-
isDerivedClass,
|
|
98636
|
-
hasSynthesizedSuper,
|
|
98637
|
-
/*isFirstStatement*/
|
|
98638
|
-
true
|
|
98639
|
-
// NOTE: this will be recalculated inside of transformConstructorBodyWorker
|
|
98640
|
-
);
|
|
98589
|
+
addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
|
|
98590
|
+
const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
|
|
98641
98591
|
addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
|
|
98642
98592
|
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
98643
98593
|
insertCaptureNewTargetIfNeeded(prologue, constructor);
|
|
98594
|
+
if (mayReplaceThis) {
|
|
98595
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
98596
|
+
} else {
|
|
98597
|
+
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98598
|
+
}
|
|
98644
98599
|
factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
98645
98600
|
if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
98646
|
-
statements.push(factory2.createReturnStatement(
|
|
98601
|
+
statements.push(factory2.createReturnStatement(createCapturedThis()));
|
|
98647
98602
|
}
|
|
98648
98603
|
const body = factory2.createBlock(
|
|
98649
98604
|
setTextRange(
|
|
@@ -98660,6 +98615,230 @@ function transformES2015(context) {
|
|
|
98660
98615
|
true
|
|
98661
98616
|
);
|
|
98662
98617
|
setTextRange(body, constructor.body);
|
|
98618
|
+
return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
|
|
98619
|
+
}
|
|
98620
|
+
function isCapturedThis(node) {
|
|
98621
|
+
return isGeneratedIdentifier(node) && idText(node) === "_this";
|
|
98622
|
+
}
|
|
98623
|
+
function isSyntheticSuper(node) {
|
|
98624
|
+
return isGeneratedIdentifier(node) && idText(node) === "_super";
|
|
98625
|
+
}
|
|
98626
|
+
function isThisCapturingVariableStatement(node) {
|
|
98627
|
+
return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
|
|
98628
|
+
}
|
|
98629
|
+
function isThisCapturingVariableDeclaration(node) {
|
|
98630
|
+
return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
|
|
98631
|
+
}
|
|
98632
|
+
function isThisCapturingAssignment(node) {
|
|
98633
|
+
return isAssignmentExpression(
|
|
98634
|
+
node,
|
|
98635
|
+
/*excludeCompoundAssignment*/
|
|
98636
|
+
true
|
|
98637
|
+
) && isCapturedThis(node.left);
|
|
98638
|
+
}
|
|
98639
|
+
function isTransformedSuperCall(node) {
|
|
98640
|
+
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 */;
|
|
98641
|
+
}
|
|
98642
|
+
function isTransformedSuperCallWithFallback(node) {
|
|
98643
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
|
|
98644
|
+
}
|
|
98645
|
+
function isImplicitSuperCall(node) {
|
|
98646
|
+
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";
|
|
98647
|
+
}
|
|
98648
|
+
function isImplicitSuperCallWithFallback(node) {
|
|
98649
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
|
|
98650
|
+
}
|
|
98651
|
+
function isThisCapturingTransformedSuperCallWithFallback(node) {
|
|
98652
|
+
return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
|
|
98653
|
+
}
|
|
98654
|
+
function isThisCapturingImplicitSuperCallWithFallback(node) {
|
|
98655
|
+
return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
|
|
98656
|
+
}
|
|
98657
|
+
function isTransformedSuperCallLike(node) {
|
|
98658
|
+
return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
|
|
98659
|
+
}
|
|
98660
|
+
function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
|
|
98661
|
+
for (let i = 0; i < body.statements.length - 1; i++) {
|
|
98662
|
+
const statement = body.statements[i];
|
|
98663
|
+
if (!isThisCapturingVariableStatement(statement)) {
|
|
98664
|
+
continue;
|
|
98665
|
+
}
|
|
98666
|
+
const varDecl = statement.declarationList.declarations[0];
|
|
98667
|
+
if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
|
|
98668
|
+
continue;
|
|
98669
|
+
}
|
|
98670
|
+
const thisCaptureStatementIndex = i;
|
|
98671
|
+
let superCallIndex = i + 1;
|
|
98672
|
+
while (superCallIndex < body.statements.length) {
|
|
98673
|
+
const statement2 = body.statements[superCallIndex];
|
|
98674
|
+
if (isExpressionStatement(statement2)) {
|
|
98675
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
|
|
98676
|
+
break;
|
|
98677
|
+
}
|
|
98678
|
+
}
|
|
98679
|
+
if (isUninitializedVariableStatement(statement2)) {
|
|
98680
|
+
superCallIndex++;
|
|
98681
|
+
continue;
|
|
98682
|
+
}
|
|
98683
|
+
return body;
|
|
98684
|
+
}
|
|
98685
|
+
const following = body.statements[superCallIndex];
|
|
98686
|
+
let expression = following.expression;
|
|
98687
|
+
if (isThisCapturingAssignment(expression)) {
|
|
98688
|
+
expression = expression.right;
|
|
98689
|
+
}
|
|
98690
|
+
const newVarDecl = factory2.updateVariableDeclaration(
|
|
98691
|
+
varDecl,
|
|
98692
|
+
varDecl.name,
|
|
98693
|
+
/*exclamationToken*/
|
|
98694
|
+
void 0,
|
|
98695
|
+
/*type*/
|
|
98696
|
+
void 0,
|
|
98697
|
+
expression
|
|
98698
|
+
);
|
|
98699
|
+
const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
|
|
98700
|
+
const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
|
|
98701
|
+
setOriginalNode(newVarStatement, following);
|
|
98702
|
+
setTextRange(newVarStatement, following);
|
|
98703
|
+
const newStatements = factory2.createNodeArray([
|
|
98704
|
+
...body.statements.slice(0, thisCaptureStatementIndex),
|
|
98705
|
+
// copy statements preceding to `var _this`
|
|
98706
|
+
...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
|
|
98707
|
+
// copy intervening temp variables
|
|
98708
|
+
newVarStatement,
|
|
98709
|
+
...body.statements.slice(superCallIndex + 1)
|
|
98710
|
+
// copy statements following `super.call(this, ...)`
|
|
98711
|
+
]);
|
|
98712
|
+
setTextRange(newStatements, body.statements);
|
|
98713
|
+
return factory2.updateBlock(body, newStatements);
|
|
98714
|
+
}
|
|
98715
|
+
return body;
|
|
98716
|
+
}
|
|
98717
|
+
function simplifyConstructorInlineSuperReturn(body, original) {
|
|
98718
|
+
for (const statement of original.statements) {
|
|
98719
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
98720
|
+
return body;
|
|
98721
|
+
}
|
|
98722
|
+
}
|
|
98723
|
+
const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
|
|
98724
|
+
for (let i = body.statements.length - 1; i > 0; i--) {
|
|
98725
|
+
const statement = body.statements[i];
|
|
98726
|
+
if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
|
|
98727
|
+
const preceding = body.statements[i - 1];
|
|
98728
|
+
let expression;
|
|
98729
|
+
if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
|
|
98730
|
+
expression = preceding.expression;
|
|
98731
|
+
} else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
|
|
98732
|
+
const varDecl = preceding.declarationList.declarations[0];
|
|
98733
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
|
|
98734
|
+
expression = factory2.createAssignment(
|
|
98735
|
+
createCapturedThis(),
|
|
98736
|
+
varDecl.initializer
|
|
98737
|
+
);
|
|
98738
|
+
}
|
|
98739
|
+
}
|
|
98740
|
+
if (!expression) {
|
|
98741
|
+
break;
|
|
98742
|
+
}
|
|
98743
|
+
const newReturnStatement = factory2.createReturnStatement(expression);
|
|
98744
|
+
setOriginalNode(newReturnStatement, preceding);
|
|
98745
|
+
setTextRange(newReturnStatement, preceding);
|
|
98746
|
+
const newStatements = factory2.createNodeArray([
|
|
98747
|
+
...body.statements.slice(0, i - 1),
|
|
98748
|
+
// copy all statements preceding `_super.call(this, ...)`
|
|
98749
|
+
newReturnStatement,
|
|
98750
|
+
...body.statements.slice(i + 1)
|
|
98751
|
+
// copy all statements following `return _this;`
|
|
98752
|
+
]);
|
|
98753
|
+
setTextRange(newStatements, body.statements);
|
|
98754
|
+
return factory2.updateBlock(body, newStatements);
|
|
98755
|
+
}
|
|
98756
|
+
}
|
|
98757
|
+
return body;
|
|
98758
|
+
}
|
|
98759
|
+
function elideUnusedThisCaptureWorker(node) {
|
|
98760
|
+
if (isThisCapturingVariableStatement(node)) {
|
|
98761
|
+
const varDecl = node.declarationList.declarations[0];
|
|
98762
|
+
if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
|
|
98763
|
+
return void 0;
|
|
98764
|
+
}
|
|
98765
|
+
} else if (isThisCapturingAssignment(node)) {
|
|
98766
|
+
return factory2.createPartiallyEmittedExpression(node.right, node);
|
|
98767
|
+
}
|
|
98768
|
+
switch (node.kind) {
|
|
98769
|
+
case 219 /* ArrowFunction */:
|
|
98770
|
+
case 218 /* FunctionExpression */:
|
|
98771
|
+
case 262 /* FunctionDeclaration */:
|
|
98772
|
+
case 176 /* Constructor */:
|
|
98773
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98774
|
+
return node;
|
|
98775
|
+
case 177 /* GetAccessor */:
|
|
98776
|
+
case 178 /* SetAccessor */:
|
|
98777
|
+
case 174 /* MethodDeclaration */:
|
|
98778
|
+
case 172 /* PropertyDeclaration */: {
|
|
98779
|
+
const named = node;
|
|
98780
|
+
if (isComputedPropertyName(named.name)) {
|
|
98781
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
|
|
98782
|
+
}
|
|
98783
|
+
return node;
|
|
98784
|
+
}
|
|
98785
|
+
}
|
|
98786
|
+
return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
|
|
98787
|
+
}
|
|
98788
|
+
function simplifyConstructorElideUnusedThisCapture(body, original) {
|
|
98789
|
+
if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
|
|
98790
|
+
return body;
|
|
98791
|
+
}
|
|
98792
|
+
for (const statement of original.statements) {
|
|
98793
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
98794
|
+
return body;
|
|
98795
|
+
}
|
|
98796
|
+
}
|
|
98797
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
|
|
98798
|
+
}
|
|
98799
|
+
function injectSuperPresenceCheckWorker(node) {
|
|
98800
|
+
if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
|
|
98801
|
+
return factory2.createLogicalAnd(
|
|
98802
|
+
factory2.createStrictInequality(
|
|
98803
|
+
createSyntheticSuper(),
|
|
98804
|
+
factory2.createNull()
|
|
98805
|
+
),
|
|
98806
|
+
node
|
|
98807
|
+
);
|
|
98808
|
+
}
|
|
98809
|
+
switch (node.kind) {
|
|
98810
|
+
case 219 /* ArrowFunction */:
|
|
98811
|
+
case 218 /* FunctionExpression */:
|
|
98812
|
+
case 262 /* FunctionDeclaration */:
|
|
98813
|
+
case 176 /* Constructor */:
|
|
98814
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
98815
|
+
return node;
|
|
98816
|
+
case 177 /* GetAccessor */:
|
|
98817
|
+
case 178 /* SetAccessor */:
|
|
98818
|
+
case 174 /* MethodDeclaration */:
|
|
98819
|
+
case 172 /* PropertyDeclaration */: {
|
|
98820
|
+
const named = node;
|
|
98821
|
+
if (isComputedPropertyName(named.name)) {
|
|
98822
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
|
|
98823
|
+
}
|
|
98824
|
+
return node;
|
|
98825
|
+
}
|
|
98826
|
+
}
|
|
98827
|
+
return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
|
|
98828
|
+
}
|
|
98829
|
+
function complicateConstructorInjectSuperPresenceCheck(body) {
|
|
98830
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
|
|
98831
|
+
}
|
|
98832
|
+
function simplifyConstructor(body, original, hasSynthesizedSuper) {
|
|
98833
|
+
const inputBody = body;
|
|
98834
|
+
body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
|
|
98835
|
+
body = simplifyConstructorInlineSuperReturn(body, original);
|
|
98836
|
+
if (body !== inputBody) {
|
|
98837
|
+
body = simplifyConstructorElideUnusedThisCapture(body, original);
|
|
98838
|
+
}
|
|
98839
|
+
if (hasSynthesizedSuper) {
|
|
98840
|
+
body = complicateConstructorInjectSuperPresenceCheck(body);
|
|
98841
|
+
}
|
|
98663
98842
|
return body;
|
|
98664
98843
|
}
|
|
98665
98844
|
function isSufficientlyCoveredByReturnStatements(statement) {
|
|
@@ -98685,11 +98864,11 @@ function transformES2015(context) {
|
|
|
98685
98864
|
return factory2.createLogicalOr(
|
|
98686
98865
|
factory2.createLogicalAnd(
|
|
98687
98866
|
factory2.createStrictInequality(
|
|
98688
|
-
|
|
98867
|
+
createSyntheticSuper(),
|
|
98689
98868
|
factory2.createNull()
|
|
98690
98869
|
),
|
|
98691
98870
|
factory2.createFunctionApplyCall(
|
|
98692
|
-
|
|
98871
|
+
createSyntheticSuper(),
|
|
98693
98872
|
createActualThis(),
|
|
98694
98873
|
factory2.createIdentifier("arguments")
|
|
98695
98874
|
)
|
|
@@ -98944,24 +99123,12 @@ function transformES2015(context) {
|
|
|
98944
99123
|
return true;
|
|
98945
99124
|
}
|
|
98946
99125
|
function insertCaptureThisForNodeIfNeeded(statements, node) {
|
|
98947
|
-
if (hierarchyFacts &
|
|
99126
|
+
if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
|
|
98948
99127
|
insertCaptureThisForNode(statements, node, factory2.createThis());
|
|
98949
99128
|
return true;
|
|
98950
99129
|
}
|
|
98951
99130
|
return false;
|
|
98952
99131
|
}
|
|
98953
|
-
function addSuperThisCaptureThisForNode(statements, superExpression) {
|
|
98954
|
-
enableSubstitutionsForCapturedThis();
|
|
98955
|
-
const assignSuperExpression = factory2.createExpressionStatement(
|
|
98956
|
-
factory2.createBinaryExpression(
|
|
98957
|
-
factory2.createThis(),
|
|
98958
|
-
64 /* EqualsToken */,
|
|
98959
|
-
superExpression
|
|
98960
|
-
)
|
|
98961
|
-
);
|
|
98962
|
-
statements.push(assignSuperExpression);
|
|
98963
|
-
setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
|
|
98964
|
-
}
|
|
98965
99132
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
98966
99133
|
enableSubstitutionsForCapturedThis();
|
|
98967
99134
|
const captureThisStatement = factory2.createVariableStatement(
|
|
@@ -98969,7 +99136,7 @@ function transformES2015(context) {
|
|
|
98969
99136
|
void 0,
|
|
98970
99137
|
factory2.createVariableDeclarationList([
|
|
98971
99138
|
factory2.createVariableDeclaration(
|
|
98972
|
-
|
|
99139
|
+
createCapturedThis(),
|
|
98973
99140
|
/*exclamationToken*/
|
|
98974
99141
|
void 0,
|
|
98975
99142
|
/*type*/
|
|
@@ -99190,7 +99357,7 @@ function transformES2015(context) {
|
|
|
99190
99357
|
}
|
|
99191
99358
|
function visitArrowFunction(node) {
|
|
99192
99359
|
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
99193
|
-
hierarchyFacts |=
|
|
99360
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
99194
99361
|
}
|
|
99195
99362
|
const savedConvertedLoopState = convertedLoopState;
|
|
99196
99363
|
convertedLoopState = void 0;
|
|
@@ -99223,7 +99390,7 @@ function transformES2015(context) {
|
|
|
99223
99390
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
99224
99391
|
const body = transformFunctionBody(node);
|
|
99225
99392
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
99226
|
-
exitSubtree(ancestorFacts,
|
|
99393
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99227
99394
|
convertedLoopState = savedConvertedLoopState;
|
|
99228
99395
|
return factory2.updateFunctionExpression(
|
|
99229
99396
|
node,
|
|
@@ -99246,7 +99413,7 @@ function transformES2015(context) {
|
|
|
99246
99413
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
99247
99414
|
const body = transformFunctionBody(node);
|
|
99248
99415
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
99249
|
-
exitSubtree(ancestorFacts,
|
|
99416
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99250
99417
|
convertedLoopState = savedConvertedLoopState;
|
|
99251
99418
|
return factory2.updateFunctionDeclaration(
|
|
99252
99419
|
node,
|
|
@@ -99270,7 +99437,7 @@ function transformES2015(context) {
|
|
|
99270
99437
|
if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
|
|
99271
99438
|
name = factory2.getGeneratedNameForNode(node);
|
|
99272
99439
|
}
|
|
99273
|
-
exitSubtree(ancestorFacts,
|
|
99440
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
99274
99441
|
convertedLoopState = savedConvertedLoopState;
|
|
99275
99442
|
return setOriginalNode(
|
|
99276
99443
|
setTextRange(
|
|
@@ -100679,7 +100846,7 @@ function transformES2015(context) {
|
|
|
100679
100846
|
} else {
|
|
100680
100847
|
updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
|
|
100681
100848
|
}
|
|
100682
|
-
exitSubtree(ancestorFacts,
|
|
100849
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
100683
100850
|
convertedLoopState = savedConvertedLoopState;
|
|
100684
100851
|
return updated;
|
|
100685
100852
|
}
|
|
@@ -100829,13 +100996,6 @@ function transformES2015(context) {
|
|
|
100829
100996
|
)
|
|
100830
100997
|
);
|
|
100831
100998
|
}
|
|
100832
|
-
function visitSuperCallInBody(node) {
|
|
100833
|
-
return visitCallExpressionWithPotentialCapturedThisAssignment(
|
|
100834
|
-
node,
|
|
100835
|
-
/*assignToCapturedThis*/
|
|
100836
|
-
false
|
|
100837
|
-
);
|
|
100838
|
-
}
|
|
100839
100999
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
100840
101000
|
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
|
|
100841
101001
|
const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
|
|
@@ -100872,10 +101032,13 @@ function transformES2015(context) {
|
|
|
100872
101032
|
resultingCall,
|
|
100873
101033
|
createActualThis()
|
|
100874
101034
|
);
|
|
100875
|
-
resultingCall = assignToCapturedThis ? factory2.createAssignment(
|
|
101035
|
+
resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
|
|
100876
101036
|
}
|
|
100877
101037
|
return setOriginalNode(resultingCall, node);
|
|
100878
101038
|
}
|
|
101039
|
+
if (isSuperCall(node)) {
|
|
101040
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
101041
|
+
}
|
|
100879
101042
|
return visitEachChild(node, visitor, context);
|
|
100880
101043
|
}
|
|
100881
101044
|
function visitNewExpression(node) {
|
|
@@ -101002,8 +101165,15 @@ function transformES2015(context) {
|
|
|
101002
101165
|
}
|
|
101003
101166
|
return setTextRange(expression, node);
|
|
101004
101167
|
}
|
|
101005
|
-
function
|
|
101006
|
-
return
|
|
101168
|
+
function createSyntheticSuper() {
|
|
101169
|
+
return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
101170
|
+
}
|
|
101171
|
+
function visitSuperKeyword(node, isExpressionOfCall) {
|
|
101172
|
+
const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
|
|
101173
|
+
setOriginalNode(expression, node);
|
|
101174
|
+
setCommentRange(expression, node);
|
|
101175
|
+
setSourceMapRange(expression, node);
|
|
101176
|
+
return expression;
|
|
101007
101177
|
}
|
|
101008
101178
|
function visitMetaProperty(node) {
|
|
101009
101179
|
if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
|
|
@@ -101109,7 +101279,7 @@ function transformES2015(context) {
|
|
|
101109
101279
|
}
|
|
101110
101280
|
function substituteThisKeyword(node) {
|
|
101111
101281
|
if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
|
|
101112
|
-
return setTextRange(
|
|
101282
|
+
return setTextRange(createCapturedThis(), node);
|
|
101113
101283
|
}
|
|
101114
101284
|
return node;
|
|
101115
101285
|
}
|
|
@@ -108207,7 +108377,7 @@ function transformDeclarations(context) {
|
|
|
108207
108377
|
return statement;
|
|
108208
108378
|
}
|
|
108209
108379
|
const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
|
|
108210
|
-
return factory2.
|
|
108380
|
+
return factory2.replaceModifiers(statement, modifiers);
|
|
108211
108381
|
}
|
|
108212
108382
|
function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
|
|
108213
108383
|
const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
|
|
@@ -108338,7 +108508,7 @@ function transformDeclarations(context) {
|
|
|
108338
108508
|
return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
|
|
108339
108509
|
});
|
|
108340
108510
|
if (!exportMappings.length) {
|
|
108341
|
-
declarations = mapDefined(declarations, (declaration) => factory2.
|
|
108511
|
+
declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
|
|
108342
108512
|
} else {
|
|
108343
108513
|
declarations.push(factory2.createExportDeclaration(
|
|
108344
108514
|
/*modifiers*/
|