typescript 5.5.0-dev.20240404 → 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 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.20240404`;
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.antecedents;
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.antecedents) {
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 (hasNode(flowNode2)) {
2109
- if (flowNode2.node) {
2110
- text += ` (${getNodeText(flowNode2.node)})`;
2111
- }
2112
- } else if (isFlowSwitchClause(flowNode2)) {
2109
+ if (isFlowSwitchClause(flowNode2)) {
2113
2110
  const clauses = [];
2114
- for (let i = flowNode2.clauseStart; i < flowNode2.clauseEnd; i++) {
2115
- const clause = flowNode2.switchStatement.caseBlock.clauses[i];
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 */ && node._children.length > 0) {
11751
- return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
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(expr) {
17691
- expr = skipOuterExpressions(expr);
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 value = evaluate(expr.operand, location);
17709
- if (typeof value === "number") {
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
- if (typeof left === "number" && typeof right === "number") {
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 "" + left + right;
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 expr.text;
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 void 0;
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 value = evaluate(span.expression, location);
17779
- if (value === void 0) {
17780
- return void 0;
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 result;
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._children = children;
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
- if (node._children) {
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._children = void 0;
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 initFlowNode(node) {
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 = { flags: 1 /* Unreachable */ };
39641
- var reportedUnreachableFlow = { flags: 1 /* Unreachable */ };
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 = initFlowNode({ flags: 2 /* Start */ });
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
- return isDottedName(expr) || (isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || isBinaryExpression(expr) && expr.operatorToken.kind === 28 /* CommaToken */ && isNarrowableReference(expr.right) || isElementAccessExpression(expr) && (isStringOrNumericLiteralLike(expr.argumentExpression) || isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || isAssignmentExpression(expr) && isNarrowableReference(expr.left);
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 initFlowNode({ flags: 4 /* BranchLabel */, antecedents: void 0 });
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 initFlowNode({ flags: 8 /* LoopLabel */, antecedents: void 0 });
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 initFlowNode({ flags: 1024 /* ReduceLabel */, target, antecedents, antecedent });
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.antecedents, antecedent)) {
40243
- (label.antecedents || (label.antecedents = [])).push(antecedent);
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 initFlowNode({ flags, antecedent, node: expression });
40340
+ return createFlowNode(flags, expression, antecedent);
40262
40341
  }
40263
40342
  function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
40264
40343
  setFlowNodeReferenced(antecedent);
40265
- return initFlowNode({ flags: 128 /* SwitchClause */, antecedent, switchStatement, clauseStart, clauseEnd });
40344
+ return createFlowNode(128 /* SwitchClause */, { switchStatement, clauseStart, clauseEnd }, antecedent);
40266
40345
  }
40267
40346
  function createFlowMutation(flags, antecedent, node) {
40268
40347
  setFlowNodeReferenced(antecedent);
40269
- const result = initFlowNode({ flags, antecedent, node });
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
- return initFlowNode({ flags: 512 /* Call */, antecedent, node });
40357
+ hasFlowEffects = true;
40358
+ return createFlowNode(512 /* Call */, node, antecedent);
40278
40359
  }
40279
40360
  function finishFlowLabel(flow) {
40280
- const antecedents = flow.antecedents;
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.antecedents = concatenate(concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
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.antecedents) {
40494
- addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
40576
+ if (currentReturnTarget && returnLabel.antecedent) {
40577
+ addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedent, currentFlow));
40495
40578
  }
40496
- if (currentExceptionTarget && exceptionLabel.antecedents) {
40497
- addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
40579
+ if (currentExceptionTarget && exceptionLabel.antecedent) {
40580
+ addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedent, currentFlow));
40498
40581
  }
40499
- currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
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.antecedents;
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 = initFlowNode({ flags: 2 /* Start */ });
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 = initFlowNode({ flags: 2 /* Start */ });
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
  }
@@ -47851,7 +47957,7 @@ function createTypeChecker(host) {
47851
47957
  }
47852
47958
  function getMeaningOfEntityNameReference(entityName) {
47853
47959
  let meaning;
47854
- 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) {
47855
47961
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
47856
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) {
47857
47963
  meaning = 1920 /* Namespace */;
@@ -50027,7 +50133,28 @@ function createTypeChecker(host) {
50027
50133
  return { introducesError, node };
50028
50134
  }
50029
50135
  const meaning = getMeaningOfEntityNameReference(node);
50030
- const sym = resolveEntityName(
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(
50031
50158
  leftmost,
50032
50159
  meaning,
50033
50160
  /*ignoreErrors*/
@@ -50036,27 +50163,44 @@ function createTypeChecker(host) {
50036
50163
  true
50037
50164
  );
50038
50165
  if (sym) {
50039
- if (isSymbolAccessible(
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(
50040
50173
  sym,
50041
50174
  context.enclosingDeclaration,
50042
50175
  meaning,
50043
50176
  /*shouldComputeAliasesToMakeVisible*/
50044
50177
  false
50045
50178
  ).accessibility !== 0 /* Accessible */) {
50046
- if (!isDeclarationName(node)) {
50047
- introducesError = true;
50048
- }
50179
+ introducesError = true;
50049
50180
  } else {
50050
50181
  context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
50051
50182
  }
50052
- if (isIdentifier(node)) {
50183
+ return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
50184
+ }
50185
+ return { introducesError, node };
50186
+ function attachSymbolToLeftmostIdentifier(node2) {
50187
+ if (node2 === leftmost) {
50053
50188
  const type = getDeclaredTypeOfSymbol(sym);
50054
- const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
50189
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
50055
50190
  name.symbol = sym;
50056
- return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */), node) };
50191
+ return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
50057
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;
50058
50203
  }
50059
- return { introducesError, node };
50060
50204
  }
50061
50205
  function tryReuseExistingTypeNodeHelper(context, existing) {
50062
50206
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
@@ -50217,11 +50361,12 @@ function createTypeChecker(host) {
50217
50361
  return visited;
50218
50362
  }
50219
50363
  if (isEntityName(node) || isEntityNameExpression(node)) {
50364
+ if (isDeclarationName(node)) {
50365
+ return node;
50366
+ }
50220
50367
  const { introducesError, node: result } = trackExistingEntityName(node, context);
50221
50368
  hadError = hadError || introducesError;
50222
- if (result !== node) {
50223
- return result;
50224
- }
50369
+ return result;
50225
50370
  }
50226
50371
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
50227
50372
  const visited = visitEachChild(
@@ -52391,6 +52536,9 @@ function createTypeChecker(host) {
52391
52536
  }
52392
52537
  }
52393
52538
  if (isParameter(declaration)) {
52539
+ if (!declaration.symbol) {
52540
+ return;
52541
+ }
52394
52542
  const func = declaration.parent;
52395
52543
  if (func.kind === 178 /* SetAccessor */ && hasBindableName(func)) {
52396
52544
  const getter = getDeclarationOfKind(getSymbolOfDeclaration(declaration.parent), 177 /* GetAccessor */);
@@ -53750,7 +53898,7 @@ function createTypeChecker(host) {
53750
53898
  for (const member of declaration.members) {
53751
53899
  if (hasBindableName(member)) {
53752
53900
  const memberSymbol = getSymbolOfDeclaration(member);
53753
- const value = getEnumMemberValue(member);
53901
+ const value = getEnumMemberValue(member).value;
53754
53902
  const memberType = getFreshTypeOfLiteralType(
53755
53903
  value !== void 0 ? getEnumLiteralType(value, getSymbolId(symbol), memberSymbol) : createComputedEnumType(memberSymbol)
53756
53904
  );
@@ -60886,8 +61034,8 @@ function createTypeChecker(host) {
60886
61034
  }
60887
61035
  return false;
60888
61036
  }
60889
- const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
60890
- 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;
60891
61039
  if (sourceValue !== targetValue) {
60892
61040
  const sourceIsString = typeof sourceValue === "string";
60893
61041
  const targetIsString = typeof targetValue === "string";
@@ -65769,7 +65917,7 @@ function createTypeChecker(host) {
65769
65917
  return false;
65770
65918
  }
65771
65919
  function getFlowNodeId(flow) {
65772
- if (!flow.id || flow.id < 0) {
65920
+ if (flow.id <= 0) {
65773
65921
  flow.id = nextFlowId;
65774
65922
  nextFlowId++;
65775
65923
  }
@@ -66404,33 +66552,34 @@ function createTypeChecker(host) {
66404
66552
  }
66405
66553
  flow = flow.antecedent;
66406
66554
  } else if (flags & 4 /* BranchLabel */) {
66407
- return some(flow.antecedents, (f) => isReachableFlowNodeWorker(
66555
+ return some(flow.antecedent, (f) => isReachableFlowNodeWorker(
66408
66556
  f,
66409
66557
  /*noCacheCheck*/
66410
66558
  false
66411
66559
  ));
66412
66560
  } else if (flags & 8 /* LoopLabel */) {
66413
- const antecedents = flow.antecedents;
66561
+ const antecedents = flow.antecedent;
66414
66562
  if (antecedents === void 0 || antecedents.length === 0) {
66415
66563
  return false;
66416
66564
  }
66417
66565
  flow = antecedents[0];
66418
66566
  } else if (flags & 128 /* SwitchClause */) {
66419
- if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
66567
+ const data = flow.node;
66568
+ if (data.clauseStart === data.clauseEnd && isExhaustiveSwitchStatement(data.switchStatement)) {
66420
66569
  return false;
66421
66570
  }
66422
66571
  flow = flow.antecedent;
66423
66572
  } else if (flags & 1024 /* ReduceLabel */) {
66424
66573
  lastFlowNode = void 0;
66425
- const target = flow.target;
66426
- const saveAntecedents = target.antecedents;
66427
- target.antecedents = flow.antecedents;
66574
+ const target = flow.node.target;
66575
+ const saveAntecedents = target.antecedent;
66576
+ target.antecedent = flow.node.antecedents;
66428
66577
  const result = isReachableFlowNodeWorker(
66429
66578
  flow.antecedent,
66430
66579
  /*noCacheCheck*/
66431
66580
  false
66432
66581
  );
66433
- target.antecedents = saveAntecedents;
66582
+ target.antecedent = saveAntecedents;
66434
66583
  return result;
66435
66584
  } else {
66436
66585
  return !(flags & 1 /* Unreachable */);
@@ -66460,23 +66609,23 @@ function createTypeChecker(host) {
66460
66609
  }
66461
66610
  flow = flow.antecedent;
66462
66611
  } else if (flags & 4 /* BranchLabel */) {
66463
- return every(flow.antecedents, (f) => isPostSuperFlowNode(
66612
+ return every(flow.antecedent, (f) => isPostSuperFlowNode(
66464
66613
  f,
66465
66614
  /*noCacheCheck*/
66466
66615
  false
66467
66616
  ));
66468
66617
  } else if (flags & 8 /* LoopLabel */) {
66469
- flow = flow.antecedents[0];
66618
+ flow = flow.antecedent[0];
66470
66619
  } else if (flags & 1024 /* ReduceLabel */) {
66471
- const target = flow.target;
66472
- const saveAntecedents = target.antecedents;
66473
- target.antecedents = flow.antecedents;
66620
+ const target = flow.node.target;
66621
+ const saveAntecedents = target.antecedent;
66622
+ target.antecedent = flow.node.antecedents;
66474
66623
  const result = isPostSuperFlowNode(
66475
66624
  flow.antecedent,
66476
66625
  /*noCacheCheck*/
66477
66626
  false
66478
66627
  );
66479
- target.antecedents = saveAntecedents;
66628
+ target.antecedent = saveAntecedents;
66480
66629
  return result;
66481
66630
  } else {
66482
66631
  return !!(flags & 1 /* Unreachable */);
@@ -66568,8 +66717,8 @@ function createTypeChecker(host) {
66568
66717
  } else if (flags & 128 /* SwitchClause */) {
66569
66718
  type = getTypeAtSwitchClause(flow);
66570
66719
  } else if (flags & 12 /* Label */) {
66571
- if (flow.antecedents.length === 1) {
66572
- flow = flow.antecedents[0];
66720
+ if (flow.antecedent.length === 1) {
66721
+ flow = flow.antecedent[0];
66573
66722
  continue;
66574
66723
  }
66575
66724
  type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow);
@@ -66580,11 +66729,11 @@ function createTypeChecker(host) {
66580
66729
  continue;
66581
66730
  }
66582
66731
  } else if (flags & 1024 /* ReduceLabel */) {
66583
- const target = flow.target;
66584
- const saveAntecedents = target.antecedents;
66585
- target.antecedents = flow.antecedents;
66732
+ const target = flow.node.target;
66733
+ const saveAntecedents = target.antecedent;
66734
+ target.antecedent = flow.node.antecedents;
66586
66735
  type = getTypeAtFlowNode(flow.antecedent);
66587
- target.antecedents = saveAntecedents;
66736
+ target.antecedent = saveAntecedents;
66588
66737
  } else if (flags & 2 /* Start */) {
66589
66738
  const container = flow.node;
66590
66739
  if (container && container !== flowContainer && reference.kind !== 211 /* PropertyAccessExpression */ && reference.kind !== 212 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 219 /* ArrowFunction */)) {
@@ -66738,26 +66887,26 @@ function createTypeChecker(host) {
66738
66887
  return createFlowType(narrowedType, isIncomplete(flowType));
66739
66888
  }
66740
66889
  function getTypeAtSwitchClause(flow) {
66741
- const expr = skipParentheses(flow.switchStatement.expression);
66890
+ const expr = skipParentheses(flow.node.switchStatement.expression);
66742
66891
  const flowType = getTypeAtFlowNode(flow.antecedent);
66743
66892
  let type = getTypeFromFlowType(flowType);
66744
66893
  if (isMatchingReference(reference, expr)) {
66745
- type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
66894
+ type = narrowTypeBySwitchOnDiscriminant(type, flow.node);
66746
66895
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
66747
- type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
66896
+ type = narrowTypeBySwitchOnTypeOf(type, flow.node);
66748
66897
  } else if (expr.kind === 112 /* TrueKeyword */) {
66749
- type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
66898
+ type = narrowTypeBySwitchOnTrue(type, flow.node);
66750
66899
  } else {
66751
66900
  if (strictNullChecks) {
66752
66901
  if (optionalChainContainsReference(expr, reference)) {
66753
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
66902
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
66754
66903
  } else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
66755
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
66904
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
66756
66905
  }
66757
66906
  }
66758
66907
  const access = getDiscriminantPropertyAccess(expr, type);
66759
66908
  if (access) {
66760
- type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
66909
+ type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.node);
66761
66910
  }
66762
66911
  }
66763
66912
  return createFlowType(type, isIncomplete(flowType));
@@ -66767,8 +66916,8 @@ function createTypeChecker(host) {
66767
66916
  let subtypeReduction = false;
66768
66917
  let seenIncomplete = false;
66769
66918
  let bypassFlow;
66770
- for (const antecedent of flow.antecedents) {
66771
- 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) {
66772
66921
  bypassFlow = antecedent;
66773
66922
  continue;
66774
66923
  }
@@ -66788,7 +66937,7 @@ function createTypeChecker(host) {
66788
66937
  if (bypassFlow) {
66789
66938
  const flowType = getTypeAtFlowNode(bypassFlow);
66790
66939
  const type = getTypeFromFlowType(flowType);
66791
- if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
66940
+ if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.node.switchStatement)) {
66792
66941
  if (type === declaredType && declaredType === initialType) {
66793
66942
  return type;
66794
66943
  }
@@ -66826,7 +66975,7 @@ function createTypeChecker(host) {
66826
66975
  const antecedentTypes = [];
66827
66976
  let subtypeReduction = false;
66828
66977
  let firstAntecedentType;
66829
- for (const antecedent of flow.antecedents) {
66978
+ for (const antecedent of flow.antecedent) {
66830
66979
  let flowType;
66831
66980
  if (!firstAntecedentType) {
66832
66981
  flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
@@ -66950,15 +67099,15 @@ function createTypeChecker(host) {
66950
67099
  }
66951
67100
  return narrowTypeByDiscriminant(type, access, (t) => narrowTypeByEquality(t, operator, value, assumeTrue));
66952
67101
  }
66953
- function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) {
66954
- if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
66955
- 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);
66956
67105
  const candidate = getUnionType(map(clauseTypes, (t) => getConstituentTypeForKeyType(type, t) || unknownType));
66957
67106
  if (candidate !== unknownType) {
66958
67107
  return candidate;
66959
67108
  }
66960
67109
  }
66961
- return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd));
67110
+ return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, data));
66962
67111
  }
66963
67112
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
66964
67113
  if (isMatchingReference(reference, expr)) {
@@ -67203,11 +67352,11 @@ function createTypeChecker(host) {
67203
67352
  function narrowTypeByLiteralExpression(type, literal, assumeTrue) {
67204
67353
  return assumeTrue ? narrowTypeByTypeName(type, literal.text) : getAdjustedTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
67205
67354
  }
67206
- function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
67355
+ function narrowTypeBySwitchOptionalChainContainment(type, { switchStatement, clauseStart, clauseEnd }, clauseCheck) {
67207
67356
  const everyClauseChecks = clauseStart !== clauseEnd && every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
67208
67357
  return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
67209
67358
  }
67210
- function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
67359
+ function narrowTypeBySwitchOnDiscriminant(type, { switchStatement, clauseStart, clauseEnd }) {
67211
67360
  const switchTypes = getSwitchClauseTypes(switchStatement);
67212
67361
  if (!switchTypes.length) {
67213
67362
  return type;
@@ -67280,7 +67429,7 @@ function createTypeChecker(host) {
67280
67429
  )
67281
67430
  ));
67282
67431
  }
67283
- function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
67432
+ function narrowTypeBySwitchOnTypeOf(type, { switchStatement, clauseStart, clauseEnd }) {
67284
67433
  const witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
67285
67434
  if (!witnesses) {
67286
67435
  return type;
@@ -67294,7 +67443,7 @@ function createTypeChecker(host) {
67294
67443
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
67295
67444
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
67296
67445
  }
67297
- function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
67446
+ function narrowTypeBySwitchOnTrue(type, { switchStatement, clauseStart, clauseEnd }) {
67298
67447
  const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
67299
67448
  const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
67300
67449
  for (let i = 0; i < clauseStart; i++) {
@@ -74588,20 +74737,18 @@ function createTypeChecker(host) {
74588
74737
  });
74589
74738
  }
74590
74739
  function checkIfExpressionRefinesParameter(func, expr, param, initType) {
74591
- const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
74592
- const trueCondition = {
74593
- flags: 32 /* TrueCondition */,
74594
- antecedent,
74595
- node: expr
74596
- };
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);
74597
74748
  const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
74598
74749
  if (trueType2 === initType)
74599
74750
  return void 0;
74600
- const falseCondition = {
74601
- flags: 64 /* FalseCondition */,
74602
- antecedent,
74603
- node: expr
74604
- };
74751
+ const falseCondition = createFlowNode(64 /* FalseCondition */, expr, antecedent);
74605
74752
  const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
74606
74753
  return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
74607
74754
  }
@@ -75995,7 +76142,7 @@ function createTypeChecker(host) {
75995
76142
  ) || unknownType, isTemplateLiteralContextualType)) {
75996
76143
  return getTemplateLiteralType(texts, types);
75997
76144
  }
75998
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
76145
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
75999
76146
  return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
76000
76147
  }
76001
76148
  function isTemplateLiteralContextualType(type) {
@@ -80900,14 +81047,14 @@ function createTypeChecker(host) {
80900
81047
  let autoValue = 0;
80901
81048
  let previous;
80902
81049
  for (const member of node.members) {
80903
- const value = computeMemberValue(member, autoValue, previous);
80904
- getNodeLinks(member).enumMemberValue = value;
80905
- 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;
80906
81053
  previous = member;
80907
81054
  }
80908
81055
  }
80909
81056
  }
80910
- function computeMemberValue(member, autoValue, previous) {
81057
+ function computeEnumMemberValue(member, autoValue, previous) {
80911
81058
  if (isComputedNonLiteralName(member.name)) {
80912
81059
  error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
80913
81060
  } else {
@@ -80917,34 +81064,43 @@ function createTypeChecker(host) {
80917
81064
  }
80918
81065
  }
80919
81066
  if (member.initializer) {
80920
- return computeConstantValue(member);
81067
+ return computeConstantEnumMemberValue(member);
80921
81068
  }
80922
81069
  if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
80923
- return void 0;
81070
+ return evaluatorResult(
81071
+ /*value*/
81072
+ void 0
81073
+ );
80924
81074
  }
80925
81075
  if (autoValue === void 0) {
80926
81076
  error(member.name, Diagnostics.Enum_member_must_have_initializer);
80927
- return void 0;
80928
- }
80929
- if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer) && !isSyntacticallyNumericConstant(previous.initializer)) {
80930
- error(
80931
- member.name,
80932
- 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
80933
81080
  );
80934
81081
  }
80935
- return autoValue;
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);
80936
81092
  }
80937
- function computeConstantValue(member) {
81093
+ function computeConstantEnumMemberValue(member) {
80938
81094
  const isConstEnum = isEnumConst(member.parent);
80939
81095
  const initializer = member.initializer;
80940
- const value = evaluate(initializer, member);
80941
- if (value !== void 0) {
80942
- 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)) {
80943
81099
  error(
80944
81100
  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
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
80946
81102
  );
80947
- } else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString(initializer)) {
81103
+ } else if (getIsolatedModules(compilerOptions) && typeof result.value === "string" && !result.isSyntacticallyString) {
80948
81104
  error(
80949
81105
  initializer,
80950
81106
  Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
@@ -80958,19 +81114,7 @@ function createTypeChecker(host) {
80958
81114
  } else {
80959
81115
  checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
80960
81116
  }
80961
- return value;
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;
81117
+ return result;
80974
81118
  }
80975
81119
  function evaluateEntityNameExpression(expr, location) {
80976
81120
  const symbol = resolveEntityName(
@@ -80980,7 +81124,10 @@ function createTypeChecker(host) {
80980
81124
  true
80981
81125
  );
80982
81126
  if (!symbol)
80983
- return void 0;
81127
+ return evaluatorResult(
81128
+ /*value*/
81129
+ void 0
81130
+ );
80984
81131
  if (expr.kind === 80 /* Identifier */) {
80985
81132
  const identifier = expr;
80986
81133
  if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
@@ -80989,7 +81136,11 @@ function createTypeChecker(host) {
80989
81136
  /*diagnostic*/
80990
81137
  void 0
80991
81138
  )) {
80992
- return +identifier.escapedText;
81139
+ return evaluatorResult(
81140
+ +identifier.escapedText,
81141
+ /*isSyntacticallyString*/
81142
+ false
81143
+ );
80993
81144
  }
80994
81145
  }
80995
81146
  if (symbol.flags & 8 /* EnumMember */) {
@@ -80998,9 +81149,23 @@ function createTypeChecker(host) {
80998
81149
  if (isConstantVariable(symbol)) {
80999
81150
  const declaration = symbol.valueDeclaration;
81000
81151
  if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
81001
- return evaluate(declaration.initializer, declaration);
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;
81002
81163
  }
81003
81164
  }
81165
+ return evaluatorResult(
81166
+ /*value*/
81167
+ void 0
81168
+ );
81004
81169
  }
81005
81170
  function evaluateElementAccessExpression(expr, location) {
81006
81171
  const root = expr.expression;
@@ -81015,20 +81180,31 @@ function createTypeChecker(host) {
81015
81180
  const name = escapeLeadingUnderscores(expr.argumentExpression.text);
81016
81181
  const member = rootSymbol.exports.get(name);
81017
81182
  if (member) {
81183
+ Debug.assert(getSourceFileOfNode(member.valueDeclaration) === getSourceFileOfNode(rootSymbol.valueDeclaration));
81018
81184
  return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
81019
81185
  }
81020
81186
  }
81021
81187
  }
81188
+ return evaluatorResult(
81189
+ /*value*/
81190
+ void 0
81191
+ );
81022
81192
  }
81023
81193
  function evaluateEnumMember(expr, symbol, location) {
81024
81194
  const declaration = symbol.valueDeclaration;
81025
81195
  if (!declaration || declaration === location) {
81026
81196
  error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
81027
- return void 0;
81197
+ return evaluatorResult(
81198
+ /*value*/
81199
+ void 0
81200
+ );
81028
81201
  }
81029
81202
  if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
81030
81203
  error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
81031
- return 0;
81204
+ return evaluatorResult(
81205
+ /*value*/
81206
+ 0
81207
+ );
81032
81208
  }
81033
81209
  return getEnumMemberValue(declaration);
81034
81210
  }
@@ -83169,7 +83345,10 @@ function createTypeChecker(host) {
83169
83345
  }
83170
83346
  function getEnumMemberValue(node) {
83171
83347
  computeEnumMemberValues(node.parent);
83172
- return getNodeLinks(node).enumMemberValue;
83348
+ return getNodeLinks(node).enumMemberValue ?? evaluatorResult(
83349
+ /*value*/
83350
+ void 0
83351
+ );
83173
83352
  }
83174
83353
  function canHaveConstantValue(node) {
83175
83354
  switch (node.kind) {
@@ -83182,13 +83361,13 @@ function createTypeChecker(host) {
83182
83361
  }
83183
83362
  function getConstantValue2(node) {
83184
83363
  if (node.kind === 306 /* EnumMember */) {
83185
- return getEnumMemberValue(node);
83364
+ return getEnumMemberValue(node).value;
83186
83365
  }
83187
83366
  const symbol = getNodeLinks(node).resolvedSymbol;
83188
83367
  if (symbol && symbol.flags & 8 /* EnumMember */) {
83189
83368
  const member = symbol.valueDeclaration;
83190
83369
  if (isEnumConst(member.parent)) {
83191
- return getEnumMemberValue(member);
83370
+ return getEnumMemberValue(member).value;
83192
83371
  }
83193
83372
  }
83194
83373
  return void 0;
@@ -83563,6 +83742,10 @@ function createTypeChecker(host) {
83563
83742
  const node = getParseTreeNode(nodeIn, canHaveConstantValue);
83564
83743
  return node ? getConstantValue2(node) : void 0;
83565
83744
  },
83745
+ getEnumMemberValue: (nodeIn) => {
83746
+ const node = getParseTreeNode(nodeIn, isEnumMember);
83747
+ return node ? getEnumMemberValue(node) : void 0;
83748
+ },
83566
83749
  collectLinkedAliases,
83567
83750
  getReferencedValueDeclaration,
83568
83751
  getReferencedValueDeclarations,
@@ -89781,7 +89964,8 @@ function transformTypeScript(context) {
89781
89964
  /*generateNameForComputedPropertyName*/
89782
89965
  false
89783
89966
  );
89784
- const valueExpression = transformEnumMemberDeclarationValue(member);
89967
+ const evaluated = resolver.getEnumMemberValue(member);
89968
+ const valueExpression = transformEnumMemberDeclarationValue(member, evaluated == null ? void 0 : evaluated.value);
89785
89969
  const innerAssignment = factory2.createAssignment(
89786
89970
  factory2.createElementAccessExpression(
89787
89971
  currentNamespaceContainerName,
@@ -89789,7 +89973,7 @@ function transformTypeScript(context) {
89789
89973
  ),
89790
89974
  valueExpression
89791
89975
  );
89792
- const outerAssignment = isSyntacticallyString(valueExpression) ? innerAssignment : factory2.createAssignment(
89976
+ const outerAssignment = typeof (evaluated == null ? void 0 : evaluated.value) === "string" || (evaluated == null ? void 0 : evaluated.isSyntacticallyString) ? innerAssignment : factory2.createAssignment(
89793
89977
  factory2.createElementAccessExpression(
89794
89978
  currentNamespaceContainerName,
89795
89979
  innerAssignment
@@ -89806,10 +89990,9 @@ function transformTypeScript(context) {
89806
89990
  member
89807
89991
  );
89808
89992
  }
89809
- function transformEnumMemberDeclarationValue(member) {
89810
- const value = resolver.getConstantValue(member);
89811
- if (value !== void 0) {
89812
- 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);
89813
89996
  } else {
89814
89997
  enableSubstitutionForNonQualifiedEnumMembers();
89815
89998
  if (member.initializer) {
@@ -111149,6 +111332,7 @@ var notImplementedResolver = {
111149
111332
  isEntityNameVisible: notImplemented,
111150
111333
  // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
111151
111334
  getConstantValue: notImplemented,
111335
+ getEnumMemberValue: notImplemented,
111152
111336
  getReferencedValueDeclaration: notImplemented,
111153
111337
  getReferencedValueDeclarations: notImplemented,
111154
111338
  getTypeReferenceSerializationKind: notImplemented,
@@ -126034,7 +126218,7 @@ function verboseReportProjectStatus(state, configFileName, status) {
126034
126218
  }
126035
126219
  }
126036
126220
 
126037
- // src/executeCommandLine/executeCommandLine.ts
126221
+ // src/compiler/executeCommandLine.ts
126038
126222
  function countLines(program) {
126039
126223
  const counts2 = getCountsMap();
126040
126224
  forEach(program.getSourceFiles(), (file) => {