typescript 5.5.0-dev.20240404 → 5.5.0-dev.20240408
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/lib.es2023.intl.d.ts +6 -2
- package/lib/tsc.js +395 -207
- package/lib/typescript.d.ts +1 -2
- package/lib/typescript.js +1574 -235
- 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.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240408`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -1684,6 +1684,7 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
1684
1684
|
attachFlowNodeDebugInfoWorker(flowNode);
|
|
1685
1685
|
}
|
|
1686
1686
|
}
|
|
1687
|
+
return flowNode;
|
|
1687
1688
|
}
|
|
1688
1689
|
Debug2.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
|
|
1689
1690
|
let nodeArrayProto;
|
|
@@ -1959,7 +1960,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
|
|
|
1959
1960
|
return !!(f.flags & 128 /* SwitchClause */);
|
|
1960
1961
|
}
|
|
1961
1962
|
function hasAntecedents(f) {
|
|
1962
|
-
return !!(f.flags & 12 /* Label */) && !!f.
|
|
1963
|
+
return !!(f.flags & 12 /* Label */) && !!f.antecedent;
|
|
1963
1964
|
}
|
|
1964
1965
|
function hasAntecedent(f) {
|
|
1965
1966
|
return !!(f.flags & hasAntecedentFlags);
|
|
@@ -2008,7 +2009,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
|
|
|
2008
2009
|
links[id] = graphNode = { id, flowNode: flowNode2, edges: [], text: "", lane: -1, endLane: -1, level: -1, circular: false };
|
|
2009
2010
|
nodes.push(graphNode);
|
|
2010
2011
|
if (hasAntecedents(flowNode2)) {
|
|
2011
|
-
for (const antecedent of flowNode2.
|
|
2012
|
+
for (const antecedent of flowNode2.antecedent) {
|
|
2012
2013
|
buildGraphEdge(graphNode, antecedent, seen);
|
|
2013
2014
|
}
|
|
2014
2015
|
} else if (hasAntecedent(flowNode2)) {
|
|
@@ -2105,14 +2106,11 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
|
|
|
2105
2106
|
if (circular) {
|
|
2106
2107
|
text = `${text}#${getDebugFlowNodeId(flowNode2)}`;
|
|
2107
2108
|
}
|
|
2108
|
-
if (
|
|
2109
|
-
if (flowNode2.node) {
|
|
2110
|
-
text += ` (${getNodeText(flowNode2.node)})`;
|
|
2111
|
-
}
|
|
2112
|
-
} else if (isFlowSwitchClause(flowNode2)) {
|
|
2109
|
+
if (isFlowSwitchClause(flowNode2)) {
|
|
2113
2110
|
const clauses = [];
|
|
2114
|
-
|
|
2115
|
-
|
|
2111
|
+
const { switchStatement, clauseStart, clauseEnd } = flowNode2.node;
|
|
2112
|
+
for (let i = clauseStart; i < clauseEnd; i++) {
|
|
2113
|
+
const clause = switchStatement.caseBlock.clauses[i];
|
|
2116
2114
|
if (isDefaultClause(clause)) {
|
|
2117
2115
|
clauses.push("default");
|
|
2118
2116
|
} else {
|
|
@@ -2120,6 +2118,10 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
|
|
|
2120
2118
|
}
|
|
2121
2119
|
}
|
|
2122
2120
|
text += ` (${clauses.join(", ")})`;
|
|
2121
|
+
} else if (hasNode(flowNode2)) {
|
|
2122
|
+
if (flowNode2.node) {
|
|
2123
|
+
text += ` (${getNodeText(flowNode2.node)})`;
|
|
2124
|
+
}
|
|
2123
2125
|
}
|
|
2124
2126
|
return circular === "circularity" ? `Circular(${text})` : text;
|
|
2125
2127
|
}
|
|
@@ -9882,6 +9884,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9882
9884
|
return token = 23 /* OpenBracketToken */;
|
|
9883
9885
|
case 93 /* closeBracket */:
|
|
9884
9886
|
return token = 24 /* CloseBracketToken */;
|
|
9887
|
+
case 40 /* openParen */:
|
|
9888
|
+
return token = 21 /* OpenParenToken */;
|
|
9889
|
+
case 41 /* closeParen */:
|
|
9890
|
+
return token = 22 /* CloseParenToken */;
|
|
9885
9891
|
case 60 /* lessThan */:
|
|
9886
9892
|
return token = 30 /* LessThanToken */;
|
|
9887
9893
|
case 62 /* greaterThan */:
|
|
@@ -11747,8 +11753,11 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
|
|
|
11747
11753
|
if (includeJsDoc && hasJSDocNodes(node)) {
|
|
11748
11754
|
return getTokenPosOfNode(node.jsDoc[0], sourceFile);
|
|
11749
11755
|
}
|
|
11750
|
-
if (node.kind === 352 /* SyntaxList */
|
|
11751
|
-
|
|
11756
|
+
if (node.kind === 352 /* SyntaxList */) {
|
|
11757
|
+
const first2 = firstOrUndefined(getNodeChildren(node));
|
|
11758
|
+
if (first2) {
|
|
11759
|
+
return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
|
|
11760
|
+
}
|
|
11752
11761
|
}
|
|
11753
11762
|
return skipTrivia(
|
|
11754
11763
|
(sourceFile || getSourceFileOfNode(node)).text,
|
|
@@ -17687,79 +17696,81 @@ function replaceFirstStar(s, replacement) {
|
|
|
17687
17696
|
function getNameFromImportAttribute(node) {
|
|
17688
17697
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17689
17698
|
}
|
|
17690
|
-
function isSyntacticallyString
|
|
17691
|
-
|
|
17692
|
-
switch (expr.kind) {
|
|
17693
|
-
case 226 /* BinaryExpression */:
|
|
17694
|
-
const left = expr.left;
|
|
17695
|
-
const right = expr.right;
|
|
17696
|
-
return expr.operatorToken.kind === 40 /* PlusToken */ && (isSyntacticallyString(left) || isSyntacticallyString(right));
|
|
17697
|
-
case 228 /* TemplateExpression */:
|
|
17698
|
-
case 11 /* StringLiteral */:
|
|
17699
|
-
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17700
|
-
return true;
|
|
17701
|
-
}
|
|
17702
|
-
return false;
|
|
17699
|
+
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false) {
|
|
17700
|
+
return { value, isSyntacticallyString, resolvedOtherFiles };
|
|
17703
17701
|
}
|
|
17704
17702
|
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
17705
17703
|
function evaluate(expr, location) {
|
|
17704
|
+
let isSyntacticallyString = false;
|
|
17705
|
+
let resolvedOtherFiles = false;
|
|
17706
|
+
expr = skipParentheses(expr);
|
|
17706
17707
|
switch (expr.kind) {
|
|
17707
17708
|
case 224 /* PrefixUnaryExpression */:
|
|
17708
|
-
const
|
|
17709
|
-
|
|
17709
|
+
const result = evaluate(expr.operand, location);
|
|
17710
|
+
resolvedOtherFiles = result.resolvedOtherFiles;
|
|
17711
|
+
if (typeof result.value === "number") {
|
|
17710
17712
|
switch (expr.operator) {
|
|
17711
17713
|
case 40 /* PlusToken */:
|
|
17712
|
-
return value;
|
|
17714
|
+
return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17713
17715
|
case 41 /* MinusToken */:
|
|
17714
|
-
return -value;
|
|
17716
|
+
return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17715
17717
|
case 55 /* TildeToken */:
|
|
17716
|
-
return ~value;
|
|
17718
|
+
return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17717
17719
|
}
|
|
17718
17720
|
}
|
|
17719
17721
|
break;
|
|
17720
|
-
case 226 /* BinaryExpression */:
|
|
17722
|
+
case 226 /* BinaryExpression */: {
|
|
17721
17723
|
const left = evaluate(expr.left, location);
|
|
17722
17724
|
const right = evaluate(expr.right, location);
|
|
17723
|
-
|
|
17725
|
+
isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
|
|
17726
|
+
resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
|
|
17727
|
+
if (typeof left.value === "number" && typeof right.value === "number") {
|
|
17724
17728
|
switch (expr.operatorToken.kind) {
|
|
17725
17729
|
case 52 /* BarToken */:
|
|
17726
|
-
return left | right;
|
|
17730
|
+
return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17727
17731
|
case 51 /* AmpersandToken */:
|
|
17728
|
-
return left & right;
|
|
17732
|
+
return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17729
17733
|
case 49 /* GreaterThanGreaterThanToken */:
|
|
17730
|
-
return left >> right;
|
|
17734
|
+
return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17731
17735
|
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
17732
|
-
return left >>> right;
|
|
17736
|
+
return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17733
17737
|
case 48 /* LessThanLessThanToken */:
|
|
17734
|
-
return left << right;
|
|
17738
|
+
return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17735
17739
|
case 53 /* CaretToken */:
|
|
17736
|
-
return left ^ right;
|
|
17740
|
+
return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17737
17741
|
case 42 /* AsteriskToken */:
|
|
17738
|
-
return left * right;
|
|
17742
|
+
return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17739
17743
|
case 44 /* SlashToken */:
|
|
17740
|
-
return left / right;
|
|
17744
|
+
return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17741
17745
|
case 40 /* PlusToken */:
|
|
17742
|
-
return left + right;
|
|
17746
|
+
return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17743
17747
|
case 41 /* MinusToken */:
|
|
17744
|
-
return left - right;
|
|
17748
|
+
return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17745
17749
|
case 45 /* PercentToken */:
|
|
17746
|
-
return left % right;
|
|
17750
|
+
return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17747
17751
|
case 43 /* AsteriskAsteriskToken */:
|
|
17748
|
-
return left ** right;
|
|
17752
|
+
return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17749
17753
|
}
|
|
17750
|
-
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17751
|
-
return
|
|
17754
|
+
} else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17755
|
+
return evaluatorResult(
|
|
17756
|
+
"" + left.value + right.value,
|
|
17757
|
+
isSyntacticallyString,
|
|
17758
|
+
resolvedOtherFiles
|
|
17759
|
+
);
|
|
17752
17760
|
}
|
|
17753
17761
|
break;
|
|
17762
|
+
}
|
|
17754
17763
|
case 11 /* StringLiteral */:
|
|
17755
17764
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17756
|
-
return
|
|
17765
|
+
return evaluatorResult(
|
|
17766
|
+
expr.text,
|
|
17767
|
+
/*isSyntacticallyString*/
|
|
17768
|
+
true
|
|
17769
|
+
);
|
|
17757
17770
|
case 228 /* TemplateExpression */:
|
|
17758
17771
|
return evaluateTemplateExpression(expr, location);
|
|
17759
17772
|
case 9 /* NumericLiteral */:
|
|
17760
|
-
return +expr.text;
|
|
17761
|
-
case 217 /* ParenthesizedExpression */:
|
|
17762
|
-
return evaluate(expr.expression, location);
|
|
17773
|
+
return evaluatorResult(+expr.text);
|
|
17763
17774
|
case 80 /* Identifier */:
|
|
17764
17775
|
return evaluateEntityNameExpression(expr, location);
|
|
17765
17776
|
case 211 /* PropertyAccessExpression */:
|
|
@@ -17770,19 +17781,36 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17770
17781
|
case 212 /* ElementAccessExpression */:
|
|
17771
17782
|
return evaluateElementAccessExpression(expr, location);
|
|
17772
17783
|
}
|
|
17773
|
-
return
|
|
17784
|
+
return evaluatorResult(
|
|
17785
|
+
/*value*/
|
|
17786
|
+
void 0,
|
|
17787
|
+
isSyntacticallyString,
|
|
17788
|
+
resolvedOtherFiles
|
|
17789
|
+
);
|
|
17774
17790
|
}
|
|
17775
17791
|
function evaluateTemplateExpression(expr, location) {
|
|
17776
17792
|
let result = expr.head.text;
|
|
17793
|
+
let resolvedOtherFiles = false;
|
|
17777
17794
|
for (const span of expr.templateSpans) {
|
|
17778
|
-
const
|
|
17779
|
-
if (value === void 0) {
|
|
17780
|
-
return
|
|
17795
|
+
const spanResult = evaluate(span.expression, location);
|
|
17796
|
+
if (spanResult.value === void 0) {
|
|
17797
|
+
return evaluatorResult(
|
|
17798
|
+
/*value*/
|
|
17799
|
+
void 0,
|
|
17800
|
+
/*isSyntacticallyString*/
|
|
17801
|
+
true
|
|
17802
|
+
);
|
|
17781
17803
|
}
|
|
17782
|
-
result += value;
|
|
17804
|
+
result += spanResult.value;
|
|
17783
17805
|
result += span.literal.text;
|
|
17806
|
+
resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
|
|
17784
17807
|
}
|
|
17785
|
-
return
|
|
17808
|
+
return evaluatorResult(
|
|
17809
|
+
result,
|
|
17810
|
+
/*isSyntacticallyString*/
|
|
17811
|
+
true,
|
|
17812
|
+
resolvedOtherFiles
|
|
17813
|
+
);
|
|
17786
17814
|
}
|
|
17787
17815
|
return evaluate;
|
|
17788
17816
|
}
|
|
@@ -21926,7 +21954,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21926
21954
|
}
|
|
21927
21955
|
function createSyntaxList(children) {
|
|
21928
21956
|
const node = createBaseNode(352 /* SyntaxList */);
|
|
21929
|
-
node
|
|
21957
|
+
setNodeChildren(node, children);
|
|
21930
21958
|
return node;
|
|
21931
21959
|
}
|
|
21932
21960
|
function createNotEmittedStatement(original) {
|
|
@@ -24703,6 +24731,19 @@ function isJSDocImportTag(node) {
|
|
|
24703
24731
|
return node.kind === 351 /* JSDocImportTag */;
|
|
24704
24732
|
}
|
|
24705
24733
|
|
|
24734
|
+
// src/compiler/factory/nodeChildren.ts
|
|
24735
|
+
var nodeChildren = /* @__PURE__ */ new WeakMap();
|
|
24736
|
+
function getNodeChildren(node) {
|
|
24737
|
+
return nodeChildren.get(node);
|
|
24738
|
+
}
|
|
24739
|
+
function setNodeChildren(node, children) {
|
|
24740
|
+
nodeChildren.set(node, children);
|
|
24741
|
+
return children;
|
|
24742
|
+
}
|
|
24743
|
+
function unsetNodeChildren(node) {
|
|
24744
|
+
nodeChildren.delete(node);
|
|
24745
|
+
}
|
|
24746
|
+
|
|
24706
24747
|
// src/compiler/factory/utilities.ts
|
|
24707
24748
|
function createEmptyExports(factory2) {
|
|
24708
24749
|
return factory2.createExportDeclaration(
|
|
@@ -33334,9 +33375,7 @@ var IncrementalParser;
|
|
|
33334
33375
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33335
33376
|
text = oldText.substring(node.pos, node.end);
|
|
33336
33377
|
}
|
|
33337
|
-
|
|
33338
|
-
node._children = void 0;
|
|
33339
|
-
}
|
|
33378
|
+
unsetNodeChildren(node);
|
|
33340
33379
|
setTextRangePosEnd(node, node.pos + delta, node.end + delta);
|
|
33341
33380
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33342
33381
|
Debug.assert(text === newText.substring(node.pos, node.end));
|
|
@@ -33350,7 +33389,6 @@ var IncrementalParser;
|
|
|
33350
33389
|
checkNodePositions(node, aggressiveChecks);
|
|
33351
33390
|
}
|
|
33352
33391
|
function visitArray2(array) {
|
|
33353
|
-
array._children = void 0;
|
|
33354
33392
|
setTextRangePosEnd(array, array.pos + delta, array.end + delta);
|
|
33355
33393
|
for (const node of array) {
|
|
33356
33394
|
visitNode3(node);
|
|
@@ -33422,7 +33460,7 @@ var IncrementalParser;
|
|
|
33422
33460
|
const fullEnd = child.end;
|
|
33423
33461
|
if (fullEnd >= changeStart) {
|
|
33424
33462
|
child.intersectsChange = true;
|
|
33425
|
-
child
|
|
33463
|
+
unsetNodeChildren(child);
|
|
33426
33464
|
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33427
33465
|
forEachChild(child, visitNode3, visitArray2);
|
|
33428
33466
|
if (hasJSDocNodes(child)) {
|
|
@@ -33452,7 +33490,6 @@ var IncrementalParser;
|
|
|
33452
33490
|
const fullEnd = array.end;
|
|
33453
33491
|
if (fullEnd >= changeStart) {
|
|
33454
33492
|
array.intersectsChange = true;
|
|
33455
|
-
array._children = void 0;
|
|
33456
33493
|
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33457
33494
|
for (const node of array) {
|
|
33458
33495
|
visitNode3(node);
|
|
@@ -39595,9 +39632,8 @@ function getModuleInstanceStateForAliasTarget(specifier, visited) {
|
|
|
39595
39632
|
}
|
|
39596
39633
|
return 1 /* Instantiated */;
|
|
39597
39634
|
}
|
|
39598
|
-
function
|
|
39599
|
-
Debug.attachFlowNodeDebugInfo(node);
|
|
39600
|
-
return node;
|
|
39635
|
+
function createFlowNode(flags, node, antecedent) {
|
|
39636
|
+
return Debug.attachFlowNodeDebugInfo({ flags, id: 0, node, antecedent });
|
|
39601
39637
|
}
|
|
39602
39638
|
var binder = /* @__PURE__ */ createBinder();
|
|
39603
39639
|
function bindSourceFile(file, options) {
|
|
@@ -39631,14 +39667,27 @@ function createBinder() {
|
|
|
39631
39667
|
var preSwitchCaseFlow;
|
|
39632
39668
|
var activeLabelList;
|
|
39633
39669
|
var hasExplicitReturn;
|
|
39670
|
+
var hasFlowEffects;
|
|
39634
39671
|
var emitFlags;
|
|
39635
39672
|
var inStrictMode;
|
|
39636
39673
|
var inAssignmentPattern = false;
|
|
39637
39674
|
var symbolCount = 0;
|
|
39638
39675
|
var Symbol12;
|
|
39639
39676
|
var classifiableNames;
|
|
39640
|
-
var unreachableFlow =
|
|
39641
|
-
|
|
39677
|
+
var unreachableFlow = createFlowNode(
|
|
39678
|
+
1 /* Unreachable */,
|
|
39679
|
+
/*node*/
|
|
39680
|
+
void 0,
|
|
39681
|
+
/*antecedent*/
|
|
39682
|
+
void 0
|
|
39683
|
+
);
|
|
39684
|
+
var reportedUnreachableFlow = createFlowNode(
|
|
39685
|
+
1 /* Unreachable */,
|
|
39686
|
+
/*node*/
|
|
39687
|
+
void 0,
|
|
39688
|
+
/*antecedent*/
|
|
39689
|
+
void 0
|
|
39690
|
+
);
|
|
39642
39691
|
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
|
|
39643
39692
|
return bindSourceFile2;
|
|
39644
39693
|
function createDiagnosticForNode2(node, message, ...args) {
|
|
@@ -39690,6 +39739,7 @@ function createBinder() {
|
|
|
39690
39739
|
currentExceptionTarget = void 0;
|
|
39691
39740
|
activeLabelList = void 0;
|
|
39692
39741
|
hasExplicitReturn = false;
|
|
39742
|
+
hasFlowEffects = false;
|
|
39693
39743
|
inAssignmentPattern = false;
|
|
39694
39744
|
emitFlags = 0 /* None */;
|
|
39695
39745
|
}
|
|
@@ -39957,7 +40007,13 @@ function createBinder() {
|
|
|
39957
40007
|
const saveHasExplicitReturn = hasExplicitReturn;
|
|
39958
40008
|
const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */;
|
|
39959
40009
|
if (!isImmediatelyInvoked) {
|
|
39960
|
-
currentFlow =
|
|
40010
|
+
currentFlow = createFlowNode(
|
|
40011
|
+
2 /* Start */,
|
|
40012
|
+
/*node*/
|
|
40013
|
+
void 0,
|
|
40014
|
+
/*antecedent*/
|
|
40015
|
+
void 0
|
|
40016
|
+
);
|
|
39961
40017
|
if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
|
|
39962
40018
|
currentFlow.node = node;
|
|
39963
40019
|
}
|
|
@@ -40147,8 +40203,8 @@ function createBinder() {
|
|
|
40147
40203
|
function isNarrowingExpression(expr) {
|
|
40148
40204
|
switch (expr.kind) {
|
|
40149
40205
|
case 80 /* Identifier */:
|
|
40150
|
-
case 81 /* PrivateIdentifier */:
|
|
40151
40206
|
case 110 /* ThisKeyword */:
|
|
40207
|
+
return true;
|
|
40152
40208
|
case 211 /* PropertyAccessExpression */:
|
|
40153
40209
|
case 212 /* ElementAccessExpression */:
|
|
40154
40210
|
return containsNarrowableReference(expr);
|
|
@@ -40170,7 +40226,22 @@ function createBinder() {
|
|
|
40170
40226
|
return false;
|
|
40171
40227
|
}
|
|
40172
40228
|
function isNarrowableReference(expr) {
|
|
40173
|
-
|
|
40229
|
+
switch (expr.kind) {
|
|
40230
|
+
case 80 /* Identifier */:
|
|
40231
|
+
case 110 /* ThisKeyword */:
|
|
40232
|
+
case 108 /* SuperKeyword */:
|
|
40233
|
+
case 236 /* MetaProperty */:
|
|
40234
|
+
return true;
|
|
40235
|
+
case 211 /* PropertyAccessExpression */:
|
|
40236
|
+
case 217 /* ParenthesizedExpression */:
|
|
40237
|
+
case 235 /* NonNullExpression */:
|
|
40238
|
+
return isNarrowableReference(expr.expression);
|
|
40239
|
+
case 212 /* ElementAccessExpression */:
|
|
40240
|
+
return (isStringOrNumericLiteralLike(expr.argumentExpression) || isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression);
|
|
40241
|
+
case 226 /* BinaryExpression */:
|
|
40242
|
+
return expr.operatorToken.kind === 28 /* CommaToken */ && isNarrowableReference(expr.right) || isAssignmentOperator(expr.operatorToken.kind) && isLeftHandSideExpression(expr.left);
|
|
40243
|
+
}
|
|
40244
|
+
return false;
|
|
40174
40245
|
}
|
|
40175
40246
|
function containsNarrowableReference(expr) {
|
|
40176
40247
|
return isNarrowableReference(expr) || isOptionalChain(expr) && containsNarrowableReference(expr.expression);
|
|
@@ -40227,20 +40298,32 @@ function createBinder() {
|
|
|
40227
40298
|
return containsNarrowableReference(expr);
|
|
40228
40299
|
}
|
|
40229
40300
|
function createBranchLabel() {
|
|
40230
|
-
return
|
|
40301
|
+
return createFlowNode(
|
|
40302
|
+
4 /* BranchLabel */,
|
|
40303
|
+
/*node*/
|
|
40304
|
+
void 0,
|
|
40305
|
+
/*antecedent*/
|
|
40306
|
+
void 0
|
|
40307
|
+
);
|
|
40231
40308
|
}
|
|
40232
40309
|
function createLoopLabel() {
|
|
40233
|
-
return
|
|
40310
|
+
return createFlowNode(
|
|
40311
|
+
8 /* LoopLabel */,
|
|
40312
|
+
/*node*/
|
|
40313
|
+
void 0,
|
|
40314
|
+
/*antecedent*/
|
|
40315
|
+
void 0
|
|
40316
|
+
);
|
|
40234
40317
|
}
|
|
40235
40318
|
function createReduceLabel(target, antecedents, antecedent) {
|
|
40236
|
-
return
|
|
40319
|
+
return createFlowNode(1024 /* ReduceLabel */, { target, antecedents }, antecedent);
|
|
40237
40320
|
}
|
|
40238
40321
|
function setFlowNodeReferenced(flow) {
|
|
40239
40322
|
flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */;
|
|
40240
40323
|
}
|
|
40241
40324
|
function addAntecedent(label, antecedent) {
|
|
40242
|
-
if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.
|
|
40243
|
-
(label.
|
|
40325
|
+
if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.antecedent, antecedent)) {
|
|
40326
|
+
(label.antecedent || (label.antecedent = [])).push(antecedent);
|
|
40244
40327
|
setFlowNodeReferenced(antecedent);
|
|
40245
40328
|
}
|
|
40246
40329
|
}
|
|
@@ -40258,15 +40341,16 @@ function createBinder() {
|
|
|
40258
40341
|
return antecedent;
|
|
40259
40342
|
}
|
|
40260
40343
|
setFlowNodeReferenced(antecedent);
|
|
40261
|
-
return
|
|
40344
|
+
return createFlowNode(flags, expression, antecedent);
|
|
40262
40345
|
}
|
|
40263
40346
|
function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
|
|
40264
40347
|
setFlowNodeReferenced(antecedent);
|
|
40265
|
-
return
|
|
40348
|
+
return createFlowNode(128 /* SwitchClause */, { switchStatement, clauseStart, clauseEnd }, antecedent);
|
|
40266
40349
|
}
|
|
40267
40350
|
function createFlowMutation(flags, antecedent, node) {
|
|
40268
40351
|
setFlowNodeReferenced(antecedent);
|
|
40269
|
-
|
|
40352
|
+
hasFlowEffects = true;
|
|
40353
|
+
const result = createFlowNode(flags, node, antecedent);
|
|
40270
40354
|
if (currentExceptionTarget) {
|
|
40271
40355
|
addAntecedent(currentExceptionTarget, result);
|
|
40272
40356
|
}
|
|
@@ -40274,10 +40358,11 @@ function createBinder() {
|
|
|
40274
40358
|
}
|
|
40275
40359
|
function createFlowCall(antecedent, node) {
|
|
40276
40360
|
setFlowNodeReferenced(antecedent);
|
|
40277
|
-
|
|
40361
|
+
hasFlowEffects = true;
|
|
40362
|
+
return createFlowNode(512 /* Call */, node, antecedent);
|
|
40278
40363
|
}
|
|
40279
40364
|
function finishFlowLabel(flow) {
|
|
40280
|
-
const antecedents = flow.
|
|
40365
|
+
const antecedents = flow.antecedent;
|
|
40281
40366
|
if (!antecedents) {
|
|
40282
40367
|
return unreachableFlow;
|
|
40283
40368
|
}
|
|
@@ -40431,6 +40516,7 @@ function createBinder() {
|
|
|
40431
40516
|
}
|
|
40432
40517
|
}
|
|
40433
40518
|
currentFlow = unreachableFlow;
|
|
40519
|
+
hasFlowEffects = true;
|
|
40434
40520
|
}
|
|
40435
40521
|
function findActiveLabel(name) {
|
|
40436
40522
|
for (let label = activeLabelList; label; label = label.next) {
|
|
@@ -40445,6 +40531,7 @@ function createBinder() {
|
|
|
40445
40531
|
if (flowLabel) {
|
|
40446
40532
|
addAntecedent(flowLabel, currentFlow);
|
|
40447
40533
|
currentFlow = unreachableFlow;
|
|
40534
|
+
hasFlowEffects = true;
|
|
40448
40535
|
}
|
|
40449
40536
|
}
|
|
40450
40537
|
function bindBreakOrContinueStatement(node) {
|
|
@@ -40484,19 +40571,19 @@ function createBinder() {
|
|
|
40484
40571
|
currentExceptionTarget = saveExceptionTarget;
|
|
40485
40572
|
if (node.finallyBlock) {
|
|
40486
40573
|
const finallyLabel = createBranchLabel();
|
|
40487
|
-
finallyLabel.
|
|
40574
|
+
finallyLabel.antecedent = concatenate(concatenate(normalExitLabel.antecedent, exceptionLabel.antecedent), returnLabel.antecedent);
|
|
40488
40575
|
currentFlow = finallyLabel;
|
|
40489
40576
|
bind(node.finallyBlock);
|
|
40490
40577
|
if (currentFlow.flags & 1 /* Unreachable */) {
|
|
40491
40578
|
currentFlow = unreachableFlow;
|
|
40492
40579
|
} else {
|
|
40493
|
-
if (currentReturnTarget && returnLabel.
|
|
40494
|
-
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.
|
|
40580
|
+
if (currentReturnTarget && returnLabel.antecedent) {
|
|
40581
|
+
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedent, currentFlow));
|
|
40495
40582
|
}
|
|
40496
|
-
if (currentExceptionTarget && exceptionLabel.
|
|
40497
|
-
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.
|
|
40583
|
+
if (currentExceptionTarget && exceptionLabel.antecedent) {
|
|
40584
|
+
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedent, currentFlow));
|
|
40498
40585
|
}
|
|
40499
|
-
currentFlow = normalExitLabel.
|
|
40586
|
+
currentFlow = normalExitLabel.antecedent ? createReduceLabel(finallyLabel, normalExitLabel.antecedent, currentFlow) : unreachableFlow;
|
|
40500
40587
|
}
|
|
40501
40588
|
} else {
|
|
40502
40589
|
currentFlow = finishFlowLabel(normalExitLabel);
|
|
@@ -40512,7 +40599,7 @@ function createBinder() {
|
|
|
40512
40599
|
bind(node.caseBlock);
|
|
40513
40600
|
addAntecedent(postSwitchLabel, currentFlow);
|
|
40514
40601
|
const hasDefault = forEach(node.caseBlock.clauses, (c) => c.kind === 297 /* DefaultClause */);
|
|
40515
|
-
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.
|
|
40602
|
+
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedent;
|
|
40516
40603
|
if (!hasDefault) {
|
|
40517
40604
|
addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
|
|
40518
40605
|
}
|
|
@@ -40700,8 +40787,12 @@ function createBinder() {
|
|
|
40700
40787
|
if (isLogicalOrCoalescingBinaryOperator(operator) || isLogicalOrCoalescingAssignmentOperator(operator)) {
|
|
40701
40788
|
if (isTopLevelLogicalExpression(node)) {
|
|
40702
40789
|
const postExpressionLabel = createBranchLabel();
|
|
40790
|
+
const saveCurrentFlow = currentFlow;
|
|
40791
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40792
|
+
hasFlowEffects = false;
|
|
40703
40793
|
bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
|
|
40704
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40794
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40795
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40705
40796
|
} else {
|
|
40706
40797
|
bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
|
|
40707
40798
|
}
|
|
@@ -40773,6 +40864,9 @@ function createBinder() {
|
|
|
40773
40864
|
const trueLabel = createBranchLabel();
|
|
40774
40865
|
const falseLabel = createBranchLabel();
|
|
40775
40866
|
const postExpressionLabel = createBranchLabel();
|
|
40867
|
+
const saveCurrentFlow = currentFlow;
|
|
40868
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40869
|
+
hasFlowEffects = false;
|
|
40776
40870
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
40777
40871
|
currentFlow = finishFlowLabel(trueLabel);
|
|
40778
40872
|
bind(node.questionToken);
|
|
@@ -40782,7 +40876,8 @@ function createBinder() {
|
|
|
40782
40876
|
bind(node.colonToken);
|
|
40783
40877
|
bind(node.whenFalse);
|
|
40784
40878
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
40785
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40879
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40880
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40786
40881
|
}
|
|
40787
40882
|
function bindInitializedVariableFlow(node) {
|
|
40788
40883
|
const name = !isOmittedExpression(node) ? node.name : void 0;
|
|
@@ -40894,8 +40989,11 @@ function createBinder() {
|
|
|
40894
40989
|
function bindOptionalChainFlow(node) {
|
|
40895
40990
|
if (isTopLevelLogicalExpression(node)) {
|
|
40896
40991
|
const postExpressionLabel = createBranchLabel();
|
|
40992
|
+
const saveCurrentFlow = currentFlow;
|
|
40993
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40897
40994
|
bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
|
|
40898
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40995
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40996
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40899
40997
|
} else {
|
|
40900
40998
|
bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
|
|
40901
40999
|
}
|
|
@@ -41116,7 +41214,13 @@ function createBinder() {
|
|
|
41116
41214
|
const host = typeAlias.parent.parent;
|
|
41117
41215
|
container = getEnclosingContainer(host) || file;
|
|
41118
41216
|
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
|
|
41119
|
-
currentFlow =
|
|
41217
|
+
currentFlow = createFlowNode(
|
|
41218
|
+
2 /* Start */,
|
|
41219
|
+
/*node*/
|
|
41220
|
+
void 0,
|
|
41221
|
+
/*antecedent*/
|
|
41222
|
+
void 0
|
|
41223
|
+
);
|
|
41120
41224
|
parent = typeAlias;
|
|
41121
41225
|
bind(typeAlias.typeExpression);
|
|
41122
41226
|
const declName = getNameOfDeclaration(typeAlias);
|
|
@@ -41186,7 +41290,13 @@ function createBinder() {
|
|
|
41186
41290
|
const enclosingBlockScopeContainer = host ? getEnclosingBlockScopeContainer(host) : void 0;
|
|
41187
41291
|
container = enclosingContainer || file;
|
|
41188
41292
|
blockScopeContainer = enclosingBlockScopeContainer || file;
|
|
41189
|
-
currentFlow =
|
|
41293
|
+
currentFlow = createFlowNode(
|
|
41294
|
+
2 /* Start */,
|
|
41295
|
+
/*node*/
|
|
41296
|
+
void 0,
|
|
41297
|
+
/*antecedent*/
|
|
41298
|
+
void 0
|
|
41299
|
+
);
|
|
41190
41300
|
parent = jsDocImportTag;
|
|
41191
41301
|
bind(jsDocImportTag.importClause);
|
|
41192
41302
|
}
|
|
@@ -47851,7 +47961,7 @@ function createTypeChecker(host) {
|
|
|
47851
47961
|
}
|
|
47852
47962
|
function getMeaningOfEntityNameReference(entityName) {
|
|
47853
47963
|
let meaning;
|
|
47854
|
-
if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
|
|
47964
|
+
if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */ || entityName.parent.kind === 182 /* TypePredicate */ && entityName.parent.parameterName === entityName) {
|
|
47855
47965
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
47856
47966
|
} else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */ || entityName.parent.kind === 166 /* QualifiedName */ && entityName.parent.left === entityName || entityName.parent.kind === 211 /* PropertyAccessExpression */ && entityName.parent.expression === entityName || entityName.parent.kind === 212 /* ElementAccessExpression */ && entityName.parent.expression === entityName) {
|
|
47857
47967
|
meaning = 1920 /* Namespace */;
|
|
@@ -50027,7 +50137,28 @@ function createTypeChecker(host) {
|
|
|
50027
50137
|
return { introducesError, node };
|
|
50028
50138
|
}
|
|
50029
50139
|
const meaning = getMeaningOfEntityNameReference(node);
|
|
50030
|
-
|
|
50140
|
+
let sym;
|
|
50141
|
+
if (isThisIdentifier(leftmost)) {
|
|
50142
|
+
sym = getSymbolOfDeclaration(getThisContainer(
|
|
50143
|
+
leftmost,
|
|
50144
|
+
/*includeArrowFunctions*/
|
|
50145
|
+
false,
|
|
50146
|
+
/*includeClassComputedPropertyName*/
|
|
50147
|
+
false
|
|
50148
|
+
));
|
|
50149
|
+
if (isSymbolAccessible(
|
|
50150
|
+
sym,
|
|
50151
|
+
leftmost,
|
|
50152
|
+
meaning,
|
|
50153
|
+
/*shouldComputeAliasesToMakeVisible*/
|
|
50154
|
+
false
|
|
50155
|
+
).accessibility !== 0 /* Accessible */) {
|
|
50156
|
+
introducesError = true;
|
|
50157
|
+
context.tracker.reportInaccessibleThisError();
|
|
50158
|
+
}
|
|
50159
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50160
|
+
}
|
|
50161
|
+
sym = resolveEntityName(
|
|
50031
50162
|
leftmost,
|
|
50032
50163
|
meaning,
|
|
50033
50164
|
/*ignoreErrors*/
|
|
@@ -50036,27 +50167,44 @@ function createTypeChecker(host) {
|
|
|
50036
50167
|
true
|
|
50037
50168
|
);
|
|
50038
50169
|
if (sym) {
|
|
50039
|
-
if (
|
|
50170
|
+
if (sym.flags & 1 /* FunctionScopedVariable */ && sym.valueDeclaration) {
|
|
50171
|
+
if (isParameterDeclaration(sym.valueDeclaration)) {
|
|
50172
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50173
|
+
}
|
|
50174
|
+
}
|
|
50175
|
+
if (!(sym.flags & 262144 /* TypeParameter */) && // Type parameters are visible in the curent context if they are are resolvable
|
|
50176
|
+
!isDeclarationName(node) && isSymbolAccessible(
|
|
50040
50177
|
sym,
|
|
50041
50178
|
context.enclosingDeclaration,
|
|
50042
50179
|
meaning,
|
|
50043
50180
|
/*shouldComputeAliasesToMakeVisible*/
|
|
50044
50181
|
false
|
|
50045
50182
|
).accessibility !== 0 /* Accessible */) {
|
|
50046
|
-
|
|
50047
|
-
introducesError = true;
|
|
50048
|
-
}
|
|
50183
|
+
introducesError = true;
|
|
50049
50184
|
} else {
|
|
50050
50185
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
50051
50186
|
}
|
|
50052
|
-
|
|
50187
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50188
|
+
}
|
|
50189
|
+
return { introducesError, node };
|
|
50190
|
+
function attachSymbolToLeftmostIdentifier(node2) {
|
|
50191
|
+
if (node2 === leftmost) {
|
|
50053
50192
|
const type = getDeclaredTypeOfSymbol(sym);
|
|
50054
|
-
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(
|
|
50193
|
+
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
|
|
50055
50194
|
name.symbol = sym;
|
|
50056
|
-
return
|
|
50195
|
+
return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
|
|
50057
50196
|
}
|
|
50197
|
+
const updated = visitEachChild(
|
|
50198
|
+
node2,
|
|
50199
|
+
(c) => attachSymbolToLeftmostIdentifier(c),
|
|
50200
|
+
/*context*/
|
|
50201
|
+
void 0
|
|
50202
|
+
);
|
|
50203
|
+
if (updated !== node2) {
|
|
50204
|
+
setTextRange(updated, node2);
|
|
50205
|
+
}
|
|
50206
|
+
return updated;
|
|
50058
50207
|
}
|
|
50059
|
-
return { introducesError, node };
|
|
50060
50208
|
}
|
|
50061
50209
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
50062
50210
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
@@ -50217,11 +50365,12 @@ function createTypeChecker(host) {
|
|
|
50217
50365
|
return visited;
|
|
50218
50366
|
}
|
|
50219
50367
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
50368
|
+
if (isDeclarationName(node)) {
|
|
50369
|
+
return node;
|
|
50370
|
+
}
|
|
50220
50371
|
const { introducesError, node: result } = trackExistingEntityName(node, context);
|
|
50221
50372
|
hadError = hadError || introducesError;
|
|
50222
|
-
|
|
50223
|
-
return result;
|
|
50224
|
-
}
|
|
50373
|
+
return result;
|
|
50225
50374
|
}
|
|
50226
50375
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
50227
50376
|
const visited = visitEachChild(
|
|
@@ -52391,6 +52540,9 @@ function createTypeChecker(host) {
|
|
|
52391
52540
|
}
|
|
52392
52541
|
}
|
|
52393
52542
|
if (isParameter(declaration)) {
|
|
52543
|
+
if (!declaration.symbol) {
|
|
52544
|
+
return;
|
|
52545
|
+
}
|
|
52394
52546
|
const func = declaration.parent;
|
|
52395
52547
|
if (func.kind === 178 /* SetAccessor */ && hasBindableName(func)) {
|
|
52396
52548
|
const getter = getDeclarationOfKind(getSymbolOfDeclaration(declaration.parent), 177 /* GetAccessor */);
|
|
@@ -53750,7 +53902,7 @@ function createTypeChecker(host) {
|
|
|
53750
53902
|
for (const member of declaration.members) {
|
|
53751
53903
|
if (hasBindableName(member)) {
|
|
53752
53904
|
const memberSymbol = getSymbolOfDeclaration(member);
|
|
53753
|
-
const value = getEnumMemberValue(member);
|
|
53905
|
+
const value = getEnumMemberValue(member).value;
|
|
53754
53906
|
const memberType = getFreshTypeOfLiteralType(
|
|
53755
53907
|
value !== void 0 ? getEnumLiteralType(value, getSymbolId(symbol), memberSymbol) : createComputedEnumType(memberSymbol)
|
|
53756
53908
|
);
|
|
@@ -60886,8 +61038,8 @@ function createTypeChecker(host) {
|
|
|
60886
61038
|
}
|
|
60887
61039
|
return false;
|
|
60888
61040
|
}
|
|
60889
|
-
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
|
|
60890
|
-
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */));
|
|
61041
|
+
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
|
|
61042
|
+
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */)).value;
|
|
60891
61043
|
if (sourceValue !== targetValue) {
|
|
60892
61044
|
const sourceIsString = typeof sourceValue === "string";
|
|
60893
61045
|
const targetIsString = typeof targetValue === "string";
|
|
@@ -65769,7 +65921,7 @@ function createTypeChecker(host) {
|
|
|
65769
65921
|
return false;
|
|
65770
65922
|
}
|
|
65771
65923
|
function getFlowNodeId(flow) {
|
|
65772
|
-
if (
|
|
65924
|
+
if (flow.id <= 0) {
|
|
65773
65925
|
flow.id = nextFlowId;
|
|
65774
65926
|
nextFlowId++;
|
|
65775
65927
|
}
|
|
@@ -66404,33 +66556,34 @@ function createTypeChecker(host) {
|
|
|
66404
66556
|
}
|
|
66405
66557
|
flow = flow.antecedent;
|
|
66406
66558
|
} else if (flags & 4 /* BranchLabel */) {
|
|
66407
|
-
return some(flow.
|
|
66559
|
+
return some(flow.antecedent, (f) => isReachableFlowNodeWorker(
|
|
66408
66560
|
f,
|
|
66409
66561
|
/*noCacheCheck*/
|
|
66410
66562
|
false
|
|
66411
66563
|
));
|
|
66412
66564
|
} else if (flags & 8 /* LoopLabel */) {
|
|
66413
|
-
const antecedents = flow.
|
|
66565
|
+
const antecedents = flow.antecedent;
|
|
66414
66566
|
if (antecedents === void 0 || antecedents.length === 0) {
|
|
66415
66567
|
return false;
|
|
66416
66568
|
}
|
|
66417
66569
|
flow = antecedents[0];
|
|
66418
66570
|
} else if (flags & 128 /* SwitchClause */) {
|
|
66419
|
-
|
|
66571
|
+
const data = flow.node;
|
|
66572
|
+
if (data.clauseStart === data.clauseEnd && isExhaustiveSwitchStatement(data.switchStatement)) {
|
|
66420
66573
|
return false;
|
|
66421
66574
|
}
|
|
66422
66575
|
flow = flow.antecedent;
|
|
66423
66576
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66424
66577
|
lastFlowNode = void 0;
|
|
66425
|
-
const target = flow.target;
|
|
66426
|
-
const saveAntecedents = target.
|
|
66427
|
-
target.
|
|
66578
|
+
const target = flow.node.target;
|
|
66579
|
+
const saveAntecedents = target.antecedent;
|
|
66580
|
+
target.antecedent = flow.node.antecedents;
|
|
66428
66581
|
const result = isReachableFlowNodeWorker(
|
|
66429
66582
|
flow.antecedent,
|
|
66430
66583
|
/*noCacheCheck*/
|
|
66431
66584
|
false
|
|
66432
66585
|
);
|
|
66433
|
-
target.
|
|
66586
|
+
target.antecedent = saveAntecedents;
|
|
66434
66587
|
return result;
|
|
66435
66588
|
} else {
|
|
66436
66589
|
return !(flags & 1 /* Unreachable */);
|
|
@@ -66460,23 +66613,23 @@ function createTypeChecker(host) {
|
|
|
66460
66613
|
}
|
|
66461
66614
|
flow = flow.antecedent;
|
|
66462
66615
|
} else if (flags & 4 /* BranchLabel */) {
|
|
66463
|
-
return every(flow.
|
|
66616
|
+
return every(flow.antecedent, (f) => isPostSuperFlowNode(
|
|
66464
66617
|
f,
|
|
66465
66618
|
/*noCacheCheck*/
|
|
66466
66619
|
false
|
|
66467
66620
|
));
|
|
66468
66621
|
} else if (flags & 8 /* LoopLabel */) {
|
|
66469
|
-
flow = flow.
|
|
66622
|
+
flow = flow.antecedent[0];
|
|
66470
66623
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66471
|
-
const target = flow.target;
|
|
66472
|
-
const saveAntecedents = target.
|
|
66473
|
-
target.
|
|
66624
|
+
const target = flow.node.target;
|
|
66625
|
+
const saveAntecedents = target.antecedent;
|
|
66626
|
+
target.antecedent = flow.node.antecedents;
|
|
66474
66627
|
const result = isPostSuperFlowNode(
|
|
66475
66628
|
flow.antecedent,
|
|
66476
66629
|
/*noCacheCheck*/
|
|
66477
66630
|
false
|
|
66478
66631
|
);
|
|
66479
|
-
target.
|
|
66632
|
+
target.antecedent = saveAntecedents;
|
|
66480
66633
|
return result;
|
|
66481
66634
|
} else {
|
|
66482
66635
|
return !!(flags & 1 /* Unreachable */);
|
|
@@ -66568,8 +66721,8 @@ function createTypeChecker(host) {
|
|
|
66568
66721
|
} else if (flags & 128 /* SwitchClause */) {
|
|
66569
66722
|
type = getTypeAtSwitchClause(flow);
|
|
66570
66723
|
} else if (flags & 12 /* Label */) {
|
|
66571
|
-
if (flow.
|
|
66572
|
-
flow = flow.
|
|
66724
|
+
if (flow.antecedent.length === 1) {
|
|
66725
|
+
flow = flow.antecedent[0];
|
|
66573
66726
|
continue;
|
|
66574
66727
|
}
|
|
66575
66728
|
type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow);
|
|
@@ -66580,11 +66733,11 @@ function createTypeChecker(host) {
|
|
|
66580
66733
|
continue;
|
|
66581
66734
|
}
|
|
66582
66735
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66583
|
-
const target = flow.target;
|
|
66584
|
-
const saveAntecedents = target.
|
|
66585
|
-
target.
|
|
66736
|
+
const target = flow.node.target;
|
|
66737
|
+
const saveAntecedents = target.antecedent;
|
|
66738
|
+
target.antecedent = flow.node.antecedents;
|
|
66586
66739
|
type = getTypeAtFlowNode(flow.antecedent);
|
|
66587
|
-
target.
|
|
66740
|
+
target.antecedent = saveAntecedents;
|
|
66588
66741
|
} else if (flags & 2 /* Start */) {
|
|
66589
66742
|
const container = flow.node;
|
|
66590
66743
|
if (container && container !== flowContainer && reference.kind !== 211 /* PropertyAccessExpression */ && reference.kind !== 212 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 219 /* ArrowFunction */)) {
|
|
@@ -66738,26 +66891,26 @@ function createTypeChecker(host) {
|
|
|
66738
66891
|
return createFlowType(narrowedType, isIncomplete(flowType));
|
|
66739
66892
|
}
|
|
66740
66893
|
function getTypeAtSwitchClause(flow) {
|
|
66741
|
-
const expr = skipParentheses(flow.switchStatement.expression);
|
|
66894
|
+
const expr = skipParentheses(flow.node.switchStatement.expression);
|
|
66742
66895
|
const flowType = getTypeAtFlowNode(flow.antecedent);
|
|
66743
66896
|
let type = getTypeFromFlowType(flowType);
|
|
66744
66897
|
if (isMatchingReference(reference, expr)) {
|
|
66745
|
-
type = narrowTypeBySwitchOnDiscriminant(type, flow.
|
|
66898
|
+
type = narrowTypeBySwitchOnDiscriminant(type, flow.node);
|
|
66746
66899
|
} else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
|
|
66747
|
-
type = narrowTypeBySwitchOnTypeOf(type, flow.
|
|
66900
|
+
type = narrowTypeBySwitchOnTypeOf(type, flow.node);
|
|
66748
66901
|
} else if (expr.kind === 112 /* TrueKeyword */) {
|
|
66749
|
-
type = narrowTypeBySwitchOnTrue(type, flow.
|
|
66902
|
+
type = narrowTypeBySwitchOnTrue(type, flow.node);
|
|
66750
66903
|
} else {
|
|
66751
66904
|
if (strictNullChecks) {
|
|
66752
66905
|
if (optionalChainContainsReference(expr, reference)) {
|
|
66753
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.
|
|
66906
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
|
|
66754
66907
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
66755
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.
|
|
66908
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
|
|
66756
66909
|
}
|
|
66757
66910
|
}
|
|
66758
66911
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
66759
66912
|
if (access) {
|
|
66760
|
-
type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.
|
|
66913
|
+
type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.node);
|
|
66761
66914
|
}
|
|
66762
66915
|
}
|
|
66763
66916
|
return createFlowType(type, isIncomplete(flowType));
|
|
@@ -66767,8 +66920,8 @@ function createTypeChecker(host) {
|
|
|
66767
66920
|
let subtypeReduction = false;
|
|
66768
66921
|
let seenIncomplete = false;
|
|
66769
66922
|
let bypassFlow;
|
|
66770
|
-
for (const antecedent of flow.
|
|
66771
|
-
if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) {
|
|
66923
|
+
for (const antecedent of flow.antecedent) {
|
|
66924
|
+
if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.node.clauseStart === antecedent.node.clauseEnd) {
|
|
66772
66925
|
bypassFlow = antecedent;
|
|
66773
66926
|
continue;
|
|
66774
66927
|
}
|
|
@@ -66788,7 +66941,7 @@ function createTypeChecker(host) {
|
|
|
66788
66941
|
if (bypassFlow) {
|
|
66789
66942
|
const flowType = getTypeAtFlowNode(bypassFlow);
|
|
66790
66943
|
const type = getTypeFromFlowType(flowType);
|
|
66791
|
-
if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
|
|
66944
|
+
if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.node.switchStatement)) {
|
|
66792
66945
|
if (type === declaredType && declaredType === initialType) {
|
|
66793
66946
|
return type;
|
|
66794
66947
|
}
|
|
@@ -66826,7 +66979,7 @@ function createTypeChecker(host) {
|
|
|
66826
66979
|
const antecedentTypes = [];
|
|
66827
66980
|
let subtypeReduction = false;
|
|
66828
66981
|
let firstAntecedentType;
|
|
66829
|
-
for (const antecedent of flow.
|
|
66982
|
+
for (const antecedent of flow.antecedent) {
|
|
66830
66983
|
let flowType;
|
|
66831
66984
|
if (!firstAntecedentType) {
|
|
66832
66985
|
flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
|
|
@@ -66950,15 +67103,15 @@ function createTypeChecker(host) {
|
|
|
66950
67103
|
}
|
|
66951
67104
|
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeByEquality(t, operator, value, assumeTrue));
|
|
66952
67105
|
}
|
|
66953
|
-
function narrowTypeBySwitchOnDiscriminantProperty(type, access,
|
|
66954
|
-
if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
|
|
66955
|
-
const clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd);
|
|
67106
|
+
function narrowTypeBySwitchOnDiscriminantProperty(type, access, data) {
|
|
67107
|
+
if (data.clauseStart < data.clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
|
|
67108
|
+
const clauseTypes = getSwitchClauseTypes(data.switchStatement).slice(data.clauseStart, data.clauseEnd);
|
|
66956
67109
|
const candidate = getUnionType(map(clauseTypes, (t) => getConstituentTypeForKeyType(type, t) || unknownType));
|
|
66957
67110
|
if (candidate !== unknownType) {
|
|
66958
67111
|
return candidate;
|
|
66959
67112
|
}
|
|
66960
67113
|
}
|
|
66961
|
-
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t,
|
|
67114
|
+
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, data));
|
|
66962
67115
|
}
|
|
66963
67116
|
function narrowTypeByTruthiness(type, expr, assumeTrue) {
|
|
66964
67117
|
if (isMatchingReference(reference, expr)) {
|
|
@@ -67203,11 +67356,11 @@ function createTypeChecker(host) {
|
|
|
67203
67356
|
function narrowTypeByLiteralExpression(type, literal, assumeTrue) {
|
|
67204
67357
|
return assumeTrue ? narrowTypeByTypeName(type, literal.text) : getAdjustedTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
|
|
67205
67358
|
}
|
|
67206
|
-
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
|
|
67359
|
+
function narrowTypeBySwitchOptionalChainContainment(type, { switchStatement, clauseStart, clauseEnd }, clauseCheck) {
|
|
67207
67360
|
const everyClauseChecks = clauseStart !== clauseEnd && every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
|
|
67208
67361
|
return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
67209
67362
|
}
|
|
67210
|
-
function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
|
|
67363
|
+
function narrowTypeBySwitchOnDiscriminant(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67211
67364
|
const switchTypes = getSwitchClauseTypes(switchStatement);
|
|
67212
67365
|
if (!switchTypes.length) {
|
|
67213
67366
|
return type;
|
|
@@ -67280,7 +67433,7 @@ function createTypeChecker(host) {
|
|
|
67280
67433
|
)
|
|
67281
67434
|
));
|
|
67282
67435
|
}
|
|
67283
|
-
function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
67436
|
+
function narrowTypeBySwitchOnTypeOf(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67284
67437
|
const witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
|
|
67285
67438
|
if (!witnesses) {
|
|
67286
67439
|
return type;
|
|
@@ -67294,7 +67447,7 @@ function createTypeChecker(host) {
|
|
|
67294
67447
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
67295
67448
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
67296
67449
|
}
|
|
67297
|
-
function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
|
|
67450
|
+
function narrowTypeBySwitchOnTrue(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67298
67451
|
const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
|
|
67299
67452
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
67300
67453
|
for (let i = 0; i < clauseStart; i++) {
|
|
@@ -74588,20 +74741,18 @@ function createTypeChecker(host) {
|
|
|
74588
74741
|
});
|
|
74589
74742
|
}
|
|
74590
74743
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
74591
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode ||
|
|
74592
|
-
|
|
74593
|
-
|
|
74594
|
-
|
|
74595
|
-
|
|
74596
|
-
|
|
74744
|
+
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
74745
|
+
2 /* Start */,
|
|
74746
|
+
/*node*/
|
|
74747
|
+
void 0,
|
|
74748
|
+
/*antecedent*/
|
|
74749
|
+
void 0
|
|
74750
|
+
);
|
|
74751
|
+
const trueCondition = createFlowNode(32 /* TrueCondition */, expr, antecedent);
|
|
74597
74752
|
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
74598
74753
|
if (trueType2 === initType)
|
|
74599
74754
|
return void 0;
|
|
74600
|
-
const falseCondition =
|
|
74601
|
-
flags: 64 /* FalseCondition */,
|
|
74602
|
-
antecedent,
|
|
74603
|
-
node: expr
|
|
74604
|
-
};
|
|
74755
|
+
const falseCondition = createFlowNode(64 /* FalseCondition */, expr, antecedent);
|
|
74605
74756
|
const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
|
|
74606
74757
|
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
74607
74758
|
}
|
|
@@ -75995,7 +76146,7 @@ function createTypeChecker(host) {
|
|
|
75995
76146
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
75996
76147
|
return getTemplateLiteralType(texts, types);
|
|
75997
76148
|
}
|
|
75998
|
-
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
|
|
76149
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
|
|
75999
76150
|
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
76000
76151
|
}
|
|
76001
76152
|
function isTemplateLiteralContextualType(type) {
|
|
@@ -80900,14 +81051,14 @@ function createTypeChecker(host) {
|
|
|
80900
81051
|
let autoValue = 0;
|
|
80901
81052
|
let previous;
|
|
80902
81053
|
for (const member of node.members) {
|
|
80903
|
-
const
|
|
80904
|
-
getNodeLinks(member).enumMemberValue =
|
|
80905
|
-
autoValue = typeof value === "number" ? value + 1 : void 0;
|
|
81054
|
+
const result = computeEnumMemberValue(member, autoValue, previous);
|
|
81055
|
+
getNodeLinks(member).enumMemberValue = result;
|
|
81056
|
+
autoValue = typeof result.value === "number" ? result.value + 1 : void 0;
|
|
80906
81057
|
previous = member;
|
|
80907
81058
|
}
|
|
80908
81059
|
}
|
|
80909
81060
|
}
|
|
80910
|
-
function
|
|
81061
|
+
function computeEnumMemberValue(member, autoValue, previous) {
|
|
80911
81062
|
if (isComputedNonLiteralName(member.name)) {
|
|
80912
81063
|
error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
80913
81064
|
} else {
|
|
@@ -80917,34 +81068,43 @@ function createTypeChecker(host) {
|
|
|
80917
81068
|
}
|
|
80918
81069
|
}
|
|
80919
81070
|
if (member.initializer) {
|
|
80920
|
-
return
|
|
81071
|
+
return computeConstantEnumMemberValue(member);
|
|
80921
81072
|
}
|
|
80922
81073
|
if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
|
|
80923
|
-
return
|
|
81074
|
+
return evaluatorResult(
|
|
81075
|
+
/*value*/
|
|
81076
|
+
void 0
|
|
81077
|
+
);
|
|
80924
81078
|
}
|
|
80925
81079
|
if (autoValue === void 0) {
|
|
80926
81080
|
error(member.name, Diagnostics.Enum_member_must_have_initializer);
|
|
80927
|
-
return
|
|
80928
|
-
|
|
80929
|
-
|
|
80930
|
-
error(
|
|
80931
|
-
member.name,
|
|
80932
|
-
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
81081
|
+
return evaluatorResult(
|
|
81082
|
+
/*value*/
|
|
81083
|
+
void 0
|
|
80933
81084
|
);
|
|
80934
81085
|
}
|
|
80935
|
-
|
|
81086
|
+
if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer)) {
|
|
81087
|
+
const prevValue = getEnumMemberValue(previous);
|
|
81088
|
+
if (!(typeof prevValue.value === "number" && !prevValue.resolvedOtherFiles)) {
|
|
81089
|
+
error(
|
|
81090
|
+
member.name,
|
|
81091
|
+
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
81092
|
+
);
|
|
81093
|
+
}
|
|
81094
|
+
}
|
|
81095
|
+
return evaluatorResult(autoValue);
|
|
80936
81096
|
}
|
|
80937
|
-
function
|
|
81097
|
+
function computeConstantEnumMemberValue(member) {
|
|
80938
81098
|
const isConstEnum = isEnumConst(member.parent);
|
|
80939
81099
|
const initializer = member.initializer;
|
|
80940
|
-
const
|
|
80941
|
-
if (value !== void 0) {
|
|
80942
|
-
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
|
|
81100
|
+
const result = evaluate(initializer, member);
|
|
81101
|
+
if (result.value !== void 0) {
|
|
81102
|
+
if (isConstEnum && typeof result.value === "number" && !isFinite(result.value)) {
|
|
80943
81103
|
error(
|
|
80944
81104
|
initializer,
|
|
80945
|
-
isNaN(value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value
|
|
81105
|
+
isNaN(result.value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value
|
|
80946
81106
|
);
|
|
80947
|
-
} else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString
|
|
81107
|
+
} else if (getIsolatedModules(compilerOptions) && typeof result.value === "string" && !result.isSyntacticallyString) {
|
|
80948
81108
|
error(
|
|
80949
81109
|
initializer,
|
|
80950
81110
|
Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
|
|
@@ -80958,19 +81118,7 @@ function createTypeChecker(host) {
|
|
|
80958
81118
|
} else {
|
|
80959
81119
|
checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
|
|
80960
81120
|
}
|
|
80961
|
-
return
|
|
80962
|
-
}
|
|
80963
|
-
function isSyntacticallyNumericConstant(expr) {
|
|
80964
|
-
expr = skipOuterExpressions(expr);
|
|
80965
|
-
switch (expr.kind) {
|
|
80966
|
-
case 224 /* PrefixUnaryExpression */:
|
|
80967
|
-
return isSyntacticallyNumericConstant(expr.operand);
|
|
80968
|
-
case 226 /* BinaryExpression */:
|
|
80969
|
-
return isSyntacticallyNumericConstant(expr.left) && isSyntacticallyNumericConstant(expr.right);
|
|
80970
|
-
case 9 /* NumericLiteral */:
|
|
80971
|
-
return true;
|
|
80972
|
-
}
|
|
80973
|
-
return false;
|
|
81121
|
+
return result;
|
|
80974
81122
|
}
|
|
80975
81123
|
function evaluateEntityNameExpression(expr, location) {
|
|
80976
81124
|
const symbol = resolveEntityName(
|
|
@@ -80980,7 +81128,10 @@ function createTypeChecker(host) {
|
|
|
80980
81128
|
true
|
|
80981
81129
|
);
|
|
80982
81130
|
if (!symbol)
|
|
80983
|
-
return
|
|
81131
|
+
return evaluatorResult(
|
|
81132
|
+
/*value*/
|
|
81133
|
+
void 0
|
|
81134
|
+
);
|
|
80984
81135
|
if (expr.kind === 80 /* Identifier */) {
|
|
80985
81136
|
const identifier = expr;
|
|
80986
81137
|
if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
|
|
@@ -80989,7 +81140,11 @@ function createTypeChecker(host) {
|
|
|
80989
81140
|
/*diagnostic*/
|
|
80990
81141
|
void 0
|
|
80991
81142
|
)) {
|
|
80992
|
-
return
|
|
81143
|
+
return evaluatorResult(
|
|
81144
|
+
+identifier.escapedText,
|
|
81145
|
+
/*isSyntacticallyString*/
|
|
81146
|
+
false
|
|
81147
|
+
);
|
|
80993
81148
|
}
|
|
80994
81149
|
}
|
|
80995
81150
|
if (symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80998,9 +81153,23 @@ function createTypeChecker(host) {
|
|
|
80998
81153
|
if (isConstantVariable(symbol)) {
|
|
80999
81154
|
const declaration = symbol.valueDeclaration;
|
|
81000
81155
|
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
|
81001
|
-
|
|
81156
|
+
const result = evaluate(declaration.initializer, declaration);
|
|
81157
|
+
if (location && getSourceFileOfNode(location) !== getSourceFileOfNode(declaration)) {
|
|
81158
|
+
return evaluatorResult(
|
|
81159
|
+
result.value,
|
|
81160
|
+
/*isSyntacticallyString*/
|
|
81161
|
+
false,
|
|
81162
|
+
/*resolvedOtherFiles*/
|
|
81163
|
+
true
|
|
81164
|
+
);
|
|
81165
|
+
}
|
|
81166
|
+
return result;
|
|
81002
81167
|
}
|
|
81003
81168
|
}
|
|
81169
|
+
return evaluatorResult(
|
|
81170
|
+
/*value*/
|
|
81171
|
+
void 0
|
|
81172
|
+
);
|
|
81004
81173
|
}
|
|
81005
81174
|
function evaluateElementAccessExpression(expr, location) {
|
|
81006
81175
|
const root = expr.expression;
|
|
@@ -81015,20 +81184,31 @@ function createTypeChecker(host) {
|
|
|
81015
81184
|
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
81016
81185
|
const member = rootSymbol.exports.get(name);
|
|
81017
81186
|
if (member) {
|
|
81187
|
+
Debug.assert(getSourceFileOfNode(member.valueDeclaration) === getSourceFileOfNode(rootSymbol.valueDeclaration));
|
|
81018
81188
|
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
81019
81189
|
}
|
|
81020
81190
|
}
|
|
81021
81191
|
}
|
|
81192
|
+
return evaluatorResult(
|
|
81193
|
+
/*value*/
|
|
81194
|
+
void 0
|
|
81195
|
+
);
|
|
81022
81196
|
}
|
|
81023
81197
|
function evaluateEnumMember(expr, symbol, location) {
|
|
81024
81198
|
const declaration = symbol.valueDeclaration;
|
|
81025
81199
|
if (!declaration || declaration === location) {
|
|
81026
81200
|
error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
|
|
81027
|
-
return
|
|
81201
|
+
return evaluatorResult(
|
|
81202
|
+
/*value*/
|
|
81203
|
+
void 0
|
|
81204
|
+
);
|
|
81028
81205
|
}
|
|
81029
81206
|
if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
|
81030
81207
|
error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
|
81031
|
-
return
|
|
81208
|
+
return evaluatorResult(
|
|
81209
|
+
/*value*/
|
|
81210
|
+
0
|
|
81211
|
+
);
|
|
81032
81212
|
}
|
|
81033
81213
|
return getEnumMemberValue(declaration);
|
|
81034
81214
|
}
|
|
@@ -83169,7 +83349,10 @@ function createTypeChecker(host) {
|
|
|
83169
83349
|
}
|
|
83170
83350
|
function getEnumMemberValue(node) {
|
|
83171
83351
|
computeEnumMemberValues(node.parent);
|
|
83172
|
-
return getNodeLinks(node).enumMemberValue
|
|
83352
|
+
return getNodeLinks(node).enumMemberValue ?? evaluatorResult(
|
|
83353
|
+
/*value*/
|
|
83354
|
+
void 0
|
|
83355
|
+
);
|
|
83173
83356
|
}
|
|
83174
83357
|
function canHaveConstantValue(node) {
|
|
83175
83358
|
switch (node.kind) {
|
|
@@ -83182,13 +83365,13 @@ function createTypeChecker(host) {
|
|
|
83182
83365
|
}
|
|
83183
83366
|
function getConstantValue2(node) {
|
|
83184
83367
|
if (node.kind === 306 /* EnumMember */) {
|
|
83185
|
-
return getEnumMemberValue(node);
|
|
83368
|
+
return getEnumMemberValue(node).value;
|
|
83186
83369
|
}
|
|
83187
83370
|
const symbol = getNodeLinks(node).resolvedSymbol;
|
|
83188
83371
|
if (symbol && symbol.flags & 8 /* EnumMember */) {
|
|
83189
83372
|
const member = symbol.valueDeclaration;
|
|
83190
83373
|
if (isEnumConst(member.parent)) {
|
|
83191
|
-
return getEnumMemberValue(member);
|
|
83374
|
+
return getEnumMemberValue(member).value;
|
|
83192
83375
|
}
|
|
83193
83376
|
}
|
|
83194
83377
|
return void 0;
|
|
@@ -83563,6 +83746,10 @@ function createTypeChecker(host) {
|
|
|
83563
83746
|
const node = getParseTreeNode(nodeIn, canHaveConstantValue);
|
|
83564
83747
|
return node ? getConstantValue2(node) : void 0;
|
|
83565
83748
|
},
|
|
83749
|
+
getEnumMemberValue: (nodeIn) => {
|
|
83750
|
+
const node = getParseTreeNode(nodeIn, isEnumMember);
|
|
83751
|
+
return node ? getEnumMemberValue(node) : void 0;
|
|
83752
|
+
},
|
|
83566
83753
|
collectLinkedAliases,
|
|
83567
83754
|
getReferencedValueDeclaration,
|
|
83568
83755
|
getReferencedValueDeclarations,
|
|
@@ -89781,7 +89968,8 @@ function transformTypeScript(context) {
|
|
|
89781
89968
|
/*generateNameForComputedPropertyName*/
|
|
89782
89969
|
false
|
|
89783
89970
|
);
|
|
89784
|
-
const
|
|
89971
|
+
const evaluated = resolver.getEnumMemberValue(member);
|
|
89972
|
+
const valueExpression = transformEnumMemberDeclarationValue(member, evaluated == null ? void 0 : evaluated.value);
|
|
89785
89973
|
const innerAssignment = factory2.createAssignment(
|
|
89786
89974
|
factory2.createElementAccessExpression(
|
|
89787
89975
|
currentNamespaceContainerName,
|
|
@@ -89789,7 +89977,7 @@ function transformTypeScript(context) {
|
|
|
89789
89977
|
),
|
|
89790
89978
|
valueExpression
|
|
89791
89979
|
);
|
|
89792
|
-
const outerAssignment =
|
|
89980
|
+
const outerAssignment = typeof (evaluated == null ? void 0 : evaluated.value) === "string" || (evaluated == null ? void 0 : evaluated.isSyntacticallyString) ? innerAssignment : factory2.createAssignment(
|
|
89793
89981
|
factory2.createElementAccessExpression(
|
|
89794
89982
|
currentNamespaceContainerName,
|
|
89795
89983
|
innerAssignment
|
|
@@ -89806,10 +89994,9 @@ function transformTypeScript(context) {
|
|
|
89806
89994
|
member
|
|
89807
89995
|
);
|
|
89808
89996
|
}
|
|
89809
|
-
function transformEnumMemberDeclarationValue(member) {
|
|
89810
|
-
|
|
89811
|
-
|
|
89812
|
-
return typeof value === "string" ? factory2.createStringLiteral(value) : value < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-value)) : factory2.createNumericLiteral(value);
|
|
89997
|
+
function transformEnumMemberDeclarationValue(member, constantValue) {
|
|
89998
|
+
if (constantValue !== void 0) {
|
|
89999
|
+
return typeof constantValue === "string" ? factory2.createStringLiteral(constantValue) : constantValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-constantValue)) : factory2.createNumericLiteral(constantValue);
|
|
89813
90000
|
} else {
|
|
89814
90001
|
enableSubstitutionForNonQualifiedEnumMembers();
|
|
89815
90002
|
if (member.initializer) {
|
|
@@ -111149,6 +111336,7 @@ var notImplementedResolver = {
|
|
|
111149
111336
|
isEntityNameVisible: notImplemented,
|
|
111150
111337
|
// Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
|
|
111151
111338
|
getConstantValue: notImplemented,
|
|
111339
|
+
getEnumMemberValue: notImplemented,
|
|
111152
111340
|
getReferencedValueDeclaration: notImplemented,
|
|
111153
111341
|
getReferencedValueDeclarations: notImplemented,
|
|
111154
111342
|
getTypeReferenceSerializationKind: notImplemented,
|
|
@@ -126034,7 +126222,7 @@ function verboseReportProjectStatus(state, configFileName, status) {
|
|
|
126034
126222
|
}
|
|
126035
126223
|
}
|
|
126036
126224
|
|
|
126037
|
-
// src/
|
|
126225
|
+
// src/compiler/executeCommandLine.ts
|
|
126038
126226
|
function countLines(program) {
|
|
126039
126227
|
const counts2 = getCountsMap();
|
|
126040
126228
|
forEach(program.getSourceFiles(), (file) => {
|