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/tsserver.js
CHANGED
|
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2328
2328
|
|
|
2329
2329
|
// src/compiler/corePublic.ts
|
|
2330
2330
|
var versionMajorMinor = "5.3";
|
|
2331
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2331
|
+
var version = `${versionMajorMinor}.0-dev.20231024`;
|
|
2332
2332
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2333
2333
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2334
2334
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -22955,8 +22955,9 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22955
22955
|
ensureUseStrict,
|
|
22956
22956
|
liftToBlock,
|
|
22957
22957
|
mergeLexicalEnvironment,
|
|
22958
|
-
|
|
22959
|
-
|
|
22958
|
+
replaceModifiers,
|
|
22959
|
+
replaceDecoratorsAndModifiers,
|
|
22960
|
+
replacePropertyName
|
|
22960
22961
|
};
|
|
22961
22962
|
forEach(nodeFactoryPatchers, (fn) => fn(factory2));
|
|
22962
22963
|
return factory2;
|
|
@@ -26464,7 +26465,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
26464
26465
|
}
|
|
26465
26466
|
return statements;
|
|
26466
26467
|
}
|
|
26467
|
-
function
|
|
26468
|
+
function replaceModifiers(node, modifiers) {
|
|
26468
26469
|
let modifierArray;
|
|
26469
26470
|
if (typeof modifiers === "number") {
|
|
26470
26471
|
modifierArray = createModifiersFromModifierFlags(modifiers);
|
|
@@ -26473,9 +26474,27 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
26473
26474
|
}
|
|
26474
26475
|
return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node);
|
|
26475
26476
|
}
|
|
26476
|
-
function
|
|
26477
|
+
function replaceDecoratorsAndModifiers(node, modifierArray) {
|
|
26477
26478
|
return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node);
|
|
26478
26479
|
}
|
|
26480
|
+
function replacePropertyName(node, name) {
|
|
26481
|
+
switch (node.kind) {
|
|
26482
|
+
case 177 /* GetAccessor */:
|
|
26483
|
+
return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
|
|
26484
|
+
case 178 /* SetAccessor */:
|
|
26485
|
+
return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
|
|
26486
|
+
case 174 /* MethodDeclaration */:
|
|
26487
|
+
return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
26488
|
+
case 173 /* MethodSignature */:
|
|
26489
|
+
return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
|
|
26490
|
+
case 172 /* PropertyDeclaration */:
|
|
26491
|
+
return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
|
|
26492
|
+
case 171 /* PropertySignature */:
|
|
26493
|
+
return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
|
|
26494
|
+
case 303 /* PropertyAssignment */:
|
|
26495
|
+
return updatePropertyAssignment(node, name, node.initializer);
|
|
26496
|
+
}
|
|
26497
|
+
}
|
|
26479
26498
|
function asNodeArray(array) {
|
|
26480
26499
|
return array ? createNodeArray(array) : void 0;
|
|
26481
26500
|
}
|
|
@@ -54645,11 +54664,11 @@ function createTypeChecker(host) {
|
|
|
54645
54664
|
}
|
|
54646
54665
|
function addExportModifier(node) {
|
|
54647
54666
|
const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
|
|
54648
|
-
return factory.
|
|
54667
|
+
return factory.replaceModifiers(node, flags);
|
|
54649
54668
|
}
|
|
54650
54669
|
function removeExportModifier(node) {
|
|
54651
54670
|
const flags = getEffectiveModifierFlags(node) & ~1 /* Export */;
|
|
54652
|
-
return factory.
|
|
54671
|
+
return factory.replaceModifiers(node, flags);
|
|
54653
54672
|
}
|
|
54654
54673
|
function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) {
|
|
54655
54674
|
if (!suppressNewPrivateContext) {
|
|
@@ -54890,7 +54909,7 @@ function createTypeChecker(host) {
|
|
|
54890
54909
|
newModifierFlags |= 1024 /* Default */;
|
|
54891
54910
|
}
|
|
54892
54911
|
if (newModifierFlags) {
|
|
54893
|
-
node = factory.
|
|
54912
|
+
node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
|
|
54894
54913
|
}
|
|
54895
54914
|
}
|
|
54896
54915
|
results.push(node);
|
|
@@ -67444,6 +67463,9 @@ function createTypeChecker(host) {
|
|
|
67444
67463
|
}
|
|
67445
67464
|
function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
|
|
67446
67465
|
if (depth >= maxDepth) {
|
|
67466
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
67467
|
+
type = getMappedTargetWithSymbol(type);
|
|
67468
|
+
}
|
|
67447
67469
|
if (type.flags & 2097152 /* Intersection */) {
|
|
67448
67470
|
return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
|
|
67449
67471
|
}
|
|
@@ -67452,7 +67474,7 @@ function createTypeChecker(host) {
|
|
|
67452
67474
|
let lastTypeId = 0;
|
|
67453
67475
|
for (let i = 0; i < depth; i++) {
|
|
67454
67476
|
const t = stack[i];
|
|
67455
|
-
if (
|
|
67477
|
+
if (hasMatchingRecursionIdentity(t, identity2)) {
|
|
67456
67478
|
if (t.id >= lastTypeId) {
|
|
67457
67479
|
count++;
|
|
67458
67480
|
if (count >= maxDepth) {
|
|
@@ -67465,18 +67487,29 @@ function createTypeChecker(host) {
|
|
|
67465
67487
|
}
|
|
67466
67488
|
return false;
|
|
67467
67489
|
}
|
|
67490
|
+
function getMappedTargetWithSymbol(type) {
|
|
67491
|
+
let target;
|
|
67492
|
+
while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) {
|
|
67493
|
+
type = target;
|
|
67494
|
+
}
|
|
67495
|
+
return type;
|
|
67496
|
+
}
|
|
67497
|
+
function hasMatchingRecursionIdentity(type, identity2) {
|
|
67498
|
+
if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
|
|
67499
|
+
type = getMappedTargetWithSymbol(type);
|
|
67500
|
+
}
|
|
67501
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
67502
|
+
return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2));
|
|
67503
|
+
}
|
|
67504
|
+
return getRecursionIdentity(type) === identity2;
|
|
67505
|
+
}
|
|
67468
67506
|
function getRecursionIdentity(type) {
|
|
67469
67507
|
if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
|
|
67470
67508
|
if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
|
|
67471
67509
|
return type.node;
|
|
67472
67510
|
}
|
|
67473
|
-
if (type.symbol) {
|
|
67474
|
-
|
|
67475
|
-
type = getMappedTargetWithSymbol(type);
|
|
67476
|
-
}
|
|
67477
|
-
if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
67478
|
-
return type.symbol;
|
|
67479
|
-
}
|
|
67511
|
+
if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
|
|
67512
|
+
return type.symbol;
|
|
67480
67513
|
}
|
|
67481
67514
|
if (isTupleType(type)) {
|
|
67482
67515
|
return type.target;
|
|
@@ -67496,13 +67529,6 @@ function createTypeChecker(host) {
|
|
|
67496
67529
|
}
|
|
67497
67530
|
return type;
|
|
67498
67531
|
}
|
|
67499
|
-
function getMappedTargetWithSymbol(type) {
|
|
67500
|
-
let target = type;
|
|
67501
|
-
while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) {
|
|
67502
|
-
target = getModifiersTypeFromMappedType(target);
|
|
67503
|
-
}
|
|
67504
|
-
return target.symbol ? target : type;
|
|
67505
|
-
}
|
|
67506
67532
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
67507
67533
|
return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
67508
67534
|
}
|
|
@@ -102878,7 +102904,7 @@ function transformES2015(context) {
|
|
|
102878
102904
|
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
|
|
102879
102905
|
}
|
|
102880
102906
|
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
|
|
102881
|
-
return (hierarchyFacts & 8192 /*
|
|
102907
|
+
return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
|
|
102882
102908
|
}
|
|
102883
102909
|
function isOrMayContainReturnCompletion(node) {
|
|
102884
102910
|
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(
|
|
@@ -102888,7 +102914,7 @@ function transformES2015(context) {
|
|
|
102888
102914
|
) || isBlock(node));
|
|
102889
102915
|
}
|
|
102890
102916
|
function shouldVisitNode(node) {
|
|
102891
|
-
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /*
|
|
102917
|
+
return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
|
|
102892
102918
|
node,
|
|
102893
102919
|
/*lookInLabeledStatements*/
|
|
102894
102920
|
false
|
|
@@ -102921,7 +102947,7 @@ function transformES2015(context) {
|
|
|
102921
102947
|
/*expressionResultIsUnused*/
|
|
102922
102948
|
false
|
|
102923
102949
|
);
|
|
102924
|
-
exitSubtree(ancestorFacts,
|
|
102950
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
102925
102951
|
return result;
|
|
102926
102952
|
}
|
|
102927
102953
|
return visitorWorker(
|
|
@@ -102935,6 +102961,7 @@ function transformES2015(context) {
|
|
|
102935
102961
|
function callExpressionVisitor(node) {
|
|
102936
102962
|
if (node.kind === 108 /* SuperKeyword */) {
|
|
102937
102963
|
return visitSuperKeyword(
|
|
102964
|
+
node,
|
|
102938
102965
|
/*isExpressionOfCall*/
|
|
102939
102966
|
true
|
|
102940
102967
|
);
|
|
@@ -103044,6 +103071,7 @@ function transformES2015(context) {
|
|
|
103044
103071
|
return visitSpreadElement(node);
|
|
103045
103072
|
case 108 /* SuperKeyword */:
|
|
103046
103073
|
return visitSuperKeyword(
|
|
103074
|
+
node,
|
|
103047
103075
|
/*isExpressionOfCall*/
|
|
103048
103076
|
false
|
|
103049
103077
|
);
|
|
@@ -103113,7 +103141,10 @@ function transformES2015(context) {
|
|
|
103113
103141
|
return updated;
|
|
103114
103142
|
}
|
|
103115
103143
|
function returnCapturedThis(node) {
|
|
103116
|
-
return setOriginalNode(factory2.createReturnStatement(
|
|
103144
|
+
return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
|
|
103145
|
+
}
|
|
103146
|
+
function createCapturedThis() {
|
|
103147
|
+
return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
103117
103148
|
}
|
|
103118
103149
|
function visitReturnStatement(node) {
|
|
103119
103150
|
if (convertedLoopState) {
|
|
@@ -103137,8 +103168,9 @@ function transformES2015(context) {
|
|
|
103137
103168
|
return visitEachChild(node, visitor, context);
|
|
103138
103169
|
}
|
|
103139
103170
|
function visitThisKeyword(node) {
|
|
103171
|
+
hierarchyFacts |= 65536 /* LexicalThis */;
|
|
103140
103172
|
if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
103141
|
-
hierarchyFacts |=
|
|
103173
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
103142
103174
|
}
|
|
103143
103175
|
if (convertedLoopState) {
|
|
103144
103176
|
if (hierarchyFacts & 2 /* ArrowFunction */) {
|
|
@@ -103277,7 +103309,7 @@ function transformES2015(context) {
|
|
|
103277
103309
|
void 0,
|
|
103278
103310
|
/*dotDotDotToken*/
|
|
103279
103311
|
void 0,
|
|
103280
|
-
|
|
103312
|
+
createSyntheticSuper()
|
|
103281
103313
|
)] : [],
|
|
103282
103314
|
/*type*/
|
|
103283
103315
|
void 0,
|
|
@@ -103367,7 +103399,7 @@ function transformES2015(context) {
|
|
|
103367
103399
|
setEmitFlags(constructorFunction, 16 /* CapturesThis */);
|
|
103368
103400
|
}
|
|
103369
103401
|
statements.push(constructorFunction);
|
|
103370
|
-
exitSubtree(ancestorFacts,
|
|
103402
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
103371
103403
|
convertedLoopState = savedConvertedLoopState;
|
|
103372
103404
|
}
|
|
103373
103405
|
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
|
|
@@ -103391,103 +103423,35 @@ function transformES2015(context) {
|
|
|
103391
103423
|
setEmitFlags(block, 3072 /* NoComments */);
|
|
103392
103424
|
return block;
|
|
103393
103425
|
}
|
|
103394
|
-
function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
|
|
103395
|
-
let mayReplaceThis = false;
|
|
103396
|
-
const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
|
|
103397
|
-
const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
|
|
103398
|
-
if (isFirstStatement && superStatementIndex >= 0) {
|
|
103399
|
-
let firstMaterialIndex = statementOffset;
|
|
103400
|
-
while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
|
|
103401
|
-
const statement = constructor.body.statements[firstMaterialIndex];
|
|
103402
|
-
if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
|
|
103403
|
-
break;
|
|
103404
|
-
firstMaterialIndex++;
|
|
103405
|
-
}
|
|
103406
|
-
isFirstStatement = superStatementIndex === firstMaterialIndex;
|
|
103407
|
-
}
|
|
103408
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
|
|
103409
|
-
const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
|
|
103410
|
-
if (superStatement && isTryStatement(superStatement)) {
|
|
103411
|
-
const tryBlockStatements = [];
|
|
103412
|
-
mayReplaceThis = transformConstructorBodyWorker(
|
|
103413
|
-
prologueOut,
|
|
103414
|
-
tryBlockStatements,
|
|
103415
|
-
superStatement.tryBlock.statements,
|
|
103416
|
-
/*statementOffset*/
|
|
103417
|
-
0,
|
|
103418
|
-
superPath,
|
|
103419
|
-
superPathDepth + 1,
|
|
103420
|
-
constructor,
|
|
103421
|
-
isDerivedClass,
|
|
103422
|
-
hasSynthesizedSuper,
|
|
103423
|
-
isFirstStatement
|
|
103424
|
-
);
|
|
103425
|
-
const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
|
|
103426
|
-
setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
|
|
103427
|
-
statementsOut.push(factory2.updateTryStatement(
|
|
103428
|
-
superStatement,
|
|
103429
|
-
factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
|
|
103430
|
-
visitNode(superStatement.catchClause, visitor, isCatchClause),
|
|
103431
|
-
visitNode(superStatement.finallyBlock, visitor, isBlock)
|
|
103432
|
-
));
|
|
103433
|
-
} else {
|
|
103434
|
-
const superCall = superStatement && getSuperCallFromStatement(superStatement);
|
|
103435
|
-
let superCallExpression;
|
|
103436
|
-
if (hasSynthesizedSuper) {
|
|
103437
|
-
superCallExpression = createDefaultSuperCallOrThis();
|
|
103438
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
103439
|
-
} else if (superCall) {
|
|
103440
|
-
superCallExpression = visitSuperCallInBody(superCall);
|
|
103441
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
103442
|
-
}
|
|
103443
|
-
if (isDerivedClass || superCallExpression) {
|
|
103444
|
-
if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
103445
|
-
const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
|
|
103446
|
-
const returnStatement = factory2.createReturnStatement(superCallExpression);
|
|
103447
|
-
setCommentRange(returnStatement, getCommentRange(superCall2));
|
|
103448
|
-
setEmitFlags(superCall2, 3072 /* NoComments */);
|
|
103449
|
-
statementsOut.push(returnStatement);
|
|
103450
|
-
return false;
|
|
103451
|
-
} else {
|
|
103452
|
-
if (isFirstStatement) {
|
|
103453
|
-
insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
|
|
103454
|
-
} else {
|
|
103455
|
-
insertCaptureThisForNode(prologueOut, constructor, createActualThis());
|
|
103456
|
-
if (superCallExpression) {
|
|
103457
|
-
addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
|
|
103458
|
-
}
|
|
103459
|
-
}
|
|
103460
|
-
mayReplaceThis = true;
|
|
103461
|
-
}
|
|
103462
|
-
} else {
|
|
103463
|
-
insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
|
|
103464
|
-
}
|
|
103465
|
-
}
|
|
103466
|
-
if (superStatementIndex >= 0) {
|
|
103467
|
-
addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
|
|
103468
|
-
}
|
|
103469
|
-
return mayReplaceThis;
|
|
103470
|
-
}
|
|
103471
103426
|
function isUninitializedVariableStatement(node) {
|
|
103472
103427
|
return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
|
|
103473
103428
|
}
|
|
103474
|
-
function
|
|
103475
|
-
if (
|
|
103476
|
-
return
|
|
103477
|
-
|
|
103478
|
-
if (!
|
|
103479
|
-
return false;
|
|
103480
|
-
const initializer = varDecl.initializer;
|
|
103481
|
-
if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
|
|
103482
|
-
return false;
|
|
103483
|
-
const [stackProp, errorProp, hasErrorProp] = initializer.properties;
|
|
103484
|
-
if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
|
|
103485
|
-
return false;
|
|
103486
|
-
if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
|
|
103487
|
-
return false;
|
|
103488
|
-
if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
|
|
103429
|
+
function containsSuperCall(node) {
|
|
103430
|
+
if (isSuperCall(node)) {
|
|
103431
|
+
return true;
|
|
103432
|
+
}
|
|
103433
|
+
if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
|
|
103489
103434
|
return false;
|
|
103490
|
-
|
|
103435
|
+
}
|
|
103436
|
+
switch (node.kind) {
|
|
103437
|
+
case 219 /* ArrowFunction */:
|
|
103438
|
+
case 218 /* FunctionExpression */:
|
|
103439
|
+
case 262 /* FunctionDeclaration */:
|
|
103440
|
+
case 176 /* Constructor */:
|
|
103441
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
103442
|
+
return false;
|
|
103443
|
+
case 177 /* GetAccessor */:
|
|
103444
|
+
case 178 /* SetAccessor */:
|
|
103445
|
+
case 174 /* MethodDeclaration */:
|
|
103446
|
+
case 172 /* PropertyDeclaration */: {
|
|
103447
|
+
const named = node;
|
|
103448
|
+
if (isComputedPropertyName(named.name)) {
|
|
103449
|
+
return !!forEachChild(named.name, containsSuperCall);
|
|
103450
|
+
}
|
|
103451
|
+
return false;
|
|
103452
|
+
}
|
|
103453
|
+
}
|
|
103454
|
+
return !!forEachChild(node, containsSuperCall);
|
|
103491
103455
|
}
|
|
103492
103456
|
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
|
|
103493
103457
|
const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
|
|
@@ -103502,31 +103466,22 @@ function transformES2015(context) {
|
|
|
103502
103466
|
/*statementOffset*/
|
|
103503
103467
|
0
|
|
103504
103468
|
);
|
|
103505
|
-
|
|
103506
|
-
|
|
103507
|
-
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
103469
|
+
if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
|
|
103470
|
+
hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
|
|
103508
103471
|
}
|
|
103509
|
-
|
|
103510
|
-
|
|
103511
|
-
statements,
|
|
103512
|
-
constructor.body.statements,
|
|
103513
|
-
standardPrologueEnd,
|
|
103514
|
-
superStatementIndices,
|
|
103515
|
-
/*superPathDepth*/
|
|
103516
|
-
0,
|
|
103517
|
-
constructor,
|
|
103518
|
-
isDerivedClass,
|
|
103519
|
-
hasSynthesizedSuper,
|
|
103520
|
-
/*isFirstStatement*/
|
|
103521
|
-
true
|
|
103522
|
-
// NOTE: this will be recalculated inside of transformConstructorBodyWorker
|
|
103523
|
-
);
|
|
103472
|
+
addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
|
|
103473
|
+
const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
|
|
103524
103474
|
addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
|
|
103525
103475
|
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
103526
103476
|
insertCaptureNewTargetIfNeeded(prologue, constructor);
|
|
103477
|
+
if (mayReplaceThis) {
|
|
103478
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
103479
|
+
} else {
|
|
103480
|
+
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
103481
|
+
}
|
|
103527
103482
|
factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
103528
103483
|
if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
103529
|
-
statements.push(factory2.createReturnStatement(
|
|
103484
|
+
statements.push(factory2.createReturnStatement(createCapturedThis()));
|
|
103530
103485
|
}
|
|
103531
103486
|
const body = factory2.createBlock(
|
|
103532
103487
|
setTextRange(
|
|
@@ -103543,6 +103498,230 @@ function transformES2015(context) {
|
|
|
103543
103498
|
true
|
|
103544
103499
|
);
|
|
103545
103500
|
setTextRange(body, constructor.body);
|
|
103501
|
+
return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
|
|
103502
|
+
}
|
|
103503
|
+
function isCapturedThis(node) {
|
|
103504
|
+
return isGeneratedIdentifier(node) && idText(node) === "_this";
|
|
103505
|
+
}
|
|
103506
|
+
function isSyntheticSuper(node) {
|
|
103507
|
+
return isGeneratedIdentifier(node) && idText(node) === "_super";
|
|
103508
|
+
}
|
|
103509
|
+
function isThisCapturingVariableStatement(node) {
|
|
103510
|
+
return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
|
|
103511
|
+
}
|
|
103512
|
+
function isThisCapturingVariableDeclaration(node) {
|
|
103513
|
+
return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
|
|
103514
|
+
}
|
|
103515
|
+
function isThisCapturingAssignment(node) {
|
|
103516
|
+
return isAssignmentExpression(
|
|
103517
|
+
node,
|
|
103518
|
+
/*excludeCompoundAssignment*/
|
|
103519
|
+
true
|
|
103520
|
+
) && isCapturedThis(node.left);
|
|
103521
|
+
}
|
|
103522
|
+
function isTransformedSuperCall(node) {
|
|
103523
|
+
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 */;
|
|
103524
|
+
}
|
|
103525
|
+
function isTransformedSuperCallWithFallback(node) {
|
|
103526
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
|
|
103527
|
+
}
|
|
103528
|
+
function isImplicitSuperCall(node) {
|
|
103529
|
+
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";
|
|
103530
|
+
}
|
|
103531
|
+
function isImplicitSuperCallWithFallback(node) {
|
|
103532
|
+
return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
|
|
103533
|
+
}
|
|
103534
|
+
function isThisCapturingTransformedSuperCallWithFallback(node) {
|
|
103535
|
+
return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
|
|
103536
|
+
}
|
|
103537
|
+
function isThisCapturingImplicitSuperCallWithFallback(node) {
|
|
103538
|
+
return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
|
|
103539
|
+
}
|
|
103540
|
+
function isTransformedSuperCallLike(node) {
|
|
103541
|
+
return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
|
|
103542
|
+
}
|
|
103543
|
+
function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
|
|
103544
|
+
for (let i = 0; i < body.statements.length - 1; i++) {
|
|
103545
|
+
const statement = body.statements[i];
|
|
103546
|
+
if (!isThisCapturingVariableStatement(statement)) {
|
|
103547
|
+
continue;
|
|
103548
|
+
}
|
|
103549
|
+
const varDecl = statement.declarationList.declarations[0];
|
|
103550
|
+
if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
|
|
103551
|
+
continue;
|
|
103552
|
+
}
|
|
103553
|
+
const thisCaptureStatementIndex = i;
|
|
103554
|
+
let superCallIndex = i + 1;
|
|
103555
|
+
while (superCallIndex < body.statements.length) {
|
|
103556
|
+
const statement2 = body.statements[superCallIndex];
|
|
103557
|
+
if (isExpressionStatement(statement2)) {
|
|
103558
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
|
|
103559
|
+
break;
|
|
103560
|
+
}
|
|
103561
|
+
}
|
|
103562
|
+
if (isUninitializedVariableStatement(statement2)) {
|
|
103563
|
+
superCallIndex++;
|
|
103564
|
+
continue;
|
|
103565
|
+
}
|
|
103566
|
+
return body;
|
|
103567
|
+
}
|
|
103568
|
+
const following = body.statements[superCallIndex];
|
|
103569
|
+
let expression = following.expression;
|
|
103570
|
+
if (isThisCapturingAssignment(expression)) {
|
|
103571
|
+
expression = expression.right;
|
|
103572
|
+
}
|
|
103573
|
+
const newVarDecl = factory2.updateVariableDeclaration(
|
|
103574
|
+
varDecl,
|
|
103575
|
+
varDecl.name,
|
|
103576
|
+
/*exclamationToken*/
|
|
103577
|
+
void 0,
|
|
103578
|
+
/*type*/
|
|
103579
|
+
void 0,
|
|
103580
|
+
expression
|
|
103581
|
+
);
|
|
103582
|
+
const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
|
|
103583
|
+
const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
|
|
103584
|
+
setOriginalNode(newVarStatement, following);
|
|
103585
|
+
setTextRange(newVarStatement, following);
|
|
103586
|
+
const newStatements = factory2.createNodeArray([
|
|
103587
|
+
...body.statements.slice(0, thisCaptureStatementIndex),
|
|
103588
|
+
// copy statements preceding to `var _this`
|
|
103589
|
+
...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
|
|
103590
|
+
// copy intervening temp variables
|
|
103591
|
+
newVarStatement,
|
|
103592
|
+
...body.statements.slice(superCallIndex + 1)
|
|
103593
|
+
// copy statements following `super.call(this, ...)`
|
|
103594
|
+
]);
|
|
103595
|
+
setTextRange(newStatements, body.statements);
|
|
103596
|
+
return factory2.updateBlock(body, newStatements);
|
|
103597
|
+
}
|
|
103598
|
+
return body;
|
|
103599
|
+
}
|
|
103600
|
+
function simplifyConstructorInlineSuperReturn(body, original) {
|
|
103601
|
+
for (const statement of original.statements) {
|
|
103602
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
103603
|
+
return body;
|
|
103604
|
+
}
|
|
103605
|
+
}
|
|
103606
|
+
const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
|
|
103607
|
+
for (let i = body.statements.length - 1; i > 0; i--) {
|
|
103608
|
+
const statement = body.statements[i];
|
|
103609
|
+
if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
|
|
103610
|
+
const preceding = body.statements[i - 1];
|
|
103611
|
+
let expression;
|
|
103612
|
+
if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
|
|
103613
|
+
expression = preceding.expression;
|
|
103614
|
+
} else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
|
|
103615
|
+
const varDecl = preceding.declarationList.declarations[0];
|
|
103616
|
+
if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
|
|
103617
|
+
expression = factory2.createAssignment(
|
|
103618
|
+
createCapturedThis(),
|
|
103619
|
+
varDecl.initializer
|
|
103620
|
+
);
|
|
103621
|
+
}
|
|
103622
|
+
}
|
|
103623
|
+
if (!expression) {
|
|
103624
|
+
break;
|
|
103625
|
+
}
|
|
103626
|
+
const newReturnStatement = factory2.createReturnStatement(expression);
|
|
103627
|
+
setOriginalNode(newReturnStatement, preceding);
|
|
103628
|
+
setTextRange(newReturnStatement, preceding);
|
|
103629
|
+
const newStatements = factory2.createNodeArray([
|
|
103630
|
+
...body.statements.slice(0, i - 1),
|
|
103631
|
+
// copy all statements preceding `_super.call(this, ...)`
|
|
103632
|
+
newReturnStatement,
|
|
103633
|
+
...body.statements.slice(i + 1)
|
|
103634
|
+
// copy all statements following `return _this;`
|
|
103635
|
+
]);
|
|
103636
|
+
setTextRange(newStatements, body.statements);
|
|
103637
|
+
return factory2.updateBlock(body, newStatements);
|
|
103638
|
+
}
|
|
103639
|
+
}
|
|
103640
|
+
return body;
|
|
103641
|
+
}
|
|
103642
|
+
function elideUnusedThisCaptureWorker(node) {
|
|
103643
|
+
if (isThisCapturingVariableStatement(node)) {
|
|
103644
|
+
const varDecl = node.declarationList.declarations[0];
|
|
103645
|
+
if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
|
|
103646
|
+
return void 0;
|
|
103647
|
+
}
|
|
103648
|
+
} else if (isThisCapturingAssignment(node)) {
|
|
103649
|
+
return factory2.createPartiallyEmittedExpression(node.right, node);
|
|
103650
|
+
}
|
|
103651
|
+
switch (node.kind) {
|
|
103652
|
+
case 219 /* ArrowFunction */:
|
|
103653
|
+
case 218 /* FunctionExpression */:
|
|
103654
|
+
case 262 /* FunctionDeclaration */:
|
|
103655
|
+
case 176 /* Constructor */:
|
|
103656
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
103657
|
+
return node;
|
|
103658
|
+
case 177 /* GetAccessor */:
|
|
103659
|
+
case 178 /* SetAccessor */:
|
|
103660
|
+
case 174 /* MethodDeclaration */:
|
|
103661
|
+
case 172 /* PropertyDeclaration */: {
|
|
103662
|
+
const named = node;
|
|
103663
|
+
if (isComputedPropertyName(named.name)) {
|
|
103664
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
|
|
103665
|
+
}
|
|
103666
|
+
return node;
|
|
103667
|
+
}
|
|
103668
|
+
}
|
|
103669
|
+
return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
|
|
103670
|
+
}
|
|
103671
|
+
function simplifyConstructorElideUnusedThisCapture(body, original) {
|
|
103672
|
+
if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
|
|
103673
|
+
return body;
|
|
103674
|
+
}
|
|
103675
|
+
for (const statement of original.statements) {
|
|
103676
|
+
if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
|
|
103677
|
+
return body;
|
|
103678
|
+
}
|
|
103679
|
+
}
|
|
103680
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
|
|
103681
|
+
}
|
|
103682
|
+
function injectSuperPresenceCheckWorker(node) {
|
|
103683
|
+
if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
|
|
103684
|
+
return factory2.createLogicalAnd(
|
|
103685
|
+
factory2.createStrictInequality(
|
|
103686
|
+
createSyntheticSuper(),
|
|
103687
|
+
factory2.createNull()
|
|
103688
|
+
),
|
|
103689
|
+
node
|
|
103690
|
+
);
|
|
103691
|
+
}
|
|
103692
|
+
switch (node.kind) {
|
|
103693
|
+
case 219 /* ArrowFunction */:
|
|
103694
|
+
case 218 /* FunctionExpression */:
|
|
103695
|
+
case 262 /* FunctionDeclaration */:
|
|
103696
|
+
case 176 /* Constructor */:
|
|
103697
|
+
case 175 /* ClassStaticBlockDeclaration */:
|
|
103698
|
+
return node;
|
|
103699
|
+
case 177 /* GetAccessor */:
|
|
103700
|
+
case 178 /* SetAccessor */:
|
|
103701
|
+
case 174 /* MethodDeclaration */:
|
|
103702
|
+
case 172 /* PropertyDeclaration */: {
|
|
103703
|
+
const named = node;
|
|
103704
|
+
if (isComputedPropertyName(named.name)) {
|
|
103705
|
+
return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
|
|
103706
|
+
}
|
|
103707
|
+
return node;
|
|
103708
|
+
}
|
|
103709
|
+
}
|
|
103710
|
+
return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
|
|
103711
|
+
}
|
|
103712
|
+
function complicateConstructorInjectSuperPresenceCheck(body) {
|
|
103713
|
+
return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
|
|
103714
|
+
}
|
|
103715
|
+
function simplifyConstructor(body, original, hasSynthesizedSuper) {
|
|
103716
|
+
const inputBody = body;
|
|
103717
|
+
body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
|
|
103718
|
+
body = simplifyConstructorInlineSuperReturn(body, original);
|
|
103719
|
+
if (body !== inputBody) {
|
|
103720
|
+
body = simplifyConstructorElideUnusedThisCapture(body, original);
|
|
103721
|
+
}
|
|
103722
|
+
if (hasSynthesizedSuper) {
|
|
103723
|
+
body = complicateConstructorInjectSuperPresenceCheck(body);
|
|
103724
|
+
}
|
|
103546
103725
|
return body;
|
|
103547
103726
|
}
|
|
103548
103727
|
function isSufficientlyCoveredByReturnStatements(statement) {
|
|
@@ -103568,11 +103747,11 @@ function transformES2015(context) {
|
|
|
103568
103747
|
return factory2.createLogicalOr(
|
|
103569
103748
|
factory2.createLogicalAnd(
|
|
103570
103749
|
factory2.createStrictInequality(
|
|
103571
|
-
|
|
103750
|
+
createSyntheticSuper(),
|
|
103572
103751
|
factory2.createNull()
|
|
103573
103752
|
),
|
|
103574
103753
|
factory2.createFunctionApplyCall(
|
|
103575
|
-
|
|
103754
|
+
createSyntheticSuper(),
|
|
103576
103755
|
createActualThis(),
|
|
103577
103756
|
factory2.createIdentifier("arguments")
|
|
103578
103757
|
)
|
|
@@ -103827,24 +104006,12 @@ function transformES2015(context) {
|
|
|
103827
104006
|
return true;
|
|
103828
104007
|
}
|
|
103829
104008
|
function insertCaptureThisForNodeIfNeeded(statements, node) {
|
|
103830
|
-
if (hierarchyFacts &
|
|
104009
|
+
if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
|
|
103831
104010
|
insertCaptureThisForNode(statements, node, factory2.createThis());
|
|
103832
104011
|
return true;
|
|
103833
104012
|
}
|
|
103834
104013
|
return false;
|
|
103835
104014
|
}
|
|
103836
|
-
function addSuperThisCaptureThisForNode(statements, superExpression) {
|
|
103837
|
-
enableSubstitutionsForCapturedThis();
|
|
103838
|
-
const assignSuperExpression = factory2.createExpressionStatement(
|
|
103839
|
-
factory2.createBinaryExpression(
|
|
103840
|
-
factory2.createThis(),
|
|
103841
|
-
64 /* EqualsToken */,
|
|
103842
|
-
superExpression
|
|
103843
|
-
)
|
|
103844
|
-
);
|
|
103845
|
-
statements.push(assignSuperExpression);
|
|
103846
|
-
setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
|
|
103847
|
-
}
|
|
103848
104015
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
103849
104016
|
enableSubstitutionsForCapturedThis();
|
|
103850
104017
|
const captureThisStatement = factory2.createVariableStatement(
|
|
@@ -103852,7 +104019,7 @@ function transformES2015(context) {
|
|
|
103852
104019
|
void 0,
|
|
103853
104020
|
factory2.createVariableDeclarationList([
|
|
103854
104021
|
factory2.createVariableDeclaration(
|
|
103855
|
-
|
|
104022
|
+
createCapturedThis(),
|
|
103856
104023
|
/*exclamationToken*/
|
|
103857
104024
|
void 0,
|
|
103858
104025
|
/*type*/
|
|
@@ -104073,7 +104240,7 @@ function transformES2015(context) {
|
|
|
104073
104240
|
}
|
|
104074
104241
|
function visitArrowFunction(node) {
|
|
104075
104242
|
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
104076
|
-
hierarchyFacts |=
|
|
104243
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
104077
104244
|
}
|
|
104078
104245
|
const savedConvertedLoopState = convertedLoopState;
|
|
104079
104246
|
convertedLoopState = void 0;
|
|
@@ -104106,7 +104273,7 @@ function transformES2015(context) {
|
|
|
104106
104273
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
104107
104274
|
const body = transformFunctionBody2(node);
|
|
104108
104275
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
104109
|
-
exitSubtree(ancestorFacts,
|
|
104276
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
104110
104277
|
convertedLoopState = savedConvertedLoopState;
|
|
104111
104278
|
return factory2.updateFunctionExpression(
|
|
104112
104279
|
node,
|
|
@@ -104129,7 +104296,7 @@ function transformES2015(context) {
|
|
|
104129
104296
|
const parameters = visitParameterList(node.parameters, visitor, context);
|
|
104130
104297
|
const body = transformFunctionBody2(node);
|
|
104131
104298
|
const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
|
|
104132
|
-
exitSubtree(ancestorFacts,
|
|
104299
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
104133
104300
|
convertedLoopState = savedConvertedLoopState;
|
|
104134
104301
|
return factory2.updateFunctionDeclaration(
|
|
104135
104302
|
node,
|
|
@@ -104153,7 +104320,7 @@ function transformES2015(context) {
|
|
|
104153
104320
|
if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
|
|
104154
104321
|
name = factory2.getGeneratedNameForNode(node);
|
|
104155
104322
|
}
|
|
104156
|
-
exitSubtree(ancestorFacts,
|
|
104323
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
104157
104324
|
convertedLoopState = savedConvertedLoopState;
|
|
104158
104325
|
return setOriginalNode(
|
|
104159
104326
|
setTextRange(
|
|
@@ -105562,7 +105729,7 @@ function transformES2015(context) {
|
|
|
105562
105729
|
} else {
|
|
105563
105730
|
updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
|
|
105564
105731
|
}
|
|
105565
|
-
exitSubtree(ancestorFacts,
|
|
105732
|
+
exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
|
|
105566
105733
|
convertedLoopState = savedConvertedLoopState;
|
|
105567
105734
|
return updated;
|
|
105568
105735
|
}
|
|
@@ -105712,13 +105879,6 @@ function transformES2015(context) {
|
|
|
105712
105879
|
)
|
|
105713
105880
|
);
|
|
105714
105881
|
}
|
|
105715
|
-
function visitSuperCallInBody(node) {
|
|
105716
|
-
return visitCallExpressionWithPotentialCapturedThisAssignment(
|
|
105717
|
-
node,
|
|
105718
|
-
/*assignToCapturedThis*/
|
|
105719
|
-
false
|
|
105720
|
-
);
|
|
105721
|
-
}
|
|
105722
105882
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
105723
105883
|
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
|
|
105724
105884
|
const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
|
|
@@ -105755,10 +105915,13 @@ function transformES2015(context) {
|
|
|
105755
105915
|
resultingCall,
|
|
105756
105916
|
createActualThis()
|
|
105757
105917
|
);
|
|
105758
|
-
resultingCall = assignToCapturedThis ? factory2.createAssignment(
|
|
105918
|
+
resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
|
|
105759
105919
|
}
|
|
105760
105920
|
return setOriginalNode(resultingCall, node);
|
|
105761
105921
|
}
|
|
105922
|
+
if (isSuperCall(node)) {
|
|
105923
|
+
hierarchyFacts |= 131072 /* CapturedLexicalThis */;
|
|
105924
|
+
}
|
|
105762
105925
|
return visitEachChild(node, visitor, context);
|
|
105763
105926
|
}
|
|
105764
105927
|
function visitNewExpression(node) {
|
|
@@ -105885,8 +106048,15 @@ function transformES2015(context) {
|
|
|
105885
106048
|
}
|
|
105886
106049
|
return setTextRange(expression, node);
|
|
105887
106050
|
}
|
|
105888
|
-
function
|
|
105889
|
-
return
|
|
106051
|
+
function createSyntheticSuper() {
|
|
106052
|
+
return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
106053
|
+
}
|
|
106054
|
+
function visitSuperKeyword(node, isExpressionOfCall) {
|
|
106055
|
+
const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
|
|
106056
|
+
setOriginalNode(expression, node);
|
|
106057
|
+
setCommentRange(expression, node);
|
|
106058
|
+
setSourceMapRange(expression, node);
|
|
106059
|
+
return expression;
|
|
105890
106060
|
}
|
|
105891
106061
|
function visitMetaProperty(node) {
|
|
105892
106062
|
if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
|
|
@@ -105992,7 +106162,7 @@ function transformES2015(context) {
|
|
|
105992
106162
|
}
|
|
105993
106163
|
function substituteThisKeyword(node) {
|
|
105994
106164
|
if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
|
|
105995
|
-
return setTextRange(
|
|
106165
|
+
return setTextRange(createCapturedThis(), node);
|
|
105996
106166
|
}
|
|
105997
106167
|
return node;
|
|
105998
106168
|
}
|
|
@@ -113090,7 +113260,7 @@ function transformDeclarations(context) {
|
|
|
113090
113260
|
return statement;
|
|
113091
113261
|
}
|
|
113092
113262
|
const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
|
|
113093
|
-
return factory2.
|
|
113263
|
+
return factory2.replaceModifiers(statement, modifiers);
|
|
113094
113264
|
}
|
|
113095
113265
|
function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
|
|
113096
113266
|
const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
|
|
@@ -113221,7 +113391,7 @@ function transformDeclarations(context) {
|
|
|
113221
113391
|
return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
|
|
113222
113392
|
});
|
|
113223
113393
|
if (!exportMappings.length) {
|
|
113224
|
-
declarations = mapDefined(declarations, (declaration) => factory2.
|
|
113394
|
+
declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
|
|
113225
113395
|
} else {
|
|
113226
113396
|
declarations.push(factory2.createExportDeclaration(
|
|
113227
113397
|
/*modifiers*/
|
|
@@ -146896,7 +147066,7 @@ function makeChange2(changeTracker, sourceFile, insertionSite, fixedDeclarations
|
|
|
146896
147066
|
}
|
|
146897
147067
|
}
|
|
146898
147068
|
fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite));
|
|
146899
|
-
const cloneWithModifier = factory.
|
|
147069
|
+
const cloneWithModifier = factory.replaceModifiers(
|
|
146900
147070
|
getSynthesizedDeepClone(
|
|
146901
147071
|
insertionSite,
|
|
146902
147072
|
/*includeTrivia*/
|
|
@@ -157861,7 +158031,7 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
|
|
|
157861
158031
|
if (!completionNodes.length) {
|
|
157862
158032
|
modifiers = node.modifierFlagsCache | requiredModifiers;
|
|
157863
158033
|
}
|
|
157864
|
-
node = factory.
|
|
158034
|
+
node = factory.replaceModifiers(node, modifiers);
|
|
157865
158035
|
completionNodes.push(node);
|
|
157866
158036
|
},
|
|
157867
158037
|
body,
|
|
@@ -157887,11 +158057,11 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
|
|
|
157887
158057
|
modifiers &= ~4 /* Public */;
|
|
157888
158058
|
}
|
|
157889
158059
|
modifiers |= allowedAndPresent;
|
|
157890
|
-
completionNodes = completionNodes.map((node) => factory.
|
|
158060
|
+
completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers));
|
|
157891
158061
|
if (presentDecorators == null ? void 0 : presentDecorators.length) {
|
|
157892
158062
|
const lastNode = completionNodes[completionNodes.length - 1];
|
|
157893
158063
|
if (canHaveDecorators(lastNode)) {
|
|
157894
|
-
completionNodes[completionNodes.length - 1] = factory.
|
|
158064
|
+
completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
|
|
157895
158065
|
}
|
|
157896
158066
|
}
|
|
157897
158067
|
const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|