typescript 5.5.0-dev.20240402 → 5.5.0-dev.20240405
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 +552 -272
- package/lib/typescript.d.ts +0 -56
- package/lib/typescript.js +1735 -302
- package/package.json +2 -3
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.20240405`;
|
|
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
|
}
|
|
@@ -11747,8 +11749,11 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
|
|
|
11747
11749
|
if (includeJsDoc && hasJSDocNodes(node)) {
|
|
11748
11750
|
return getTokenPosOfNode(node.jsDoc[0], sourceFile);
|
|
11749
11751
|
}
|
|
11750
|
-
if (node.kind === 352 /* SyntaxList */
|
|
11751
|
-
|
|
11752
|
+
if (node.kind === 352 /* SyntaxList */) {
|
|
11753
|
+
const first2 = firstOrUndefined(getNodeChildren(node));
|
|
11754
|
+
if (first2) {
|
|
11755
|
+
return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
|
|
11756
|
+
}
|
|
11752
11757
|
}
|
|
11753
11758
|
return skipTrivia(
|
|
11754
11759
|
(sourceFile || getSourceFileOfNode(node)).text,
|
|
@@ -17687,79 +17692,81 @@ function replaceFirstStar(s, replacement) {
|
|
|
17687
17692
|
function getNameFromImportAttribute(node) {
|
|
17688
17693
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17689
17694
|
}
|
|
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;
|
|
17695
|
+
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false) {
|
|
17696
|
+
return { value, isSyntacticallyString, resolvedOtherFiles };
|
|
17703
17697
|
}
|
|
17704
17698
|
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
17705
17699
|
function evaluate(expr, location) {
|
|
17700
|
+
let isSyntacticallyString = false;
|
|
17701
|
+
let resolvedOtherFiles = false;
|
|
17702
|
+
expr = skipParentheses(expr);
|
|
17706
17703
|
switch (expr.kind) {
|
|
17707
17704
|
case 224 /* PrefixUnaryExpression */:
|
|
17708
|
-
const
|
|
17709
|
-
|
|
17705
|
+
const result = evaluate(expr.operand, location);
|
|
17706
|
+
resolvedOtherFiles = result.resolvedOtherFiles;
|
|
17707
|
+
if (typeof result.value === "number") {
|
|
17710
17708
|
switch (expr.operator) {
|
|
17711
17709
|
case 40 /* PlusToken */:
|
|
17712
|
-
return value;
|
|
17710
|
+
return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17713
17711
|
case 41 /* MinusToken */:
|
|
17714
|
-
return -value;
|
|
17712
|
+
return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17715
17713
|
case 55 /* TildeToken */:
|
|
17716
|
-
return ~value;
|
|
17714
|
+
return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17717
17715
|
}
|
|
17718
17716
|
}
|
|
17719
17717
|
break;
|
|
17720
|
-
case 226 /* BinaryExpression */:
|
|
17718
|
+
case 226 /* BinaryExpression */: {
|
|
17721
17719
|
const left = evaluate(expr.left, location);
|
|
17722
17720
|
const right = evaluate(expr.right, location);
|
|
17723
|
-
|
|
17721
|
+
isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
|
|
17722
|
+
resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
|
|
17723
|
+
if (typeof left.value === "number" && typeof right.value === "number") {
|
|
17724
17724
|
switch (expr.operatorToken.kind) {
|
|
17725
17725
|
case 52 /* BarToken */:
|
|
17726
|
-
return left | right;
|
|
17726
|
+
return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17727
17727
|
case 51 /* AmpersandToken */:
|
|
17728
|
-
return left & right;
|
|
17728
|
+
return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17729
17729
|
case 49 /* GreaterThanGreaterThanToken */:
|
|
17730
|
-
return left >> right;
|
|
17730
|
+
return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17731
17731
|
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
17732
|
-
return left >>> right;
|
|
17732
|
+
return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17733
17733
|
case 48 /* LessThanLessThanToken */:
|
|
17734
|
-
return left << right;
|
|
17734
|
+
return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17735
17735
|
case 53 /* CaretToken */:
|
|
17736
|
-
return left ^ right;
|
|
17736
|
+
return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17737
17737
|
case 42 /* AsteriskToken */:
|
|
17738
|
-
return left * right;
|
|
17738
|
+
return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17739
17739
|
case 44 /* SlashToken */:
|
|
17740
|
-
return left / right;
|
|
17740
|
+
return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17741
17741
|
case 40 /* PlusToken */:
|
|
17742
|
-
return left + right;
|
|
17742
|
+
return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17743
17743
|
case 41 /* MinusToken */:
|
|
17744
|
-
return left - right;
|
|
17744
|
+
return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17745
17745
|
case 45 /* PercentToken */:
|
|
17746
|
-
return left % right;
|
|
17746
|
+
return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17747
17747
|
case 43 /* AsteriskAsteriskToken */:
|
|
17748
|
-
return left ** right;
|
|
17748
|
+
return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17749
17749
|
}
|
|
17750
|
-
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17751
|
-
return
|
|
17750
|
+
} else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17751
|
+
return evaluatorResult(
|
|
17752
|
+
"" + left.value + right.value,
|
|
17753
|
+
isSyntacticallyString,
|
|
17754
|
+
resolvedOtherFiles
|
|
17755
|
+
);
|
|
17752
17756
|
}
|
|
17753
17757
|
break;
|
|
17758
|
+
}
|
|
17754
17759
|
case 11 /* StringLiteral */:
|
|
17755
17760
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17756
|
-
return
|
|
17761
|
+
return evaluatorResult(
|
|
17762
|
+
expr.text,
|
|
17763
|
+
/*isSyntacticallyString*/
|
|
17764
|
+
true
|
|
17765
|
+
);
|
|
17757
17766
|
case 228 /* TemplateExpression */:
|
|
17758
17767
|
return evaluateTemplateExpression(expr, location);
|
|
17759
17768
|
case 9 /* NumericLiteral */:
|
|
17760
|
-
return +expr.text;
|
|
17761
|
-
case 217 /* ParenthesizedExpression */:
|
|
17762
|
-
return evaluate(expr.expression, location);
|
|
17769
|
+
return evaluatorResult(+expr.text);
|
|
17763
17770
|
case 80 /* Identifier */:
|
|
17764
17771
|
return evaluateEntityNameExpression(expr, location);
|
|
17765
17772
|
case 211 /* PropertyAccessExpression */:
|
|
@@ -17770,19 +17777,36 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17770
17777
|
case 212 /* ElementAccessExpression */:
|
|
17771
17778
|
return evaluateElementAccessExpression(expr, location);
|
|
17772
17779
|
}
|
|
17773
|
-
return
|
|
17780
|
+
return evaluatorResult(
|
|
17781
|
+
/*value*/
|
|
17782
|
+
void 0,
|
|
17783
|
+
isSyntacticallyString,
|
|
17784
|
+
resolvedOtherFiles
|
|
17785
|
+
);
|
|
17774
17786
|
}
|
|
17775
17787
|
function evaluateTemplateExpression(expr, location) {
|
|
17776
17788
|
let result = expr.head.text;
|
|
17789
|
+
let resolvedOtherFiles = false;
|
|
17777
17790
|
for (const span of expr.templateSpans) {
|
|
17778
|
-
const
|
|
17779
|
-
if (value === void 0) {
|
|
17780
|
-
return
|
|
17791
|
+
const spanResult = evaluate(span.expression, location);
|
|
17792
|
+
if (spanResult.value === void 0) {
|
|
17793
|
+
return evaluatorResult(
|
|
17794
|
+
/*value*/
|
|
17795
|
+
void 0,
|
|
17796
|
+
/*isSyntacticallyString*/
|
|
17797
|
+
true
|
|
17798
|
+
);
|
|
17781
17799
|
}
|
|
17782
|
-
result += value;
|
|
17800
|
+
result += spanResult.value;
|
|
17783
17801
|
result += span.literal.text;
|
|
17802
|
+
resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
|
|
17784
17803
|
}
|
|
17785
|
-
return
|
|
17804
|
+
return evaluatorResult(
|
|
17805
|
+
result,
|
|
17806
|
+
/*isSyntacticallyString*/
|
|
17807
|
+
true,
|
|
17808
|
+
resolvedOtherFiles
|
|
17809
|
+
);
|
|
17786
17810
|
}
|
|
17787
17811
|
return evaluate;
|
|
17788
17812
|
}
|
|
@@ -21926,7 +21950,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21926
21950
|
}
|
|
21927
21951
|
function createSyntaxList(children) {
|
|
21928
21952
|
const node = createBaseNode(352 /* SyntaxList */);
|
|
21929
|
-
node
|
|
21953
|
+
setNodeChildren(node, children);
|
|
21930
21954
|
return node;
|
|
21931
21955
|
}
|
|
21932
21956
|
function createNotEmittedStatement(original) {
|
|
@@ -24703,6 +24727,19 @@ function isJSDocImportTag(node) {
|
|
|
24703
24727
|
return node.kind === 351 /* JSDocImportTag */;
|
|
24704
24728
|
}
|
|
24705
24729
|
|
|
24730
|
+
// src/compiler/factory/nodeChildren.ts
|
|
24731
|
+
var nodeChildren = /* @__PURE__ */ new WeakMap();
|
|
24732
|
+
function getNodeChildren(node) {
|
|
24733
|
+
return nodeChildren.get(node);
|
|
24734
|
+
}
|
|
24735
|
+
function setNodeChildren(node, children) {
|
|
24736
|
+
nodeChildren.set(node, children);
|
|
24737
|
+
return children;
|
|
24738
|
+
}
|
|
24739
|
+
function unsetNodeChildren(node) {
|
|
24740
|
+
nodeChildren.delete(node);
|
|
24741
|
+
}
|
|
24742
|
+
|
|
24706
24743
|
// src/compiler/factory/utilities.ts
|
|
24707
24744
|
function createEmptyExports(factory2) {
|
|
24708
24745
|
return factory2.createExportDeclaration(
|
|
@@ -33334,9 +33371,7 @@ var IncrementalParser;
|
|
|
33334
33371
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33335
33372
|
text = oldText.substring(node.pos, node.end);
|
|
33336
33373
|
}
|
|
33337
|
-
|
|
33338
|
-
node._children = void 0;
|
|
33339
|
-
}
|
|
33374
|
+
unsetNodeChildren(node);
|
|
33340
33375
|
setTextRangePosEnd(node, node.pos + delta, node.end + delta);
|
|
33341
33376
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33342
33377
|
Debug.assert(text === newText.substring(node.pos, node.end));
|
|
@@ -33350,7 +33385,6 @@ var IncrementalParser;
|
|
|
33350
33385
|
checkNodePositions(node, aggressiveChecks);
|
|
33351
33386
|
}
|
|
33352
33387
|
function visitArray2(array) {
|
|
33353
|
-
array._children = void 0;
|
|
33354
33388
|
setTextRangePosEnd(array, array.pos + delta, array.end + delta);
|
|
33355
33389
|
for (const node of array) {
|
|
33356
33390
|
visitNode3(node);
|
|
@@ -33422,7 +33456,7 @@ var IncrementalParser;
|
|
|
33422
33456
|
const fullEnd = child.end;
|
|
33423
33457
|
if (fullEnd >= changeStart) {
|
|
33424
33458
|
child.intersectsChange = true;
|
|
33425
|
-
child
|
|
33459
|
+
unsetNodeChildren(child);
|
|
33426
33460
|
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33427
33461
|
forEachChild(child, visitNode3, visitArray2);
|
|
33428
33462
|
if (hasJSDocNodes(child)) {
|
|
@@ -33452,7 +33486,6 @@ var IncrementalParser;
|
|
|
33452
33486
|
const fullEnd = array.end;
|
|
33453
33487
|
if (fullEnd >= changeStart) {
|
|
33454
33488
|
array.intersectsChange = true;
|
|
33455
|
-
array._children = void 0;
|
|
33456
33489
|
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33457
33490
|
for (const node of array) {
|
|
33458
33491
|
visitNode3(node);
|
|
@@ -39595,9 +39628,8 @@ function getModuleInstanceStateForAliasTarget(specifier, visited) {
|
|
|
39595
39628
|
}
|
|
39596
39629
|
return 1 /* Instantiated */;
|
|
39597
39630
|
}
|
|
39598
|
-
function
|
|
39599
|
-
Debug.attachFlowNodeDebugInfo(node);
|
|
39600
|
-
return node;
|
|
39631
|
+
function createFlowNode(flags, node, antecedent) {
|
|
39632
|
+
return Debug.attachFlowNodeDebugInfo({ flags, id: 0, node, antecedent });
|
|
39601
39633
|
}
|
|
39602
39634
|
var binder = /* @__PURE__ */ createBinder();
|
|
39603
39635
|
function bindSourceFile(file, options) {
|
|
@@ -39631,14 +39663,27 @@ function createBinder() {
|
|
|
39631
39663
|
var preSwitchCaseFlow;
|
|
39632
39664
|
var activeLabelList;
|
|
39633
39665
|
var hasExplicitReturn;
|
|
39666
|
+
var hasFlowEffects;
|
|
39634
39667
|
var emitFlags;
|
|
39635
39668
|
var inStrictMode;
|
|
39636
39669
|
var inAssignmentPattern = false;
|
|
39637
39670
|
var symbolCount = 0;
|
|
39638
39671
|
var Symbol12;
|
|
39639
39672
|
var classifiableNames;
|
|
39640
|
-
var unreachableFlow =
|
|
39641
|
-
|
|
39673
|
+
var unreachableFlow = createFlowNode(
|
|
39674
|
+
1 /* Unreachable */,
|
|
39675
|
+
/*node*/
|
|
39676
|
+
void 0,
|
|
39677
|
+
/*antecedent*/
|
|
39678
|
+
void 0
|
|
39679
|
+
);
|
|
39680
|
+
var reportedUnreachableFlow = createFlowNode(
|
|
39681
|
+
1 /* Unreachable */,
|
|
39682
|
+
/*node*/
|
|
39683
|
+
void 0,
|
|
39684
|
+
/*antecedent*/
|
|
39685
|
+
void 0
|
|
39686
|
+
);
|
|
39642
39687
|
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
|
|
39643
39688
|
return bindSourceFile2;
|
|
39644
39689
|
function createDiagnosticForNode2(node, message, ...args) {
|
|
@@ -39690,6 +39735,7 @@ function createBinder() {
|
|
|
39690
39735
|
currentExceptionTarget = void 0;
|
|
39691
39736
|
activeLabelList = void 0;
|
|
39692
39737
|
hasExplicitReturn = false;
|
|
39738
|
+
hasFlowEffects = false;
|
|
39693
39739
|
inAssignmentPattern = false;
|
|
39694
39740
|
emitFlags = 0 /* None */;
|
|
39695
39741
|
}
|
|
@@ -39957,7 +40003,13 @@ function createBinder() {
|
|
|
39957
40003
|
const saveHasExplicitReturn = hasExplicitReturn;
|
|
39958
40004
|
const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */;
|
|
39959
40005
|
if (!isImmediatelyInvoked) {
|
|
39960
|
-
currentFlow =
|
|
40006
|
+
currentFlow = createFlowNode(
|
|
40007
|
+
2 /* Start */,
|
|
40008
|
+
/*node*/
|
|
40009
|
+
void 0,
|
|
40010
|
+
/*antecedent*/
|
|
40011
|
+
void 0
|
|
40012
|
+
);
|
|
39961
40013
|
if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
|
|
39962
40014
|
currentFlow.node = node;
|
|
39963
40015
|
}
|
|
@@ -40147,8 +40199,8 @@ function createBinder() {
|
|
|
40147
40199
|
function isNarrowingExpression(expr) {
|
|
40148
40200
|
switch (expr.kind) {
|
|
40149
40201
|
case 80 /* Identifier */:
|
|
40150
|
-
case 81 /* PrivateIdentifier */:
|
|
40151
40202
|
case 110 /* ThisKeyword */:
|
|
40203
|
+
return true;
|
|
40152
40204
|
case 211 /* PropertyAccessExpression */:
|
|
40153
40205
|
case 212 /* ElementAccessExpression */:
|
|
40154
40206
|
return containsNarrowableReference(expr);
|
|
@@ -40170,7 +40222,22 @@ function createBinder() {
|
|
|
40170
40222
|
return false;
|
|
40171
40223
|
}
|
|
40172
40224
|
function isNarrowableReference(expr) {
|
|
40173
|
-
|
|
40225
|
+
switch (expr.kind) {
|
|
40226
|
+
case 80 /* Identifier */:
|
|
40227
|
+
case 110 /* ThisKeyword */:
|
|
40228
|
+
case 108 /* SuperKeyword */:
|
|
40229
|
+
case 236 /* MetaProperty */:
|
|
40230
|
+
return true;
|
|
40231
|
+
case 211 /* PropertyAccessExpression */:
|
|
40232
|
+
case 217 /* ParenthesizedExpression */:
|
|
40233
|
+
case 235 /* NonNullExpression */:
|
|
40234
|
+
return isNarrowableReference(expr.expression);
|
|
40235
|
+
case 212 /* ElementAccessExpression */:
|
|
40236
|
+
return (isStringOrNumericLiteralLike(expr.argumentExpression) || isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression);
|
|
40237
|
+
case 226 /* BinaryExpression */:
|
|
40238
|
+
return expr.operatorToken.kind === 28 /* CommaToken */ && isNarrowableReference(expr.right) || isAssignmentOperator(expr.operatorToken.kind) && isLeftHandSideExpression(expr.left);
|
|
40239
|
+
}
|
|
40240
|
+
return false;
|
|
40174
40241
|
}
|
|
40175
40242
|
function containsNarrowableReference(expr) {
|
|
40176
40243
|
return isNarrowableReference(expr) || isOptionalChain(expr) && containsNarrowableReference(expr.expression);
|
|
@@ -40227,20 +40294,32 @@ function createBinder() {
|
|
|
40227
40294
|
return containsNarrowableReference(expr);
|
|
40228
40295
|
}
|
|
40229
40296
|
function createBranchLabel() {
|
|
40230
|
-
return
|
|
40297
|
+
return createFlowNode(
|
|
40298
|
+
4 /* BranchLabel */,
|
|
40299
|
+
/*node*/
|
|
40300
|
+
void 0,
|
|
40301
|
+
/*antecedent*/
|
|
40302
|
+
void 0
|
|
40303
|
+
);
|
|
40231
40304
|
}
|
|
40232
40305
|
function createLoopLabel() {
|
|
40233
|
-
return
|
|
40306
|
+
return createFlowNode(
|
|
40307
|
+
8 /* LoopLabel */,
|
|
40308
|
+
/*node*/
|
|
40309
|
+
void 0,
|
|
40310
|
+
/*antecedent*/
|
|
40311
|
+
void 0
|
|
40312
|
+
);
|
|
40234
40313
|
}
|
|
40235
40314
|
function createReduceLabel(target, antecedents, antecedent) {
|
|
40236
|
-
return
|
|
40315
|
+
return createFlowNode(1024 /* ReduceLabel */, { target, antecedents }, antecedent);
|
|
40237
40316
|
}
|
|
40238
40317
|
function setFlowNodeReferenced(flow) {
|
|
40239
40318
|
flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */;
|
|
40240
40319
|
}
|
|
40241
40320
|
function addAntecedent(label, antecedent) {
|
|
40242
|
-
if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.
|
|
40243
|
-
(label.
|
|
40321
|
+
if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.antecedent, antecedent)) {
|
|
40322
|
+
(label.antecedent || (label.antecedent = [])).push(antecedent);
|
|
40244
40323
|
setFlowNodeReferenced(antecedent);
|
|
40245
40324
|
}
|
|
40246
40325
|
}
|
|
@@ -40258,15 +40337,16 @@ function createBinder() {
|
|
|
40258
40337
|
return antecedent;
|
|
40259
40338
|
}
|
|
40260
40339
|
setFlowNodeReferenced(antecedent);
|
|
40261
|
-
return
|
|
40340
|
+
return createFlowNode(flags, expression, antecedent);
|
|
40262
40341
|
}
|
|
40263
40342
|
function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
|
|
40264
40343
|
setFlowNodeReferenced(antecedent);
|
|
40265
|
-
return
|
|
40344
|
+
return createFlowNode(128 /* SwitchClause */, { switchStatement, clauseStart, clauseEnd }, antecedent);
|
|
40266
40345
|
}
|
|
40267
40346
|
function createFlowMutation(flags, antecedent, node) {
|
|
40268
40347
|
setFlowNodeReferenced(antecedent);
|
|
40269
|
-
|
|
40348
|
+
hasFlowEffects = true;
|
|
40349
|
+
const result = createFlowNode(flags, node, antecedent);
|
|
40270
40350
|
if (currentExceptionTarget) {
|
|
40271
40351
|
addAntecedent(currentExceptionTarget, result);
|
|
40272
40352
|
}
|
|
@@ -40274,10 +40354,11 @@ function createBinder() {
|
|
|
40274
40354
|
}
|
|
40275
40355
|
function createFlowCall(antecedent, node) {
|
|
40276
40356
|
setFlowNodeReferenced(antecedent);
|
|
40277
|
-
|
|
40357
|
+
hasFlowEffects = true;
|
|
40358
|
+
return createFlowNode(512 /* Call */, node, antecedent);
|
|
40278
40359
|
}
|
|
40279
40360
|
function finishFlowLabel(flow) {
|
|
40280
|
-
const antecedents = flow.
|
|
40361
|
+
const antecedents = flow.antecedent;
|
|
40281
40362
|
if (!antecedents) {
|
|
40282
40363
|
return unreachableFlow;
|
|
40283
40364
|
}
|
|
@@ -40431,6 +40512,7 @@ function createBinder() {
|
|
|
40431
40512
|
}
|
|
40432
40513
|
}
|
|
40433
40514
|
currentFlow = unreachableFlow;
|
|
40515
|
+
hasFlowEffects = true;
|
|
40434
40516
|
}
|
|
40435
40517
|
function findActiveLabel(name) {
|
|
40436
40518
|
for (let label = activeLabelList; label; label = label.next) {
|
|
@@ -40445,6 +40527,7 @@ function createBinder() {
|
|
|
40445
40527
|
if (flowLabel) {
|
|
40446
40528
|
addAntecedent(flowLabel, currentFlow);
|
|
40447
40529
|
currentFlow = unreachableFlow;
|
|
40530
|
+
hasFlowEffects = true;
|
|
40448
40531
|
}
|
|
40449
40532
|
}
|
|
40450
40533
|
function bindBreakOrContinueStatement(node) {
|
|
@@ -40484,19 +40567,19 @@ function createBinder() {
|
|
|
40484
40567
|
currentExceptionTarget = saveExceptionTarget;
|
|
40485
40568
|
if (node.finallyBlock) {
|
|
40486
40569
|
const finallyLabel = createBranchLabel();
|
|
40487
|
-
finallyLabel.
|
|
40570
|
+
finallyLabel.antecedent = concatenate(concatenate(normalExitLabel.antecedent, exceptionLabel.antecedent), returnLabel.antecedent);
|
|
40488
40571
|
currentFlow = finallyLabel;
|
|
40489
40572
|
bind(node.finallyBlock);
|
|
40490
40573
|
if (currentFlow.flags & 1 /* Unreachable */) {
|
|
40491
40574
|
currentFlow = unreachableFlow;
|
|
40492
40575
|
} else {
|
|
40493
|
-
if (currentReturnTarget && returnLabel.
|
|
40494
|
-
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.
|
|
40576
|
+
if (currentReturnTarget && returnLabel.antecedent) {
|
|
40577
|
+
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedent, currentFlow));
|
|
40495
40578
|
}
|
|
40496
|
-
if (currentExceptionTarget && exceptionLabel.
|
|
40497
|
-
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.
|
|
40579
|
+
if (currentExceptionTarget && exceptionLabel.antecedent) {
|
|
40580
|
+
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedent, currentFlow));
|
|
40498
40581
|
}
|
|
40499
|
-
currentFlow = normalExitLabel.
|
|
40582
|
+
currentFlow = normalExitLabel.antecedent ? createReduceLabel(finallyLabel, normalExitLabel.antecedent, currentFlow) : unreachableFlow;
|
|
40500
40583
|
}
|
|
40501
40584
|
} else {
|
|
40502
40585
|
currentFlow = finishFlowLabel(normalExitLabel);
|
|
@@ -40512,7 +40595,7 @@ function createBinder() {
|
|
|
40512
40595
|
bind(node.caseBlock);
|
|
40513
40596
|
addAntecedent(postSwitchLabel, currentFlow);
|
|
40514
40597
|
const hasDefault = forEach(node.caseBlock.clauses, (c) => c.kind === 297 /* DefaultClause */);
|
|
40515
|
-
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.
|
|
40598
|
+
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedent;
|
|
40516
40599
|
if (!hasDefault) {
|
|
40517
40600
|
addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
|
|
40518
40601
|
}
|
|
@@ -40700,8 +40783,12 @@ function createBinder() {
|
|
|
40700
40783
|
if (isLogicalOrCoalescingBinaryOperator(operator) || isLogicalOrCoalescingAssignmentOperator(operator)) {
|
|
40701
40784
|
if (isTopLevelLogicalExpression(node)) {
|
|
40702
40785
|
const postExpressionLabel = createBranchLabel();
|
|
40786
|
+
const saveCurrentFlow = currentFlow;
|
|
40787
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40788
|
+
hasFlowEffects = false;
|
|
40703
40789
|
bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
|
|
40704
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40790
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40791
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40705
40792
|
} else {
|
|
40706
40793
|
bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
|
|
40707
40794
|
}
|
|
@@ -40773,6 +40860,9 @@ function createBinder() {
|
|
|
40773
40860
|
const trueLabel = createBranchLabel();
|
|
40774
40861
|
const falseLabel = createBranchLabel();
|
|
40775
40862
|
const postExpressionLabel = createBranchLabel();
|
|
40863
|
+
const saveCurrentFlow = currentFlow;
|
|
40864
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40865
|
+
hasFlowEffects = false;
|
|
40776
40866
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
40777
40867
|
currentFlow = finishFlowLabel(trueLabel);
|
|
40778
40868
|
bind(node.questionToken);
|
|
@@ -40782,7 +40872,8 @@ function createBinder() {
|
|
|
40782
40872
|
bind(node.colonToken);
|
|
40783
40873
|
bind(node.whenFalse);
|
|
40784
40874
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
40785
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40875
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40876
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40786
40877
|
}
|
|
40787
40878
|
function bindInitializedVariableFlow(node) {
|
|
40788
40879
|
const name = !isOmittedExpression(node) ? node.name : void 0;
|
|
@@ -40894,8 +40985,11 @@ function createBinder() {
|
|
|
40894
40985
|
function bindOptionalChainFlow(node) {
|
|
40895
40986
|
if (isTopLevelLogicalExpression(node)) {
|
|
40896
40987
|
const postExpressionLabel = createBranchLabel();
|
|
40988
|
+
const saveCurrentFlow = currentFlow;
|
|
40989
|
+
const saveHasFlowEffects = hasFlowEffects;
|
|
40897
40990
|
bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
|
|
40898
|
-
currentFlow = finishFlowLabel(postExpressionLabel);
|
|
40991
|
+
currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
|
|
40992
|
+
hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
|
|
40899
40993
|
} else {
|
|
40900
40994
|
bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
|
|
40901
40995
|
}
|
|
@@ -41116,7 +41210,13 @@ function createBinder() {
|
|
|
41116
41210
|
const host = typeAlias.parent.parent;
|
|
41117
41211
|
container = getEnclosingContainer(host) || file;
|
|
41118
41212
|
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
|
|
41119
|
-
currentFlow =
|
|
41213
|
+
currentFlow = createFlowNode(
|
|
41214
|
+
2 /* Start */,
|
|
41215
|
+
/*node*/
|
|
41216
|
+
void 0,
|
|
41217
|
+
/*antecedent*/
|
|
41218
|
+
void 0
|
|
41219
|
+
);
|
|
41120
41220
|
parent = typeAlias;
|
|
41121
41221
|
bind(typeAlias.typeExpression);
|
|
41122
41222
|
const declName = getNameOfDeclaration(typeAlias);
|
|
@@ -41186,7 +41286,13 @@ function createBinder() {
|
|
|
41186
41286
|
const enclosingBlockScopeContainer = host ? getEnclosingBlockScopeContainer(host) : void 0;
|
|
41187
41287
|
container = enclosingContainer || file;
|
|
41188
41288
|
blockScopeContainer = enclosingBlockScopeContainer || file;
|
|
41189
|
-
currentFlow =
|
|
41289
|
+
currentFlow = createFlowNode(
|
|
41290
|
+
2 /* Start */,
|
|
41291
|
+
/*node*/
|
|
41292
|
+
void 0,
|
|
41293
|
+
/*antecedent*/
|
|
41294
|
+
void 0
|
|
41295
|
+
);
|
|
41190
41296
|
parent = jsDocImportTag;
|
|
41191
41297
|
bind(jsDocImportTag.importClause);
|
|
41192
41298
|
}
|
|
@@ -43542,6 +43648,7 @@ function createTypeChecker(host) {
|
|
|
43542
43648
|
isArgumentsSymbol: (symbol) => symbol === argumentsSymbol,
|
|
43543
43649
|
isUnknownSymbol: (symbol) => symbol === unknownSymbol,
|
|
43544
43650
|
getMergedSymbol,
|
|
43651
|
+
symbolIsValue,
|
|
43545
43652
|
getDiagnostics,
|
|
43546
43653
|
getGlobalDiagnostics,
|
|
43547
43654
|
getRecursionIdentity,
|
|
@@ -47850,7 +47957,7 @@ function createTypeChecker(host) {
|
|
|
47850
47957
|
}
|
|
47851
47958
|
function getMeaningOfEntityNameReference(entityName) {
|
|
47852
47959
|
let meaning;
|
|
47853
|
-
if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
|
|
47960
|
+
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) {
|
|
47854
47961
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
47855
47962
|
} 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) {
|
|
47856
47963
|
meaning = 1920 /* Namespace */;
|
|
@@ -49110,68 +49217,7 @@ function createTypeChecker(host) {
|
|
|
49110
49217
|
/*skipUnionExpanding*/
|
|
49111
49218
|
true
|
|
49112
49219
|
)[0];
|
|
49113
|
-
|
|
49114
|
-
if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
|
|
49115
|
-
let pushFakeScope2 = function(kind2, addAll) {
|
|
49116
|
-
Debug.assert(context.enclosingDeclaration);
|
|
49117
|
-
let existingFakeScope;
|
|
49118
|
-
if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
|
|
49119
|
-
existingFakeScope = context.enclosingDeclaration;
|
|
49120
|
-
} else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
|
|
49121
|
-
existingFakeScope = context.enclosingDeclaration.parent;
|
|
49122
|
-
}
|
|
49123
|
-
Debug.assertOptionalNode(existingFakeScope, isBlock);
|
|
49124
|
-
const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
|
|
49125
|
-
let newLocals;
|
|
49126
|
-
addAll((name, symbol) => {
|
|
49127
|
-
if (!locals.has(name)) {
|
|
49128
|
-
newLocals = append(newLocals, name);
|
|
49129
|
-
locals.set(name, symbol);
|
|
49130
|
-
}
|
|
49131
|
-
});
|
|
49132
|
-
if (!newLocals)
|
|
49133
|
-
return;
|
|
49134
|
-
const oldCleanup = cleanup;
|
|
49135
|
-
function undo() {
|
|
49136
|
-
forEach(newLocals, (s) => locals.delete(s));
|
|
49137
|
-
oldCleanup == null ? void 0 : oldCleanup();
|
|
49138
|
-
}
|
|
49139
|
-
if (existingFakeScope) {
|
|
49140
|
-
cleanup = undo;
|
|
49141
|
-
} else {
|
|
49142
|
-
const fakeScope = parseNodeFactory.createBlock(emptyArray);
|
|
49143
|
-
getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
|
|
49144
|
-
fakeScope.locals = locals;
|
|
49145
|
-
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
49146
|
-
setParent(fakeScope, saveEnclosingDeclaration);
|
|
49147
|
-
context.enclosingDeclaration = fakeScope;
|
|
49148
|
-
cleanup = () => {
|
|
49149
|
-
context.enclosingDeclaration = saveEnclosingDeclaration;
|
|
49150
|
-
undo();
|
|
49151
|
-
};
|
|
49152
|
-
}
|
|
49153
|
-
};
|
|
49154
|
-
var pushFakeScope = pushFakeScope2;
|
|
49155
|
-
pushFakeScope2(
|
|
49156
|
-
"params",
|
|
49157
|
-
(add) => {
|
|
49158
|
-
for (const param of expandedParams) {
|
|
49159
|
-
add(param.escapedName, param);
|
|
49160
|
-
}
|
|
49161
|
-
}
|
|
49162
|
-
);
|
|
49163
|
-
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
49164
|
-
pushFakeScope2(
|
|
49165
|
-
"typeParams",
|
|
49166
|
-
(add) => {
|
|
49167
|
-
for (const typeParam of signature.typeParameters ?? emptyArray) {
|
|
49168
|
-
const typeParamName = typeParameterToName(typeParam, context).escapedText;
|
|
49169
|
-
add(typeParamName, typeParam.symbol);
|
|
49170
|
-
}
|
|
49171
|
-
}
|
|
49172
|
-
);
|
|
49173
|
-
}
|
|
49174
|
-
}
|
|
49220
|
+
const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
|
|
49175
49221
|
const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */));
|
|
49176
49222
|
const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
|
|
49177
49223
|
if (thisParameter) {
|
|
@@ -49262,6 +49308,111 @@ function createTypeChecker(host) {
|
|
|
49262
49308
|
cleanup == null ? void 0 : cleanup();
|
|
49263
49309
|
return node;
|
|
49264
49310
|
}
|
|
49311
|
+
function isNewScopeNode(node) {
|
|
49312
|
+
return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
|
|
49313
|
+
}
|
|
49314
|
+
function getTypeParametersInScope(node) {
|
|
49315
|
+
return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
|
|
49316
|
+
}
|
|
49317
|
+
function getParametersInScope(node) {
|
|
49318
|
+
return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
|
|
49319
|
+
getSignatureFromDeclaration(node),
|
|
49320
|
+
/*skipUnionExpanding*/
|
|
49321
|
+
true
|
|
49322
|
+
)[0] : void 0;
|
|
49323
|
+
}
|
|
49324
|
+
function enterNewScope(context, declaration, expandedParams, typeParameters) {
|
|
49325
|
+
let cleanup;
|
|
49326
|
+
if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
|
|
49327
|
+
let pushFakeScope2 = function(kind, addAll) {
|
|
49328
|
+
Debug.assert(context.enclosingDeclaration);
|
|
49329
|
+
let existingFakeScope;
|
|
49330
|
+
if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind) {
|
|
49331
|
+
existingFakeScope = context.enclosingDeclaration;
|
|
49332
|
+
} else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind) {
|
|
49333
|
+
existingFakeScope = context.enclosingDeclaration.parent;
|
|
49334
|
+
}
|
|
49335
|
+
Debug.assertOptionalNode(existingFakeScope, isBlock);
|
|
49336
|
+
const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
|
|
49337
|
+
let newLocals;
|
|
49338
|
+
addAll((name, symbol) => {
|
|
49339
|
+
if (!locals.has(name)) {
|
|
49340
|
+
newLocals = append(newLocals, name);
|
|
49341
|
+
locals.set(name, symbol);
|
|
49342
|
+
}
|
|
49343
|
+
});
|
|
49344
|
+
if (!newLocals)
|
|
49345
|
+
return;
|
|
49346
|
+
const oldCleanup = cleanup;
|
|
49347
|
+
function undo() {
|
|
49348
|
+
forEach(newLocals, (s) => locals.delete(s));
|
|
49349
|
+
oldCleanup == null ? void 0 : oldCleanup();
|
|
49350
|
+
}
|
|
49351
|
+
if (existingFakeScope) {
|
|
49352
|
+
cleanup = undo;
|
|
49353
|
+
} else {
|
|
49354
|
+
const fakeScope = parseNodeFactory.createBlock(emptyArray);
|
|
49355
|
+
getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
|
|
49356
|
+
fakeScope.locals = locals;
|
|
49357
|
+
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
49358
|
+
setParent(fakeScope, saveEnclosingDeclaration);
|
|
49359
|
+
context.enclosingDeclaration = fakeScope;
|
|
49360
|
+
cleanup = () => {
|
|
49361
|
+
context.enclosingDeclaration = saveEnclosingDeclaration;
|
|
49362
|
+
undo();
|
|
49363
|
+
};
|
|
49364
|
+
}
|
|
49365
|
+
};
|
|
49366
|
+
var pushFakeScope = pushFakeScope2;
|
|
49367
|
+
pushFakeScope2(
|
|
49368
|
+
"params",
|
|
49369
|
+
(add) => {
|
|
49370
|
+
for (const param of expandedParams ?? emptyArray) {
|
|
49371
|
+
if (!forEach(param.declarations, (d) => {
|
|
49372
|
+
if (isParameter(d) && isBindingPattern(d.name)) {
|
|
49373
|
+
bindPattern(d.name);
|
|
49374
|
+
return true;
|
|
49375
|
+
}
|
|
49376
|
+
return void 0;
|
|
49377
|
+
function bindPattern(p) {
|
|
49378
|
+
forEach(p.elements, (e) => {
|
|
49379
|
+
switch (e.kind) {
|
|
49380
|
+
case 232 /* OmittedExpression */:
|
|
49381
|
+
return;
|
|
49382
|
+
case 208 /* BindingElement */:
|
|
49383
|
+
return bindElement(e);
|
|
49384
|
+
default:
|
|
49385
|
+
return Debug.assertNever(e);
|
|
49386
|
+
}
|
|
49387
|
+
});
|
|
49388
|
+
}
|
|
49389
|
+
function bindElement(e) {
|
|
49390
|
+
if (isBindingPattern(e.name)) {
|
|
49391
|
+
return bindPattern(e.name);
|
|
49392
|
+
}
|
|
49393
|
+
const symbol = getSymbolOfDeclaration(e);
|
|
49394
|
+
add(symbol.escapedName, symbol);
|
|
49395
|
+
}
|
|
49396
|
+
})) {
|
|
49397
|
+
add(param.escapedName, param);
|
|
49398
|
+
}
|
|
49399
|
+
}
|
|
49400
|
+
}
|
|
49401
|
+
);
|
|
49402
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
49403
|
+
pushFakeScope2(
|
|
49404
|
+
"typeParams",
|
|
49405
|
+
(add) => {
|
|
49406
|
+
for (const typeParam of typeParameters ?? emptyArray) {
|
|
49407
|
+
const typeParamName = typeParameterToName(typeParam, context).escapedText;
|
|
49408
|
+
add(typeParamName, typeParam.symbol);
|
|
49409
|
+
}
|
|
49410
|
+
}
|
|
49411
|
+
);
|
|
49412
|
+
}
|
|
49413
|
+
return cleanup;
|
|
49414
|
+
}
|
|
49415
|
+
}
|
|
49265
49416
|
function tryGetThisParameterDeclaration(signature, context) {
|
|
49266
49417
|
if (signature.thisParameter) {
|
|
49267
49418
|
return symbolToParameterDeclaration(signature.thisParameter, context);
|
|
@@ -49880,6 +50031,9 @@ function createTypeChecker(host) {
|
|
|
49880
50031
|
if (initial.typeParameterSymbolList) {
|
|
49881
50032
|
initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
|
|
49882
50033
|
}
|
|
50034
|
+
if (initial.typeParameterNamesByTextNextNameCount) {
|
|
50035
|
+
initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
|
|
50036
|
+
}
|
|
49883
50037
|
initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
|
|
49884
50038
|
return initial;
|
|
49885
50039
|
}
|
|
@@ -49887,7 +50041,16 @@ function createTypeChecker(host) {
|
|
|
49887
50041
|
return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
|
|
49888
50042
|
}
|
|
49889
50043
|
function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
|
|
49890
|
-
|
|
50044
|
+
if (!(getObjectFlags(type) & 4 /* Reference */))
|
|
50045
|
+
return true;
|
|
50046
|
+
if (!isTypeReferenceNode(existing))
|
|
50047
|
+
return true;
|
|
50048
|
+
void getTypeFromTypeReference(existing);
|
|
50049
|
+
const symbol = getNodeLinks(existing).resolvedSymbol;
|
|
50050
|
+
const existingTarget = symbol && getDeclaredTypeOfSymbol(symbol);
|
|
50051
|
+
if (!existingTarget || existingTarget !== type.target)
|
|
50052
|
+
return true;
|
|
50053
|
+
return length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
|
|
49891
50054
|
}
|
|
49892
50055
|
function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
|
|
49893
50056
|
while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
|
|
@@ -49970,7 +50133,28 @@ function createTypeChecker(host) {
|
|
|
49970
50133
|
return { introducesError, node };
|
|
49971
50134
|
}
|
|
49972
50135
|
const meaning = getMeaningOfEntityNameReference(node);
|
|
49973
|
-
|
|
50136
|
+
let sym;
|
|
50137
|
+
if (isThisIdentifier(leftmost)) {
|
|
50138
|
+
sym = getSymbolOfDeclaration(getThisContainer(
|
|
50139
|
+
leftmost,
|
|
50140
|
+
/*includeArrowFunctions*/
|
|
50141
|
+
false,
|
|
50142
|
+
/*includeClassComputedPropertyName*/
|
|
50143
|
+
false
|
|
50144
|
+
));
|
|
50145
|
+
if (isSymbolAccessible(
|
|
50146
|
+
sym,
|
|
50147
|
+
leftmost,
|
|
50148
|
+
meaning,
|
|
50149
|
+
/*shouldComputeAliasesToMakeVisible*/
|
|
50150
|
+
false
|
|
50151
|
+
).accessibility !== 0 /* Accessible */) {
|
|
50152
|
+
introducesError = true;
|
|
50153
|
+
context.tracker.reportInaccessibleThisError();
|
|
50154
|
+
}
|
|
50155
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50156
|
+
}
|
|
50157
|
+
sym = resolveEntityName(
|
|
49974
50158
|
leftmost,
|
|
49975
50159
|
meaning,
|
|
49976
50160
|
/*ignoreErrors*/
|
|
@@ -49979,27 +50163,44 @@ function createTypeChecker(host) {
|
|
|
49979
50163
|
true
|
|
49980
50164
|
);
|
|
49981
50165
|
if (sym) {
|
|
49982
|
-
if (
|
|
50166
|
+
if (sym.flags & 1 /* FunctionScopedVariable */ && sym.valueDeclaration) {
|
|
50167
|
+
if (isParameterDeclaration(sym.valueDeclaration)) {
|
|
50168
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50169
|
+
}
|
|
50170
|
+
}
|
|
50171
|
+
if (!(sym.flags & 262144 /* TypeParameter */) && // Type parameters are visible in the curent context if they are are resolvable
|
|
50172
|
+
!isDeclarationName(node) && isSymbolAccessible(
|
|
49983
50173
|
sym,
|
|
49984
50174
|
context.enclosingDeclaration,
|
|
49985
50175
|
meaning,
|
|
49986
50176
|
/*shouldComputeAliasesToMakeVisible*/
|
|
49987
50177
|
false
|
|
49988
50178
|
).accessibility !== 0 /* Accessible */) {
|
|
49989
|
-
|
|
49990
|
-
introducesError = true;
|
|
49991
|
-
}
|
|
50179
|
+
introducesError = true;
|
|
49992
50180
|
} else {
|
|
49993
50181
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
49994
50182
|
}
|
|
49995
|
-
|
|
50183
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50184
|
+
}
|
|
50185
|
+
return { introducesError, node };
|
|
50186
|
+
function attachSymbolToLeftmostIdentifier(node2) {
|
|
50187
|
+
if (node2 === leftmost) {
|
|
49996
50188
|
const type = getDeclaredTypeOfSymbol(sym);
|
|
49997
|
-
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(
|
|
50189
|
+
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
|
|
49998
50190
|
name.symbol = sym;
|
|
49999
|
-
return
|
|
50191
|
+
return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
|
|
50000
50192
|
}
|
|
50193
|
+
const updated = visitEachChild(
|
|
50194
|
+
node2,
|
|
50195
|
+
(c) => attachSymbolToLeftmostIdentifier(c),
|
|
50196
|
+
/*context*/
|
|
50197
|
+
void 0
|
|
50198
|
+
);
|
|
50199
|
+
if (updated !== node2) {
|
|
50200
|
+
setTextRange(updated, node2);
|
|
50201
|
+
}
|
|
50202
|
+
return updated;
|
|
50001
50203
|
}
|
|
50002
|
-
return { introducesError, node };
|
|
50003
50204
|
}
|
|
50004
50205
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
50005
50206
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
@@ -50012,6 +50213,22 @@ function createTypeChecker(host) {
|
|
|
50012
50213
|
}
|
|
50013
50214
|
return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
|
|
50014
50215
|
function visitExistingNodeTreeSymbols(node) {
|
|
50216
|
+
const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
|
|
50217
|
+
const result = visitExistingNodeTreeSymbolsWorker(node);
|
|
50218
|
+
onExitNewScope == null ? void 0 : onExitNewScope();
|
|
50219
|
+
return result;
|
|
50220
|
+
}
|
|
50221
|
+
function onEnterNewScope(node) {
|
|
50222
|
+
const oldContex = context;
|
|
50223
|
+
context = cloneNodeBuilderContext(context);
|
|
50224
|
+
const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
|
|
50225
|
+
return onExitNewScope;
|
|
50226
|
+
function onExitNewScope() {
|
|
50227
|
+
cleanup == null ? void 0 : cleanup();
|
|
50228
|
+
context = oldContex;
|
|
50229
|
+
}
|
|
50230
|
+
}
|
|
50231
|
+
function visitExistingNodeTreeSymbolsWorker(node) {
|
|
50015
50232
|
if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
|
|
50016
50233
|
return factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
50017
50234
|
}
|
|
@@ -50144,11 +50361,12 @@ function createTypeChecker(host) {
|
|
|
50144
50361
|
return visited;
|
|
50145
50362
|
}
|
|
50146
50363
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
50364
|
+
if (isDeclarationName(node)) {
|
|
50365
|
+
return node;
|
|
50366
|
+
}
|
|
50147
50367
|
const { introducesError, node: result } = trackExistingEntityName(node, context);
|
|
50148
50368
|
hadError = hadError || introducesError;
|
|
50149
|
-
|
|
50150
|
-
return result;
|
|
50151
|
-
}
|
|
50369
|
+
return result;
|
|
50152
50370
|
}
|
|
50153
50371
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
50154
50372
|
const visited = visitEachChild(
|
|
@@ -50162,6 +50380,21 @@ function createTypeChecker(host) {
|
|
|
50162
50380
|
setEmitFlags(clone, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
|
|
50163
50381
|
return clone;
|
|
50164
50382
|
}
|
|
50383
|
+
if (isConditionalTypeNode(node)) {
|
|
50384
|
+
const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50385
|
+
const disposeScope = onEnterNewScope(node);
|
|
50386
|
+
const extendType = visitNode(node.extendsType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50387
|
+
const trueType2 = visitNode(node.trueType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50388
|
+
disposeScope();
|
|
50389
|
+
const falseType2 = visitNode(node.falseType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50390
|
+
return factory.updateConditionalTypeNode(
|
|
50391
|
+
node,
|
|
50392
|
+
checkType,
|
|
50393
|
+
extendType,
|
|
50394
|
+
trueType2,
|
|
50395
|
+
falseType2
|
|
50396
|
+
);
|
|
50397
|
+
}
|
|
50165
50398
|
return visitEachChild(
|
|
50166
50399
|
node,
|
|
50167
50400
|
visitExistingNodeTreeSymbols,
|
|
@@ -52303,6 +52536,9 @@ function createTypeChecker(host) {
|
|
|
52303
52536
|
}
|
|
52304
52537
|
}
|
|
52305
52538
|
if (isParameter(declaration)) {
|
|
52539
|
+
if (!declaration.symbol) {
|
|
52540
|
+
return;
|
|
52541
|
+
}
|
|
52306
52542
|
const func = declaration.parent;
|
|
52307
52543
|
if (func.kind === 178 /* SetAccessor */ && hasBindableName(func)) {
|
|
52308
52544
|
const getter = getDeclarationOfKind(getSymbolOfDeclaration(declaration.parent), 177 /* GetAccessor */);
|
|
@@ -53662,7 +53898,7 @@ function createTypeChecker(host) {
|
|
|
53662
53898
|
for (const member of declaration.members) {
|
|
53663
53899
|
if (hasBindableName(member)) {
|
|
53664
53900
|
const memberSymbol = getSymbolOfDeclaration(member);
|
|
53665
|
-
const value = getEnumMemberValue(member);
|
|
53901
|
+
const value = getEnumMemberValue(member).value;
|
|
53666
53902
|
const memberType = getFreshTypeOfLiteralType(
|
|
53667
53903
|
value !== void 0 ? getEnumLiteralType(value, getSymbolId(symbol), memberSymbol) : createComputedEnumType(memberSymbol)
|
|
53668
53904
|
);
|
|
@@ -60798,8 +61034,8 @@ function createTypeChecker(host) {
|
|
|
60798
61034
|
}
|
|
60799
61035
|
return false;
|
|
60800
61036
|
}
|
|
60801
|
-
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
|
|
60802
|
-
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */));
|
|
61037
|
+
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
|
|
61038
|
+
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */)).value;
|
|
60803
61039
|
if (sourceValue !== targetValue) {
|
|
60804
61040
|
const sourceIsString = typeof sourceValue === "string";
|
|
60805
61041
|
const targetIsString = typeof targetValue === "string";
|
|
@@ -63377,6 +63613,9 @@ function createTypeChecker(host) {
|
|
|
63377
63613
|
const resolved = resolveStructuredTypeMembers(type);
|
|
63378
63614
|
return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && resolved.properties.length > 0 && every(resolved.properties, (p) => !!(p.flags & 16777216 /* Optional */));
|
|
63379
63615
|
}
|
|
63616
|
+
if (type.flags & 33554432 /* Substitution */) {
|
|
63617
|
+
return isWeakType(type.baseType);
|
|
63618
|
+
}
|
|
63380
63619
|
if (type.flags & 2097152 /* Intersection */) {
|
|
63381
63620
|
return every(type.types, isWeakType);
|
|
63382
63621
|
}
|
|
@@ -65678,7 +65917,7 @@ function createTypeChecker(host) {
|
|
|
65678
65917
|
return false;
|
|
65679
65918
|
}
|
|
65680
65919
|
function getFlowNodeId(flow) {
|
|
65681
|
-
if (
|
|
65920
|
+
if (flow.id <= 0) {
|
|
65682
65921
|
flow.id = nextFlowId;
|
|
65683
65922
|
nextFlowId++;
|
|
65684
65923
|
}
|
|
@@ -66313,33 +66552,34 @@ function createTypeChecker(host) {
|
|
|
66313
66552
|
}
|
|
66314
66553
|
flow = flow.antecedent;
|
|
66315
66554
|
} else if (flags & 4 /* BranchLabel */) {
|
|
66316
|
-
return some(flow.
|
|
66555
|
+
return some(flow.antecedent, (f) => isReachableFlowNodeWorker(
|
|
66317
66556
|
f,
|
|
66318
66557
|
/*noCacheCheck*/
|
|
66319
66558
|
false
|
|
66320
66559
|
));
|
|
66321
66560
|
} else if (flags & 8 /* LoopLabel */) {
|
|
66322
|
-
const antecedents = flow.
|
|
66561
|
+
const antecedents = flow.antecedent;
|
|
66323
66562
|
if (antecedents === void 0 || antecedents.length === 0) {
|
|
66324
66563
|
return false;
|
|
66325
66564
|
}
|
|
66326
66565
|
flow = antecedents[0];
|
|
66327
66566
|
} else if (flags & 128 /* SwitchClause */) {
|
|
66328
|
-
|
|
66567
|
+
const data = flow.node;
|
|
66568
|
+
if (data.clauseStart === data.clauseEnd && isExhaustiveSwitchStatement(data.switchStatement)) {
|
|
66329
66569
|
return false;
|
|
66330
66570
|
}
|
|
66331
66571
|
flow = flow.antecedent;
|
|
66332
66572
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66333
66573
|
lastFlowNode = void 0;
|
|
66334
|
-
const target = flow.target;
|
|
66335
|
-
const saveAntecedents = target.
|
|
66336
|
-
target.
|
|
66574
|
+
const target = flow.node.target;
|
|
66575
|
+
const saveAntecedents = target.antecedent;
|
|
66576
|
+
target.antecedent = flow.node.antecedents;
|
|
66337
66577
|
const result = isReachableFlowNodeWorker(
|
|
66338
66578
|
flow.antecedent,
|
|
66339
66579
|
/*noCacheCheck*/
|
|
66340
66580
|
false
|
|
66341
66581
|
);
|
|
66342
|
-
target.
|
|
66582
|
+
target.antecedent = saveAntecedents;
|
|
66343
66583
|
return result;
|
|
66344
66584
|
} else {
|
|
66345
66585
|
return !(flags & 1 /* Unreachable */);
|
|
@@ -66369,23 +66609,23 @@ function createTypeChecker(host) {
|
|
|
66369
66609
|
}
|
|
66370
66610
|
flow = flow.antecedent;
|
|
66371
66611
|
} else if (flags & 4 /* BranchLabel */) {
|
|
66372
|
-
return every(flow.
|
|
66612
|
+
return every(flow.antecedent, (f) => isPostSuperFlowNode(
|
|
66373
66613
|
f,
|
|
66374
66614
|
/*noCacheCheck*/
|
|
66375
66615
|
false
|
|
66376
66616
|
));
|
|
66377
66617
|
} else if (flags & 8 /* LoopLabel */) {
|
|
66378
|
-
flow = flow.
|
|
66618
|
+
flow = flow.antecedent[0];
|
|
66379
66619
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66380
|
-
const target = flow.target;
|
|
66381
|
-
const saveAntecedents = target.
|
|
66382
|
-
target.
|
|
66620
|
+
const target = flow.node.target;
|
|
66621
|
+
const saveAntecedents = target.antecedent;
|
|
66622
|
+
target.antecedent = flow.node.antecedents;
|
|
66383
66623
|
const result = isPostSuperFlowNode(
|
|
66384
66624
|
flow.antecedent,
|
|
66385
66625
|
/*noCacheCheck*/
|
|
66386
66626
|
false
|
|
66387
66627
|
);
|
|
66388
|
-
target.
|
|
66628
|
+
target.antecedent = saveAntecedents;
|
|
66389
66629
|
return result;
|
|
66390
66630
|
} else {
|
|
66391
66631
|
return !!(flags & 1 /* Unreachable */);
|
|
@@ -66477,8 +66717,8 @@ function createTypeChecker(host) {
|
|
|
66477
66717
|
} else if (flags & 128 /* SwitchClause */) {
|
|
66478
66718
|
type = getTypeAtSwitchClause(flow);
|
|
66479
66719
|
} else if (flags & 12 /* Label */) {
|
|
66480
|
-
if (flow.
|
|
66481
|
-
flow = flow.
|
|
66720
|
+
if (flow.antecedent.length === 1) {
|
|
66721
|
+
flow = flow.antecedent[0];
|
|
66482
66722
|
continue;
|
|
66483
66723
|
}
|
|
66484
66724
|
type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow);
|
|
@@ -66489,11 +66729,11 @@ function createTypeChecker(host) {
|
|
|
66489
66729
|
continue;
|
|
66490
66730
|
}
|
|
66491
66731
|
} else if (flags & 1024 /* ReduceLabel */) {
|
|
66492
|
-
const target = flow.target;
|
|
66493
|
-
const saveAntecedents = target.
|
|
66494
|
-
target.
|
|
66732
|
+
const target = flow.node.target;
|
|
66733
|
+
const saveAntecedents = target.antecedent;
|
|
66734
|
+
target.antecedent = flow.node.antecedents;
|
|
66495
66735
|
type = getTypeAtFlowNode(flow.antecedent);
|
|
66496
|
-
target.
|
|
66736
|
+
target.antecedent = saveAntecedents;
|
|
66497
66737
|
} else if (flags & 2 /* Start */) {
|
|
66498
66738
|
const container = flow.node;
|
|
66499
66739
|
if (container && container !== flowContainer && reference.kind !== 211 /* PropertyAccessExpression */ && reference.kind !== 212 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 219 /* ArrowFunction */)) {
|
|
@@ -66647,26 +66887,26 @@ function createTypeChecker(host) {
|
|
|
66647
66887
|
return createFlowType(narrowedType, isIncomplete(flowType));
|
|
66648
66888
|
}
|
|
66649
66889
|
function getTypeAtSwitchClause(flow) {
|
|
66650
|
-
const expr = skipParentheses(flow.switchStatement.expression);
|
|
66890
|
+
const expr = skipParentheses(flow.node.switchStatement.expression);
|
|
66651
66891
|
const flowType = getTypeAtFlowNode(flow.antecedent);
|
|
66652
66892
|
let type = getTypeFromFlowType(flowType);
|
|
66653
66893
|
if (isMatchingReference(reference, expr)) {
|
|
66654
|
-
type = narrowTypeBySwitchOnDiscriminant(type, flow.
|
|
66894
|
+
type = narrowTypeBySwitchOnDiscriminant(type, flow.node);
|
|
66655
66895
|
} else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
|
|
66656
|
-
type = narrowTypeBySwitchOnTypeOf(type, flow.
|
|
66896
|
+
type = narrowTypeBySwitchOnTypeOf(type, flow.node);
|
|
66657
66897
|
} else if (expr.kind === 112 /* TrueKeyword */) {
|
|
66658
|
-
type = narrowTypeBySwitchOnTrue(type, flow.
|
|
66898
|
+
type = narrowTypeBySwitchOnTrue(type, flow.node);
|
|
66659
66899
|
} else {
|
|
66660
66900
|
if (strictNullChecks) {
|
|
66661
66901
|
if (optionalChainContainsReference(expr, reference)) {
|
|
66662
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.
|
|
66902
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
|
|
66663
66903
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
66664
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.
|
|
66904
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
|
|
66665
66905
|
}
|
|
66666
66906
|
}
|
|
66667
66907
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
66668
66908
|
if (access) {
|
|
66669
|
-
type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.
|
|
66909
|
+
type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.node);
|
|
66670
66910
|
}
|
|
66671
66911
|
}
|
|
66672
66912
|
return createFlowType(type, isIncomplete(flowType));
|
|
@@ -66676,8 +66916,8 @@ function createTypeChecker(host) {
|
|
|
66676
66916
|
let subtypeReduction = false;
|
|
66677
66917
|
let seenIncomplete = false;
|
|
66678
66918
|
let bypassFlow;
|
|
66679
|
-
for (const antecedent of flow.
|
|
66680
|
-
if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) {
|
|
66919
|
+
for (const antecedent of flow.antecedent) {
|
|
66920
|
+
if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.node.clauseStart === antecedent.node.clauseEnd) {
|
|
66681
66921
|
bypassFlow = antecedent;
|
|
66682
66922
|
continue;
|
|
66683
66923
|
}
|
|
@@ -66697,7 +66937,7 @@ function createTypeChecker(host) {
|
|
|
66697
66937
|
if (bypassFlow) {
|
|
66698
66938
|
const flowType = getTypeAtFlowNode(bypassFlow);
|
|
66699
66939
|
const type = getTypeFromFlowType(flowType);
|
|
66700
|
-
if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
|
|
66940
|
+
if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.node.switchStatement)) {
|
|
66701
66941
|
if (type === declaredType && declaredType === initialType) {
|
|
66702
66942
|
return type;
|
|
66703
66943
|
}
|
|
@@ -66735,7 +66975,7 @@ function createTypeChecker(host) {
|
|
|
66735
66975
|
const antecedentTypes = [];
|
|
66736
66976
|
let subtypeReduction = false;
|
|
66737
66977
|
let firstAntecedentType;
|
|
66738
|
-
for (const antecedent of flow.
|
|
66978
|
+
for (const antecedent of flow.antecedent) {
|
|
66739
66979
|
let flowType;
|
|
66740
66980
|
if (!firstAntecedentType) {
|
|
66741
66981
|
flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
|
|
@@ -66859,15 +67099,15 @@ function createTypeChecker(host) {
|
|
|
66859
67099
|
}
|
|
66860
67100
|
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeByEquality(t, operator, value, assumeTrue));
|
|
66861
67101
|
}
|
|
66862
|
-
function narrowTypeBySwitchOnDiscriminantProperty(type, access,
|
|
66863
|
-
if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
|
|
66864
|
-
const clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd);
|
|
67102
|
+
function narrowTypeBySwitchOnDiscriminantProperty(type, access, data) {
|
|
67103
|
+
if (data.clauseStart < data.clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
|
|
67104
|
+
const clauseTypes = getSwitchClauseTypes(data.switchStatement).slice(data.clauseStart, data.clauseEnd);
|
|
66865
67105
|
const candidate = getUnionType(map(clauseTypes, (t) => getConstituentTypeForKeyType(type, t) || unknownType));
|
|
66866
67106
|
if (candidate !== unknownType) {
|
|
66867
67107
|
return candidate;
|
|
66868
67108
|
}
|
|
66869
67109
|
}
|
|
66870
|
-
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t,
|
|
67110
|
+
return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, data));
|
|
66871
67111
|
}
|
|
66872
67112
|
function narrowTypeByTruthiness(type, expr, assumeTrue) {
|
|
66873
67113
|
if (isMatchingReference(reference, expr)) {
|
|
@@ -67112,11 +67352,11 @@ function createTypeChecker(host) {
|
|
|
67112
67352
|
function narrowTypeByLiteralExpression(type, literal, assumeTrue) {
|
|
67113
67353
|
return assumeTrue ? narrowTypeByTypeName(type, literal.text) : getAdjustedTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
|
|
67114
67354
|
}
|
|
67115
|
-
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
|
|
67355
|
+
function narrowTypeBySwitchOptionalChainContainment(type, { switchStatement, clauseStart, clauseEnd }, clauseCheck) {
|
|
67116
67356
|
const everyClauseChecks = clauseStart !== clauseEnd && every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
|
|
67117
67357
|
return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
67118
67358
|
}
|
|
67119
|
-
function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
|
|
67359
|
+
function narrowTypeBySwitchOnDiscriminant(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67120
67360
|
const switchTypes = getSwitchClauseTypes(switchStatement);
|
|
67121
67361
|
if (!switchTypes.length) {
|
|
67122
67362
|
return type;
|
|
@@ -67189,7 +67429,7 @@ function createTypeChecker(host) {
|
|
|
67189
67429
|
)
|
|
67190
67430
|
));
|
|
67191
67431
|
}
|
|
67192
|
-
function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
67432
|
+
function narrowTypeBySwitchOnTypeOf(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67193
67433
|
const witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
|
|
67194
67434
|
if (!witnesses) {
|
|
67195
67435
|
return type;
|
|
@@ -67203,7 +67443,7 @@ function createTypeChecker(host) {
|
|
|
67203
67443
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
67204
67444
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
67205
67445
|
}
|
|
67206
|
-
function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
|
|
67446
|
+
function narrowTypeBySwitchOnTrue(type, { switchStatement, clauseStart, clauseEnd }) {
|
|
67207
67447
|
const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
|
|
67208
67448
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
67209
67449
|
for (let i = 0; i < clauseStart; i++) {
|
|
@@ -70345,7 +70585,11 @@ function createTypeChecker(host) {
|
|
|
70345
70585
|
if (getPropertyOfObjectType(targetType, name) || getApplicableIndexInfoForName(targetType, name) || isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || isComparingJsxAttributes && isHyphenatedJsxName(name)) {
|
|
70346
70586
|
return true;
|
|
70347
70587
|
}
|
|
70348
|
-
}
|
|
70588
|
+
}
|
|
70589
|
+
if (targetType.flags & 33554432 /* Substitution */) {
|
|
70590
|
+
return isKnownProperty(targetType.baseType, name, isComparingJsxAttributes);
|
|
70591
|
+
}
|
|
70592
|
+
if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
|
|
70349
70593
|
for (const t of targetType.types) {
|
|
70350
70594
|
if (isKnownProperty(t, name, isComparingJsxAttributes)) {
|
|
70351
70595
|
return true;
|
|
@@ -70355,7 +70599,7 @@ function createTypeChecker(host) {
|
|
|
70355
70599
|
return false;
|
|
70356
70600
|
}
|
|
70357
70601
|
function isExcessPropertyCheckTarget(type) {
|
|
70358
|
-
return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
|
|
70602
|
+
return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 33554432 /* Substitution */ && isExcessPropertyCheckTarget(type.baseType) || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
|
|
70359
70603
|
}
|
|
70360
70604
|
function checkJsxExpression(node, checkMode) {
|
|
70361
70605
|
checkGrammarJsxExpression(node);
|
|
@@ -74493,20 +74737,19 @@ function createTypeChecker(host) {
|
|
|
74493
74737
|
});
|
|
74494
74738
|
}
|
|
74495
74739
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
74496
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode ||
|
|
74497
|
-
|
|
74498
|
-
|
|
74499
|
-
|
|
74500
|
-
antecedent
|
|
74501
|
-
|
|
74740
|
+
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
74741
|
+
2 /* Start */,
|
|
74742
|
+
/*node*/
|
|
74743
|
+
void 0,
|
|
74744
|
+
/*antecedent*/
|
|
74745
|
+
void 0
|
|
74746
|
+
);
|
|
74747
|
+
const trueCondition = createFlowNode(32 /* TrueCondition */, expr, antecedent);
|
|
74502
74748
|
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
74503
74749
|
if (trueType2 === initType)
|
|
74504
74750
|
return void 0;
|
|
74505
|
-
const falseCondition =
|
|
74506
|
-
|
|
74507
|
-
flags: 64 /* FalseCondition */
|
|
74508
|
-
};
|
|
74509
|
-
const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
|
|
74751
|
+
const falseCondition = createFlowNode(64 /* FalseCondition */, expr, antecedent);
|
|
74752
|
+
const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
|
|
74510
74753
|
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
74511
74754
|
}
|
|
74512
74755
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
@@ -75899,7 +76142,7 @@ function createTypeChecker(host) {
|
|
|
75899
76142
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
75900
76143
|
return getTemplateLiteralType(texts, types);
|
|
75901
76144
|
}
|
|
75902
|
-
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
|
|
76145
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
|
|
75903
76146
|
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
75904
76147
|
}
|
|
75905
76148
|
function isTemplateLiteralContextualType(type) {
|
|
@@ -80804,14 +81047,14 @@ function createTypeChecker(host) {
|
|
|
80804
81047
|
let autoValue = 0;
|
|
80805
81048
|
let previous;
|
|
80806
81049
|
for (const member of node.members) {
|
|
80807
|
-
const
|
|
80808
|
-
getNodeLinks(member).enumMemberValue =
|
|
80809
|
-
autoValue = typeof value === "number" ? value + 1 : void 0;
|
|
81050
|
+
const result = computeEnumMemberValue(member, autoValue, previous);
|
|
81051
|
+
getNodeLinks(member).enumMemberValue = result;
|
|
81052
|
+
autoValue = typeof result.value === "number" ? result.value + 1 : void 0;
|
|
80810
81053
|
previous = member;
|
|
80811
81054
|
}
|
|
80812
81055
|
}
|
|
80813
81056
|
}
|
|
80814
|
-
function
|
|
81057
|
+
function computeEnumMemberValue(member, autoValue, previous) {
|
|
80815
81058
|
if (isComputedNonLiteralName(member.name)) {
|
|
80816
81059
|
error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
80817
81060
|
} else {
|
|
@@ -80821,34 +81064,43 @@ function createTypeChecker(host) {
|
|
|
80821
81064
|
}
|
|
80822
81065
|
}
|
|
80823
81066
|
if (member.initializer) {
|
|
80824
|
-
return
|
|
81067
|
+
return computeConstantEnumMemberValue(member);
|
|
80825
81068
|
}
|
|
80826
81069
|
if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
|
|
80827
|
-
return
|
|
81070
|
+
return evaluatorResult(
|
|
81071
|
+
/*value*/
|
|
81072
|
+
void 0
|
|
81073
|
+
);
|
|
80828
81074
|
}
|
|
80829
81075
|
if (autoValue === void 0) {
|
|
80830
81076
|
error(member.name, Diagnostics.Enum_member_must_have_initializer);
|
|
80831
|
-
return
|
|
80832
|
-
|
|
80833
|
-
|
|
80834
|
-
error(
|
|
80835
|
-
member.name,
|
|
80836
|
-
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
81077
|
+
return evaluatorResult(
|
|
81078
|
+
/*value*/
|
|
81079
|
+
void 0
|
|
80837
81080
|
);
|
|
80838
81081
|
}
|
|
80839
|
-
|
|
81082
|
+
if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer)) {
|
|
81083
|
+
const prevValue = getEnumMemberValue(previous);
|
|
81084
|
+
if (!(typeof prevValue.value === "number" && !prevValue.resolvedOtherFiles)) {
|
|
81085
|
+
error(
|
|
81086
|
+
member.name,
|
|
81087
|
+
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
81088
|
+
);
|
|
81089
|
+
}
|
|
81090
|
+
}
|
|
81091
|
+
return evaluatorResult(autoValue);
|
|
80840
81092
|
}
|
|
80841
|
-
function
|
|
81093
|
+
function computeConstantEnumMemberValue(member) {
|
|
80842
81094
|
const isConstEnum = isEnumConst(member.parent);
|
|
80843
81095
|
const initializer = member.initializer;
|
|
80844
|
-
const
|
|
80845
|
-
if (value !== void 0) {
|
|
80846
|
-
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
|
|
81096
|
+
const result = evaluate(initializer, member);
|
|
81097
|
+
if (result.value !== void 0) {
|
|
81098
|
+
if (isConstEnum && typeof result.value === "number" && !isFinite(result.value)) {
|
|
80847
81099
|
error(
|
|
80848
81100
|
initializer,
|
|
80849
|
-
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
|
|
81101
|
+
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
|
|
80850
81102
|
);
|
|
80851
|
-
} else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString
|
|
81103
|
+
} else if (getIsolatedModules(compilerOptions) && typeof result.value === "string" && !result.isSyntacticallyString) {
|
|
80852
81104
|
error(
|
|
80853
81105
|
initializer,
|
|
80854
81106
|
Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
|
|
@@ -80862,19 +81114,7 @@ function createTypeChecker(host) {
|
|
|
80862
81114
|
} else {
|
|
80863
81115
|
checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
|
|
80864
81116
|
}
|
|
80865
|
-
return
|
|
80866
|
-
}
|
|
80867
|
-
function isSyntacticallyNumericConstant(expr) {
|
|
80868
|
-
expr = skipOuterExpressions(expr);
|
|
80869
|
-
switch (expr.kind) {
|
|
80870
|
-
case 224 /* PrefixUnaryExpression */:
|
|
80871
|
-
return isSyntacticallyNumericConstant(expr.operand);
|
|
80872
|
-
case 226 /* BinaryExpression */:
|
|
80873
|
-
return isSyntacticallyNumericConstant(expr.left) && isSyntacticallyNumericConstant(expr.right);
|
|
80874
|
-
case 9 /* NumericLiteral */:
|
|
80875
|
-
return true;
|
|
80876
|
-
}
|
|
80877
|
-
return false;
|
|
81117
|
+
return result;
|
|
80878
81118
|
}
|
|
80879
81119
|
function evaluateEntityNameExpression(expr, location) {
|
|
80880
81120
|
const symbol = resolveEntityName(
|
|
@@ -80884,7 +81124,10 @@ function createTypeChecker(host) {
|
|
|
80884
81124
|
true
|
|
80885
81125
|
);
|
|
80886
81126
|
if (!symbol)
|
|
80887
|
-
return
|
|
81127
|
+
return evaluatorResult(
|
|
81128
|
+
/*value*/
|
|
81129
|
+
void 0
|
|
81130
|
+
);
|
|
80888
81131
|
if (expr.kind === 80 /* Identifier */) {
|
|
80889
81132
|
const identifier = expr;
|
|
80890
81133
|
if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
|
|
@@ -80893,7 +81136,11 @@ function createTypeChecker(host) {
|
|
|
80893
81136
|
/*diagnostic*/
|
|
80894
81137
|
void 0
|
|
80895
81138
|
)) {
|
|
80896
|
-
return
|
|
81139
|
+
return evaluatorResult(
|
|
81140
|
+
+identifier.escapedText,
|
|
81141
|
+
/*isSyntacticallyString*/
|
|
81142
|
+
false
|
|
81143
|
+
);
|
|
80897
81144
|
}
|
|
80898
81145
|
}
|
|
80899
81146
|
if (symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80902,9 +81149,23 @@ function createTypeChecker(host) {
|
|
|
80902
81149
|
if (isConstantVariable(symbol)) {
|
|
80903
81150
|
const declaration = symbol.valueDeclaration;
|
|
80904
81151
|
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
|
80905
|
-
|
|
81152
|
+
const result = evaluate(declaration.initializer, declaration);
|
|
81153
|
+
if (location && getSourceFileOfNode(location) !== getSourceFileOfNode(declaration)) {
|
|
81154
|
+
return evaluatorResult(
|
|
81155
|
+
result.value,
|
|
81156
|
+
/*isSyntacticallyString*/
|
|
81157
|
+
false,
|
|
81158
|
+
/*resolvedOtherFiles*/
|
|
81159
|
+
true
|
|
81160
|
+
);
|
|
81161
|
+
}
|
|
81162
|
+
return result;
|
|
80906
81163
|
}
|
|
80907
81164
|
}
|
|
81165
|
+
return evaluatorResult(
|
|
81166
|
+
/*value*/
|
|
81167
|
+
void 0
|
|
81168
|
+
);
|
|
80908
81169
|
}
|
|
80909
81170
|
function evaluateElementAccessExpression(expr, location) {
|
|
80910
81171
|
const root = expr.expression;
|
|
@@ -80919,20 +81180,31 @@ function createTypeChecker(host) {
|
|
|
80919
81180
|
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
80920
81181
|
const member = rootSymbol.exports.get(name);
|
|
80921
81182
|
if (member) {
|
|
81183
|
+
Debug.assert(getSourceFileOfNode(member.valueDeclaration) === getSourceFileOfNode(rootSymbol.valueDeclaration));
|
|
80922
81184
|
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
80923
81185
|
}
|
|
80924
81186
|
}
|
|
80925
81187
|
}
|
|
81188
|
+
return evaluatorResult(
|
|
81189
|
+
/*value*/
|
|
81190
|
+
void 0
|
|
81191
|
+
);
|
|
80926
81192
|
}
|
|
80927
81193
|
function evaluateEnumMember(expr, symbol, location) {
|
|
80928
81194
|
const declaration = symbol.valueDeclaration;
|
|
80929
81195
|
if (!declaration || declaration === location) {
|
|
80930
81196
|
error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
|
|
80931
|
-
return
|
|
81197
|
+
return evaluatorResult(
|
|
81198
|
+
/*value*/
|
|
81199
|
+
void 0
|
|
81200
|
+
);
|
|
80932
81201
|
}
|
|
80933
81202
|
if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
|
80934
81203
|
error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
|
80935
|
-
return
|
|
81204
|
+
return evaluatorResult(
|
|
81205
|
+
/*value*/
|
|
81206
|
+
0
|
|
81207
|
+
);
|
|
80936
81208
|
}
|
|
80937
81209
|
return getEnumMemberValue(declaration);
|
|
80938
81210
|
}
|
|
@@ -83073,7 +83345,10 @@ function createTypeChecker(host) {
|
|
|
83073
83345
|
}
|
|
83074
83346
|
function getEnumMemberValue(node) {
|
|
83075
83347
|
computeEnumMemberValues(node.parent);
|
|
83076
|
-
return getNodeLinks(node).enumMemberValue
|
|
83348
|
+
return getNodeLinks(node).enumMemberValue ?? evaluatorResult(
|
|
83349
|
+
/*value*/
|
|
83350
|
+
void 0
|
|
83351
|
+
);
|
|
83077
83352
|
}
|
|
83078
83353
|
function canHaveConstantValue(node) {
|
|
83079
83354
|
switch (node.kind) {
|
|
@@ -83086,13 +83361,13 @@ function createTypeChecker(host) {
|
|
|
83086
83361
|
}
|
|
83087
83362
|
function getConstantValue2(node) {
|
|
83088
83363
|
if (node.kind === 306 /* EnumMember */) {
|
|
83089
|
-
return getEnumMemberValue(node);
|
|
83364
|
+
return getEnumMemberValue(node).value;
|
|
83090
83365
|
}
|
|
83091
83366
|
const symbol = getNodeLinks(node).resolvedSymbol;
|
|
83092
83367
|
if (symbol && symbol.flags & 8 /* EnumMember */) {
|
|
83093
83368
|
const member = symbol.valueDeclaration;
|
|
83094
83369
|
if (isEnumConst(member.parent)) {
|
|
83095
|
-
return getEnumMemberValue(member);
|
|
83370
|
+
return getEnumMemberValue(member).value;
|
|
83096
83371
|
}
|
|
83097
83372
|
}
|
|
83098
83373
|
return void 0;
|
|
@@ -83467,6 +83742,10 @@ function createTypeChecker(host) {
|
|
|
83467
83742
|
const node = getParseTreeNode(nodeIn, canHaveConstantValue);
|
|
83468
83743
|
return node ? getConstantValue2(node) : void 0;
|
|
83469
83744
|
},
|
|
83745
|
+
getEnumMemberValue: (nodeIn) => {
|
|
83746
|
+
const node = getParseTreeNode(nodeIn, isEnumMember);
|
|
83747
|
+
return node ? getEnumMemberValue(node) : void 0;
|
|
83748
|
+
},
|
|
83470
83749
|
collectLinkedAliases,
|
|
83471
83750
|
getReferencedValueDeclaration,
|
|
83472
83751
|
getReferencedValueDeclarations,
|
|
@@ -89685,7 +89964,8 @@ function transformTypeScript(context) {
|
|
|
89685
89964
|
/*generateNameForComputedPropertyName*/
|
|
89686
89965
|
false
|
|
89687
89966
|
);
|
|
89688
|
-
const
|
|
89967
|
+
const evaluated = resolver.getEnumMemberValue(member);
|
|
89968
|
+
const valueExpression = transformEnumMemberDeclarationValue(member, evaluated == null ? void 0 : evaluated.value);
|
|
89689
89969
|
const innerAssignment = factory2.createAssignment(
|
|
89690
89970
|
factory2.createElementAccessExpression(
|
|
89691
89971
|
currentNamespaceContainerName,
|
|
@@ -89693,7 +89973,7 @@ function transformTypeScript(context) {
|
|
|
89693
89973
|
),
|
|
89694
89974
|
valueExpression
|
|
89695
89975
|
);
|
|
89696
|
-
const outerAssignment =
|
|
89976
|
+
const outerAssignment = typeof (evaluated == null ? void 0 : evaluated.value) === "string" || (evaluated == null ? void 0 : evaluated.isSyntacticallyString) ? innerAssignment : factory2.createAssignment(
|
|
89697
89977
|
factory2.createElementAccessExpression(
|
|
89698
89978
|
currentNamespaceContainerName,
|
|
89699
89979
|
innerAssignment
|
|
@@ -89710,10 +89990,9 @@ function transformTypeScript(context) {
|
|
|
89710
89990
|
member
|
|
89711
89991
|
);
|
|
89712
89992
|
}
|
|
89713
|
-
function transformEnumMemberDeclarationValue(member) {
|
|
89714
|
-
|
|
89715
|
-
|
|
89716
|
-
return typeof value === "string" ? factory2.createStringLiteral(value) : value < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-value)) : factory2.createNumericLiteral(value);
|
|
89993
|
+
function transformEnumMemberDeclarationValue(member, constantValue) {
|
|
89994
|
+
if (constantValue !== void 0) {
|
|
89995
|
+
return typeof constantValue === "string" ? factory2.createStringLiteral(constantValue) : constantValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-constantValue)) : factory2.createNumericLiteral(constantValue);
|
|
89717
89996
|
} else {
|
|
89718
89997
|
enableSubstitutionForNonQualifiedEnumMembers();
|
|
89719
89998
|
if (member.initializer) {
|
|
@@ -111053,6 +111332,7 @@ var notImplementedResolver = {
|
|
|
111053
111332
|
isEntityNameVisible: notImplemented,
|
|
111054
111333
|
// Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
|
|
111055
111334
|
getConstantValue: notImplemented,
|
|
111335
|
+
getEnumMemberValue: notImplemented,
|
|
111056
111336
|
getReferencedValueDeclaration: notImplemented,
|
|
111057
111337
|
getReferencedValueDeclarations: notImplemented,
|
|
111058
111338
|
getTypeReferenceSerializationKind: notImplemented,
|
|
@@ -125938,7 +126218,7 @@ function verboseReportProjectStatus(state, configFileName, status) {
|
|
|
125938
126218
|
}
|
|
125939
126219
|
}
|
|
125940
126220
|
|
|
125941
|
-
// src/
|
|
126221
|
+
// src/compiler/executeCommandLine.ts
|
|
125942
126222
|
function countLines(program) {
|
|
125943
126223
|
const counts2 = getCountsMap();
|
|
125944
126224
|
forEach(program.getSourceFiles(), (file) => {
|