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/typescript.js CHANGED
@@ -163,6 +163,7 @@ __export(typescript_exports, {
163
163
  SignatureKind: () => SignatureKind,
164
164
  SmartSelectionRange: () => ts_SmartSelectionRange_exports,
165
165
  SnippetKind: () => SnippetKind,
166
+ StatisticType: () => StatisticType,
166
167
  StructureIsReused: () => StructureIsReused,
167
168
  SymbolAccessibility: () => SymbolAccessibility,
168
169
  SymbolDisplay: () => ts_SymbolDisplay_exports,
@@ -411,6 +412,7 @@ __export(typescript_exports, {
411
412
  createExternalHelpersImportDeclarationIfNeeded: () => createExternalHelpersImportDeclarationIfNeeded,
412
413
  createFileDiagnostic: () => createFileDiagnostic,
413
414
  createFileDiagnosticFromMessageChain: () => createFileDiagnosticFromMessageChain,
415
+ createFlowNode: () => createFlowNode,
414
416
  createForOfBindingStatement: () => createForOfBindingStatement,
415
417
  createGetCanonicalFileName: () => createGetCanonicalFileName,
416
418
  createGetSourceFile: () => createGetSourceFile,
@@ -542,7 +544,9 @@ __export(typescript_exports, {
542
544
  escapeSnippetText: () => escapeSnippetText,
543
545
  escapeString: () => escapeString,
544
546
  escapeTemplateSubstitution: () => escapeTemplateSubstitution,
547
+ evaluatorResult: () => evaluatorResult,
545
548
  every: () => every,
549
+ executeCommandLine: () => executeCommandLine,
546
550
  expandPreOrPostfixIncrementOrDecrementExpression: () => expandPreOrPostfixIncrementOrDecrementExpression,
547
551
  explainFiles: () => explainFiles,
548
552
  explainIfFileIsRedirectAndImpliedFormat: () => explainIfFileIsRedirectAndImpliedFormat,
@@ -908,6 +912,7 @@ __export(typescript_exports, {
908
912
  getNewLineOrDefaultFromHost: () => getNewLineOrDefaultFromHost,
909
913
  getNewTargetContainer: () => getNewTargetContainer,
910
914
  getNextJSDocCommentLocation: () => getNextJSDocCommentLocation,
915
+ getNodeChildren: () => getNodeChildren,
911
916
  getNodeForGeneratedName: () => getNodeForGeneratedName,
912
917
  getNodeId: () => getNodeId,
913
918
  getNodeKind: () => getNodeKind,
@@ -1230,6 +1235,7 @@ __export(typescript_exports, {
1230
1235
  isBooleanLiteral: () => isBooleanLiteral,
1231
1236
  isBreakOrContinueStatement: () => isBreakOrContinueStatement,
1232
1237
  isBreakStatement: () => isBreakStatement,
1238
+ isBuild: () => isBuild,
1233
1239
  isBuildInfoFile: () => isBuildInfoFile,
1234
1240
  isBuilderProgram: () => isBuilderProgram2,
1235
1241
  isBundle: () => isBundle,
@@ -1761,7 +1767,6 @@ __export(typescript_exports, {
1761
1767
  isSuperProperty: () => isSuperProperty,
1762
1768
  isSupportedSourceFileName: () => isSupportedSourceFileName,
1763
1769
  isSwitchStatement: () => isSwitchStatement,
1764
- isSyntacticallyString: () => isSyntacticallyString,
1765
1770
  isSyntaxList: () => isSyntaxList,
1766
1771
  isSyntheticExpression: () => isSyntheticExpression,
1767
1772
  isSyntheticReference: () => isSyntheticReference,
@@ -2093,6 +2098,7 @@ __export(typescript_exports, {
2093
2098
  setInternalEmitFlags: () => setInternalEmitFlags,
2094
2099
  setLocalizedDiagnosticMessages: () => setLocalizedDiagnosticMessages,
2095
2100
  setModuleDefaultHelper: () => setModuleDefaultHelper,
2101
+ setNodeChildren: () => setNodeChildren,
2096
2102
  setNodeFlags: () => setNodeFlags,
2097
2103
  setObjectAllocator: () => setObjectAllocator,
2098
2104
  setOriginalNode: () => setOriginalNode,
@@ -2287,6 +2293,7 @@ __export(typescript_exports, {
2287
2293
  unorderedRemoveItem: () => unorderedRemoveItem,
2288
2294
  unorderedRemoveItemAt: () => unorderedRemoveItemAt,
2289
2295
  unreachableCodeIsError: () => unreachableCodeIsError,
2296
+ unsetNodeChildren: () => unsetNodeChildren,
2290
2297
  unusedLabelIsError: () => unusedLabelIsError,
2291
2298
  unwrapInnermostStatementOfLabel: () => unwrapInnermostStatementOfLabel,
2292
2299
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
@@ -2328,7 +2335,7 @@ module.exports = __toCommonJS(typescript_exports);
2328
2335
 
2329
2336
  // src/compiler/corePublic.ts
2330
2337
  var versionMajorMinor = "5.5";
2331
- var version = `${versionMajorMinor}.0-dev.20240402`;
2338
+ var version = `${versionMajorMinor}.0-dev.20240405`;
2332
2339
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2340
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2341
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4392,6 +4399,7 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
4392
4399
  attachFlowNodeDebugInfoWorker(flowNode);
4393
4400
  }
4394
4401
  }
4402
+ return flowNode;
4395
4403
  }
4396
4404
  Debug2.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
4397
4405
  let nodeArrayProto;
@@ -4667,7 +4675,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
4667
4675
  return !!(f.flags & 128 /* SwitchClause */);
4668
4676
  }
4669
4677
  function hasAntecedents(f) {
4670
- return !!(f.flags & 12 /* Label */) && !!f.antecedents;
4678
+ return !!(f.flags & 12 /* Label */) && !!f.antecedent;
4671
4679
  }
4672
4680
  function hasAntecedent(f) {
4673
4681
  return !!(f.flags & hasAntecedentFlags);
@@ -4716,7 +4724,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
4716
4724
  links[id] = graphNode = { id, flowNode: flowNode2, edges: [], text: "", lane: -1, endLane: -1, level: -1, circular: false };
4717
4725
  nodes.push(graphNode);
4718
4726
  if (hasAntecedents(flowNode2)) {
4719
- for (const antecedent of flowNode2.antecedents) {
4727
+ for (const antecedent of flowNode2.antecedent) {
4720
4728
  buildGraphEdge(graphNode, antecedent, seen);
4721
4729
  }
4722
4730
  } else if (hasAntecedent(flowNode2)) {
@@ -4774,7 +4782,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
4774
4782
  node.endLane = lane;
4775
4783
  }
4776
4784
  }
4777
- function getHeader(flags) {
4785
+ function getHeader2(flags) {
4778
4786
  if (flags & 2 /* Start */)
4779
4787
  return "Start";
4780
4788
  if (flags & 4 /* BranchLabel */)
@@ -4809,18 +4817,15 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
4809
4817
  );
4810
4818
  }
4811
4819
  function renderFlowNode(flowNode2, circular) {
4812
- let text = getHeader(flowNode2.flags);
4820
+ let text = getHeader2(flowNode2.flags);
4813
4821
  if (circular) {
4814
4822
  text = `${text}#${getDebugFlowNodeId(flowNode2)}`;
4815
4823
  }
4816
- if (hasNode(flowNode2)) {
4817
- if (flowNode2.node) {
4818
- text += ` (${getNodeText(flowNode2.node)})`;
4819
- }
4820
- } else if (isFlowSwitchClause(flowNode2)) {
4824
+ if (isFlowSwitchClause(flowNode2)) {
4821
4825
  const clauses = [];
4822
- for (let i = flowNode2.clauseStart; i < flowNode2.clauseEnd; i++) {
4823
- const clause = flowNode2.switchStatement.caseBlock.clauses[i];
4826
+ const { switchStatement, clauseStart, clauseEnd } = flowNode2.node;
4827
+ for (let i = clauseStart; i < clauseEnd; i++) {
4828
+ const clause = switchStatement.caseBlock.clauses[i];
4824
4829
  if (isDefaultClause(clause)) {
4825
4830
  clauses.push("default");
4826
4831
  } else {
@@ -4828,6 +4833,10 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
4828
4833
  }
4829
4834
  }
4830
4835
  text += ` (${clauses.join(", ")})`;
4836
+ } else if (hasNode(flowNode2)) {
4837
+ if (flowNode2.node) {
4838
+ text += ` (${getNodeText(flowNode2.node)})`;
4839
+ }
4831
4840
  }
4832
4841
  return circular === "circularity" ? `Circular(${text})` : text;
4833
4842
  }
@@ -15549,8 +15558,11 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
15549
15558
  if (includeJsDoc && hasJSDocNodes(node)) {
15550
15559
  return getTokenPosOfNode(node.jsDoc[0], sourceFile);
15551
15560
  }
15552
- if (node.kind === 352 /* SyntaxList */ && node._children.length > 0) {
15553
- return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
15561
+ if (node.kind === 352 /* SyntaxList */) {
15562
+ const first2 = firstOrUndefined(getNodeChildren(node));
15563
+ if (first2) {
15564
+ return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
15565
+ }
15554
15566
  }
15555
15567
  return skipTrivia(
15556
15568
  (sourceFile || getSourceFileOfNode(node)).text,
@@ -21926,79 +21938,81 @@ function replaceFirstStar(s, replacement) {
21926
21938
  function getNameFromImportAttribute(node) {
21927
21939
  return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
21928
21940
  }
21929
- function isSyntacticallyString(expr) {
21930
- expr = skipOuterExpressions(expr);
21931
- switch (expr.kind) {
21932
- case 226 /* BinaryExpression */:
21933
- const left = expr.left;
21934
- const right = expr.right;
21935
- return expr.operatorToken.kind === 40 /* PlusToken */ && (isSyntacticallyString(left) || isSyntacticallyString(right));
21936
- case 228 /* TemplateExpression */:
21937
- case 11 /* StringLiteral */:
21938
- case 15 /* NoSubstitutionTemplateLiteral */:
21939
- return true;
21940
- }
21941
- return false;
21941
+ function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false) {
21942
+ return { value, isSyntacticallyString, resolvedOtherFiles };
21942
21943
  }
21943
21944
  function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
21944
21945
  function evaluate(expr, location) {
21946
+ let isSyntacticallyString = false;
21947
+ let resolvedOtherFiles = false;
21948
+ expr = skipParentheses(expr);
21945
21949
  switch (expr.kind) {
21946
21950
  case 224 /* PrefixUnaryExpression */:
21947
- const value = evaluate(expr.operand, location);
21948
- if (typeof value === "number") {
21951
+ const result = evaluate(expr.operand, location);
21952
+ resolvedOtherFiles = result.resolvedOtherFiles;
21953
+ if (typeof result.value === "number") {
21949
21954
  switch (expr.operator) {
21950
21955
  case 40 /* PlusToken */:
21951
- return value;
21956
+ return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles);
21952
21957
  case 41 /* MinusToken */:
21953
- return -value;
21958
+ return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles);
21954
21959
  case 55 /* TildeToken */:
21955
- return ~value;
21960
+ return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles);
21956
21961
  }
21957
21962
  }
21958
21963
  break;
21959
- case 226 /* BinaryExpression */:
21964
+ case 226 /* BinaryExpression */: {
21960
21965
  const left = evaluate(expr.left, location);
21961
21966
  const right = evaluate(expr.right, location);
21962
- if (typeof left === "number" && typeof right === "number") {
21967
+ isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
21968
+ resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
21969
+ if (typeof left.value === "number" && typeof right.value === "number") {
21963
21970
  switch (expr.operatorToken.kind) {
21964
21971
  case 52 /* BarToken */:
21965
- return left | right;
21972
+ return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles);
21966
21973
  case 51 /* AmpersandToken */:
21967
- return left & right;
21974
+ return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles);
21968
21975
  case 49 /* GreaterThanGreaterThanToken */:
21969
- return left >> right;
21976
+ return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles);
21970
21977
  case 50 /* GreaterThanGreaterThanGreaterThanToken */:
21971
- return left >>> right;
21978
+ return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles);
21972
21979
  case 48 /* LessThanLessThanToken */:
21973
- return left << right;
21980
+ return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles);
21974
21981
  case 53 /* CaretToken */:
21975
- return left ^ right;
21982
+ return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles);
21976
21983
  case 42 /* AsteriskToken */:
21977
- return left * right;
21984
+ return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles);
21978
21985
  case 44 /* SlashToken */:
21979
- return left / right;
21986
+ return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles);
21980
21987
  case 40 /* PlusToken */:
21981
- return left + right;
21988
+ return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles);
21982
21989
  case 41 /* MinusToken */:
21983
- return left - right;
21990
+ return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles);
21984
21991
  case 45 /* PercentToken */:
21985
- return left % right;
21992
+ return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles);
21986
21993
  case 43 /* AsteriskAsteriskToken */:
21987
- return left ** right;
21994
+ return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles);
21988
21995
  }
21989
- } else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
21990
- return "" + left + right;
21996
+ } else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
21997
+ return evaluatorResult(
21998
+ "" + left.value + right.value,
21999
+ isSyntacticallyString,
22000
+ resolvedOtherFiles
22001
+ );
21991
22002
  }
21992
22003
  break;
22004
+ }
21993
22005
  case 11 /* StringLiteral */:
21994
22006
  case 15 /* NoSubstitutionTemplateLiteral */:
21995
- return expr.text;
22007
+ return evaluatorResult(
22008
+ expr.text,
22009
+ /*isSyntacticallyString*/
22010
+ true
22011
+ );
21996
22012
  case 228 /* TemplateExpression */:
21997
22013
  return evaluateTemplateExpression(expr, location);
21998
22014
  case 9 /* NumericLiteral */:
21999
- return +expr.text;
22000
- case 217 /* ParenthesizedExpression */:
22001
- return evaluate(expr.expression, location);
22015
+ return evaluatorResult(+expr.text);
22002
22016
  case 80 /* Identifier */:
22003
22017
  return evaluateEntityNameExpression(expr, location);
22004
22018
  case 211 /* PropertyAccessExpression */:
@@ -22009,19 +22023,36 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
22009
22023
  case 212 /* ElementAccessExpression */:
22010
22024
  return evaluateElementAccessExpression(expr, location);
22011
22025
  }
22012
- return void 0;
22026
+ return evaluatorResult(
22027
+ /*value*/
22028
+ void 0,
22029
+ isSyntacticallyString,
22030
+ resolvedOtherFiles
22031
+ );
22013
22032
  }
22014
22033
  function evaluateTemplateExpression(expr, location) {
22015
22034
  let result = expr.head.text;
22035
+ let resolvedOtherFiles = false;
22016
22036
  for (const span of expr.templateSpans) {
22017
- const value = evaluate(span.expression, location);
22018
- if (value === void 0) {
22019
- return void 0;
22037
+ const spanResult = evaluate(span.expression, location);
22038
+ if (spanResult.value === void 0) {
22039
+ return evaluatorResult(
22040
+ /*value*/
22041
+ void 0,
22042
+ /*isSyntacticallyString*/
22043
+ true
22044
+ );
22020
22045
  }
22021
- result += value;
22046
+ result += spanResult.value;
22022
22047
  result += span.literal.text;
22048
+ resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
22023
22049
  }
22024
- return result;
22050
+ return evaluatorResult(
22051
+ result,
22052
+ /*isSyntacticallyString*/
22053
+ true,
22054
+ resolvedOtherFiles
22055
+ );
22025
22056
  }
22026
22057
  return evaluate;
22027
22058
  }
@@ -26176,7 +26207,7 @@ function createNodeFactory(flags, baseFactory2) {
26176
26207
  }
26177
26208
  function createSyntaxList3(children) {
26178
26209
  const node = createBaseNode(352 /* SyntaxList */);
26179
- node._children = children;
26210
+ setNodeChildren(node, children);
26180
26211
  return node;
26181
26212
  }
26182
26213
  function createNotEmittedStatement(original) {
@@ -29084,6 +29115,19 @@ function isSyntaxList(n) {
29084
29115
  return n.kind === 352 /* SyntaxList */;
29085
29116
  }
29086
29117
 
29118
+ // src/compiler/factory/nodeChildren.ts
29119
+ var nodeChildren = /* @__PURE__ */ new WeakMap();
29120
+ function getNodeChildren(node) {
29121
+ return nodeChildren.get(node);
29122
+ }
29123
+ function setNodeChildren(node, children) {
29124
+ nodeChildren.set(node, children);
29125
+ return children;
29126
+ }
29127
+ function unsetNodeChildren(node) {
29128
+ nodeChildren.delete(node);
29129
+ }
29130
+
29087
29131
  // src/compiler/factory/utilities.ts
29088
29132
  function createEmptyExports(factory2) {
29089
29133
  return factory2.createExportDeclaration(
@@ -37756,9 +37800,7 @@ var IncrementalParser;
37756
37800
  if (aggressiveChecks && shouldCheckNode(node)) {
37757
37801
  text = oldText.substring(node.pos, node.end);
37758
37802
  }
37759
- if (node._children) {
37760
- node._children = void 0;
37761
- }
37803
+ unsetNodeChildren(node);
37762
37804
  setTextRangePosEnd(node, node.pos + delta, node.end + delta);
37763
37805
  if (aggressiveChecks && shouldCheckNode(node)) {
37764
37806
  Debug.assert(text === newText.substring(node.pos, node.end));
@@ -37772,7 +37814,6 @@ var IncrementalParser;
37772
37814
  checkNodePositions(node, aggressiveChecks);
37773
37815
  }
37774
37816
  function visitArray2(array) {
37775
- array._children = void 0;
37776
37817
  setTextRangePosEnd(array, array.pos + delta, array.end + delta);
37777
37818
  for (const node of array) {
37778
37819
  visitNode3(node);
@@ -37844,7 +37885,7 @@ var IncrementalParser;
37844
37885
  const fullEnd = child.end;
37845
37886
  if (fullEnd >= changeStart) {
37846
37887
  child.intersectsChange = true;
37847
- child._children = void 0;
37888
+ unsetNodeChildren(child);
37848
37889
  adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
37849
37890
  forEachChild(child, visitNode3, visitArray2);
37850
37891
  if (hasJSDocNodes(child)) {
@@ -37874,7 +37915,6 @@ var IncrementalParser;
37874
37915
  const fullEnd = array.end;
37875
37916
  if (fullEnd >= changeStart) {
37876
37917
  array.intersectsChange = true;
37877
- array._children = void 0;
37878
37918
  adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
37879
37919
  for (const node of array) {
37880
37920
  visitNode3(node);
@@ -44272,9 +44312,8 @@ var ContainerFlags = /* @__PURE__ */ ((ContainerFlags2) => {
44272
44312
  ContainerFlags2[ContainerFlags2["IsObjectLiteralOrClassExpressionMethodOrAccessor"] = 128] = "IsObjectLiteralOrClassExpressionMethodOrAccessor";
44273
44313
  return ContainerFlags2;
44274
44314
  })(ContainerFlags || {});
44275
- function initFlowNode(node) {
44276
- Debug.attachFlowNodeDebugInfo(node);
44277
- return node;
44315
+ function createFlowNode(flags, node, antecedent) {
44316
+ return Debug.attachFlowNodeDebugInfo({ flags, id: 0, node, antecedent });
44278
44317
  }
44279
44318
  var binder = /* @__PURE__ */ createBinder();
44280
44319
  function bindSourceFile(file, options) {
@@ -44308,14 +44347,27 @@ function createBinder() {
44308
44347
  var preSwitchCaseFlow;
44309
44348
  var activeLabelList;
44310
44349
  var hasExplicitReturn;
44350
+ var hasFlowEffects;
44311
44351
  var emitFlags;
44312
44352
  var inStrictMode;
44313
44353
  var inAssignmentPattern = false;
44314
44354
  var symbolCount = 0;
44315
44355
  var Symbol47;
44316
44356
  var classifiableNames;
44317
- var unreachableFlow = { flags: 1 /* Unreachable */ };
44318
- var reportedUnreachableFlow = { flags: 1 /* Unreachable */ };
44357
+ var unreachableFlow = createFlowNode(
44358
+ 1 /* Unreachable */,
44359
+ /*node*/
44360
+ void 0,
44361
+ /*antecedent*/
44362
+ void 0
44363
+ );
44364
+ var reportedUnreachableFlow = createFlowNode(
44365
+ 1 /* Unreachable */,
44366
+ /*node*/
44367
+ void 0,
44368
+ /*antecedent*/
44369
+ void 0
44370
+ );
44319
44371
  var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
44320
44372
  return bindSourceFile2;
44321
44373
  function createDiagnosticForNode2(node, message, ...args) {
@@ -44367,6 +44419,7 @@ function createBinder() {
44367
44419
  currentExceptionTarget = void 0;
44368
44420
  activeLabelList = void 0;
44369
44421
  hasExplicitReturn = false;
44422
+ hasFlowEffects = false;
44370
44423
  inAssignmentPattern = false;
44371
44424
  emitFlags = 0 /* None */;
44372
44425
  }
@@ -44634,7 +44687,13 @@ function createBinder() {
44634
44687
  const saveHasExplicitReturn = hasExplicitReturn;
44635
44688
  const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */;
44636
44689
  if (!isImmediatelyInvoked) {
44637
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
44690
+ currentFlow = createFlowNode(
44691
+ 2 /* Start */,
44692
+ /*node*/
44693
+ void 0,
44694
+ /*antecedent*/
44695
+ void 0
44696
+ );
44638
44697
  if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
44639
44698
  currentFlow.node = node;
44640
44699
  }
@@ -44824,8 +44883,8 @@ function createBinder() {
44824
44883
  function isNarrowingExpression(expr) {
44825
44884
  switch (expr.kind) {
44826
44885
  case 80 /* Identifier */:
44827
- case 81 /* PrivateIdentifier */:
44828
44886
  case 110 /* ThisKeyword */:
44887
+ return true;
44829
44888
  case 211 /* PropertyAccessExpression */:
44830
44889
  case 212 /* ElementAccessExpression */:
44831
44890
  return containsNarrowableReference(expr);
@@ -44847,7 +44906,22 @@ function createBinder() {
44847
44906
  return false;
44848
44907
  }
44849
44908
  function isNarrowableReference(expr) {
44850
- 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);
44909
+ switch (expr.kind) {
44910
+ case 80 /* Identifier */:
44911
+ case 110 /* ThisKeyword */:
44912
+ case 108 /* SuperKeyword */:
44913
+ case 236 /* MetaProperty */:
44914
+ return true;
44915
+ case 211 /* PropertyAccessExpression */:
44916
+ case 217 /* ParenthesizedExpression */:
44917
+ case 235 /* NonNullExpression */:
44918
+ return isNarrowableReference(expr.expression);
44919
+ case 212 /* ElementAccessExpression */:
44920
+ return (isStringOrNumericLiteralLike(expr.argumentExpression) || isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression);
44921
+ case 226 /* BinaryExpression */:
44922
+ return expr.operatorToken.kind === 28 /* CommaToken */ && isNarrowableReference(expr.right) || isAssignmentOperator(expr.operatorToken.kind) && isLeftHandSideExpression(expr.left);
44923
+ }
44924
+ return false;
44851
44925
  }
44852
44926
  function containsNarrowableReference(expr) {
44853
44927
  return isNarrowableReference(expr) || isOptionalChain(expr) && containsNarrowableReference(expr.expression);
@@ -44904,20 +44978,32 @@ function createBinder() {
44904
44978
  return containsNarrowableReference(expr);
44905
44979
  }
44906
44980
  function createBranchLabel() {
44907
- return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: void 0 });
44981
+ return createFlowNode(
44982
+ 4 /* BranchLabel */,
44983
+ /*node*/
44984
+ void 0,
44985
+ /*antecedent*/
44986
+ void 0
44987
+ );
44908
44988
  }
44909
44989
  function createLoopLabel() {
44910
- return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: void 0 });
44990
+ return createFlowNode(
44991
+ 8 /* LoopLabel */,
44992
+ /*node*/
44993
+ void 0,
44994
+ /*antecedent*/
44995
+ void 0
44996
+ );
44911
44997
  }
44912
44998
  function createReduceLabel(target, antecedents, antecedent) {
44913
- return initFlowNode({ flags: 1024 /* ReduceLabel */, target, antecedents, antecedent });
44999
+ return createFlowNode(1024 /* ReduceLabel */, { target, antecedents }, antecedent);
44914
45000
  }
44915
45001
  function setFlowNodeReferenced(flow) {
44916
45002
  flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */;
44917
45003
  }
44918
45004
  function addAntecedent(label, antecedent) {
44919
- if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.antecedents, antecedent)) {
44920
- (label.antecedents || (label.antecedents = [])).push(antecedent);
45005
+ if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.antecedent, antecedent)) {
45006
+ (label.antecedent || (label.antecedent = [])).push(antecedent);
44921
45007
  setFlowNodeReferenced(antecedent);
44922
45008
  }
44923
45009
  }
@@ -44935,15 +45021,16 @@ function createBinder() {
44935
45021
  return antecedent;
44936
45022
  }
44937
45023
  setFlowNodeReferenced(antecedent);
44938
- return initFlowNode({ flags, antecedent, node: expression });
45024
+ return createFlowNode(flags, expression, antecedent);
44939
45025
  }
44940
45026
  function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
44941
45027
  setFlowNodeReferenced(antecedent);
44942
- return initFlowNode({ flags: 128 /* SwitchClause */, antecedent, switchStatement, clauseStart, clauseEnd });
45028
+ return createFlowNode(128 /* SwitchClause */, { switchStatement, clauseStart, clauseEnd }, antecedent);
44943
45029
  }
44944
45030
  function createFlowMutation(flags, antecedent, node) {
44945
45031
  setFlowNodeReferenced(antecedent);
44946
- const result = initFlowNode({ flags, antecedent, node });
45032
+ hasFlowEffects = true;
45033
+ const result = createFlowNode(flags, node, antecedent);
44947
45034
  if (currentExceptionTarget) {
44948
45035
  addAntecedent(currentExceptionTarget, result);
44949
45036
  }
@@ -44951,10 +45038,11 @@ function createBinder() {
44951
45038
  }
44952
45039
  function createFlowCall(antecedent, node) {
44953
45040
  setFlowNodeReferenced(antecedent);
44954
- return initFlowNode({ flags: 512 /* Call */, antecedent, node });
45041
+ hasFlowEffects = true;
45042
+ return createFlowNode(512 /* Call */, node, antecedent);
44955
45043
  }
44956
45044
  function finishFlowLabel(flow) {
44957
- const antecedents = flow.antecedents;
45045
+ const antecedents = flow.antecedent;
44958
45046
  if (!antecedents) {
44959
45047
  return unreachableFlow;
44960
45048
  }
@@ -45108,6 +45196,7 @@ function createBinder() {
45108
45196
  }
45109
45197
  }
45110
45198
  currentFlow = unreachableFlow;
45199
+ hasFlowEffects = true;
45111
45200
  }
45112
45201
  function findActiveLabel(name) {
45113
45202
  for (let label = activeLabelList; label; label = label.next) {
@@ -45122,6 +45211,7 @@ function createBinder() {
45122
45211
  if (flowLabel) {
45123
45212
  addAntecedent(flowLabel, currentFlow);
45124
45213
  currentFlow = unreachableFlow;
45214
+ hasFlowEffects = true;
45125
45215
  }
45126
45216
  }
45127
45217
  function bindBreakOrContinueStatement(node) {
@@ -45161,19 +45251,19 @@ function createBinder() {
45161
45251
  currentExceptionTarget = saveExceptionTarget;
45162
45252
  if (node.finallyBlock) {
45163
45253
  const finallyLabel = createBranchLabel();
45164
- finallyLabel.antecedents = concatenate(concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
45254
+ finallyLabel.antecedent = concatenate(concatenate(normalExitLabel.antecedent, exceptionLabel.antecedent), returnLabel.antecedent);
45165
45255
  currentFlow = finallyLabel;
45166
45256
  bind(node.finallyBlock);
45167
45257
  if (currentFlow.flags & 1 /* Unreachable */) {
45168
45258
  currentFlow = unreachableFlow;
45169
45259
  } else {
45170
- if (currentReturnTarget && returnLabel.antecedents) {
45171
- addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
45260
+ if (currentReturnTarget && returnLabel.antecedent) {
45261
+ addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedent, currentFlow));
45172
45262
  }
45173
- if (currentExceptionTarget && exceptionLabel.antecedents) {
45174
- addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
45263
+ if (currentExceptionTarget && exceptionLabel.antecedent) {
45264
+ addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedent, currentFlow));
45175
45265
  }
45176
- currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
45266
+ currentFlow = normalExitLabel.antecedent ? createReduceLabel(finallyLabel, normalExitLabel.antecedent, currentFlow) : unreachableFlow;
45177
45267
  }
45178
45268
  } else {
45179
45269
  currentFlow = finishFlowLabel(normalExitLabel);
@@ -45189,7 +45279,7 @@ function createBinder() {
45189
45279
  bind(node.caseBlock);
45190
45280
  addAntecedent(postSwitchLabel, currentFlow);
45191
45281
  const hasDefault = forEach(node.caseBlock.clauses, (c) => c.kind === 297 /* DefaultClause */);
45192
- node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
45282
+ node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedent;
45193
45283
  if (!hasDefault) {
45194
45284
  addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
45195
45285
  }
@@ -45377,8 +45467,12 @@ function createBinder() {
45377
45467
  if (isLogicalOrCoalescingBinaryOperator(operator) || isLogicalOrCoalescingAssignmentOperator(operator)) {
45378
45468
  if (isTopLevelLogicalExpression(node)) {
45379
45469
  const postExpressionLabel = createBranchLabel();
45470
+ const saveCurrentFlow = currentFlow;
45471
+ const saveHasFlowEffects = hasFlowEffects;
45472
+ hasFlowEffects = false;
45380
45473
  bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
45381
- currentFlow = finishFlowLabel(postExpressionLabel);
45474
+ currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
45475
+ hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
45382
45476
  } else {
45383
45477
  bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
45384
45478
  }
@@ -45450,6 +45544,9 @@ function createBinder() {
45450
45544
  const trueLabel = createBranchLabel();
45451
45545
  const falseLabel = createBranchLabel();
45452
45546
  const postExpressionLabel = createBranchLabel();
45547
+ const saveCurrentFlow = currentFlow;
45548
+ const saveHasFlowEffects = hasFlowEffects;
45549
+ hasFlowEffects = false;
45453
45550
  bindCondition(node.condition, trueLabel, falseLabel);
45454
45551
  currentFlow = finishFlowLabel(trueLabel);
45455
45552
  bind(node.questionToken);
@@ -45459,7 +45556,8 @@ function createBinder() {
45459
45556
  bind(node.colonToken);
45460
45557
  bind(node.whenFalse);
45461
45558
  addAntecedent(postExpressionLabel, currentFlow);
45462
- currentFlow = finishFlowLabel(postExpressionLabel);
45559
+ currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
45560
+ hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
45463
45561
  }
45464
45562
  function bindInitializedVariableFlow(node) {
45465
45563
  const name = !isOmittedExpression(node) ? node.name : void 0;
@@ -45571,8 +45669,11 @@ function createBinder() {
45571
45669
  function bindOptionalChainFlow(node) {
45572
45670
  if (isTopLevelLogicalExpression(node)) {
45573
45671
  const postExpressionLabel = createBranchLabel();
45672
+ const saveCurrentFlow = currentFlow;
45673
+ const saveHasFlowEffects = hasFlowEffects;
45574
45674
  bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
45575
- currentFlow = finishFlowLabel(postExpressionLabel);
45675
+ currentFlow = hasFlowEffects ? finishFlowLabel(postExpressionLabel) : saveCurrentFlow;
45676
+ hasFlowEffects || (hasFlowEffects = saveHasFlowEffects);
45576
45677
  } else {
45577
45678
  bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
45578
45679
  }
@@ -45793,7 +45894,13 @@ function createBinder() {
45793
45894
  const host = typeAlias.parent.parent;
45794
45895
  container = getEnclosingContainer(host) || file;
45795
45896
  blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
45796
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
45897
+ currentFlow = createFlowNode(
45898
+ 2 /* Start */,
45899
+ /*node*/
45900
+ void 0,
45901
+ /*antecedent*/
45902
+ void 0
45903
+ );
45797
45904
  parent2 = typeAlias;
45798
45905
  bind(typeAlias.typeExpression);
45799
45906
  const declName = getNameOfDeclaration(typeAlias);
@@ -45863,7 +45970,13 @@ function createBinder() {
45863
45970
  const enclosingBlockScopeContainer = host ? getEnclosingBlockScopeContainer(host) : void 0;
45864
45971
  container = enclosingContainer || file;
45865
45972
  blockScopeContainer = enclosingBlockScopeContainer || file;
45866
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
45973
+ currentFlow = createFlowNode(
45974
+ 2 /* Start */,
45975
+ /*node*/
45976
+ void 0,
45977
+ /*antecedent*/
45978
+ void 0
45979
+ );
45867
45980
  parent2 = jsDocImportTag;
45868
45981
  bind(jsDocImportTag.importClause);
45869
45982
  }
@@ -48307,6 +48420,7 @@ function createTypeChecker(host) {
48307
48420
  isArgumentsSymbol: (symbol) => symbol === argumentsSymbol,
48308
48421
  isUnknownSymbol: (symbol) => symbol === unknownSymbol,
48309
48422
  getMergedSymbol,
48423
+ symbolIsValue,
48310
48424
  getDiagnostics: getDiagnostics2,
48311
48425
  getGlobalDiagnostics,
48312
48426
  getRecursionIdentity,
@@ -52615,7 +52729,7 @@ function createTypeChecker(host) {
52615
52729
  }
52616
52730
  function getMeaningOfEntityNameReference(entityName) {
52617
52731
  let meaning;
52618
- if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
52732
+ 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) {
52619
52733
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
52620
52734
  } 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) {
52621
52735
  meaning = 1920 /* Namespace */;
@@ -53875,68 +53989,7 @@ function createTypeChecker(host) {
53875
53989
  /*skipUnionExpanding*/
53876
53990
  true
53877
53991
  )[0];
53878
- let cleanup;
53879
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
53880
- let pushFakeScope2 = function(kind2, addAll) {
53881
- Debug.assert(context.enclosingDeclaration);
53882
- let existingFakeScope;
53883
- if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
53884
- existingFakeScope = context.enclosingDeclaration;
53885
- } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
53886
- existingFakeScope = context.enclosingDeclaration.parent;
53887
- }
53888
- Debug.assertOptionalNode(existingFakeScope, isBlock);
53889
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53890
- let newLocals;
53891
- addAll((name, symbol) => {
53892
- if (!locals.has(name)) {
53893
- newLocals = append(newLocals, name);
53894
- locals.set(name, symbol);
53895
- }
53896
- });
53897
- if (!newLocals)
53898
- return;
53899
- const oldCleanup = cleanup;
53900
- function undo() {
53901
- forEach(newLocals, (s) => locals.delete(s));
53902
- oldCleanup == null ? void 0 : oldCleanup();
53903
- }
53904
- if (existingFakeScope) {
53905
- cleanup = undo;
53906
- } else {
53907
- const fakeScope = parseNodeFactory.createBlock(emptyArray);
53908
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
53909
- fakeScope.locals = locals;
53910
- const saveEnclosingDeclaration = context.enclosingDeclaration;
53911
- setParent(fakeScope, saveEnclosingDeclaration);
53912
- context.enclosingDeclaration = fakeScope;
53913
- cleanup = () => {
53914
- context.enclosingDeclaration = saveEnclosingDeclaration;
53915
- undo();
53916
- };
53917
- }
53918
- };
53919
- var pushFakeScope = pushFakeScope2;
53920
- pushFakeScope2(
53921
- "params",
53922
- (add) => {
53923
- for (const param of expandedParams) {
53924
- add(param.escapedName, param);
53925
- }
53926
- }
53927
- );
53928
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53929
- pushFakeScope2(
53930
- "typeParams",
53931
- (add) => {
53932
- for (const typeParam of signature.typeParameters ?? emptyArray) {
53933
- const typeParamName = typeParameterToName(typeParam, context).escapedText;
53934
- add(typeParamName, typeParam.symbol);
53935
- }
53936
- }
53937
- );
53938
- }
53939
- }
53992
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
53940
53993
  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 */));
53941
53994
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
53942
53995
  if (thisParameter) {
@@ -54027,6 +54080,111 @@ function createTypeChecker(host) {
54027
54080
  cleanup == null ? void 0 : cleanup();
54028
54081
  return node;
54029
54082
  }
54083
+ function isNewScopeNode(node) {
54084
+ return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
54085
+ }
54086
+ function getTypeParametersInScope(node) {
54087
+ return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
54088
+ }
54089
+ function getParametersInScope(node) {
54090
+ return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
54091
+ getSignatureFromDeclaration(node),
54092
+ /*skipUnionExpanding*/
54093
+ true
54094
+ )[0] : void 0;
54095
+ }
54096
+ function enterNewScope(context, declaration, expandedParams, typeParameters) {
54097
+ let cleanup;
54098
+ if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
54099
+ let pushFakeScope2 = function(kind, addAll) {
54100
+ Debug.assert(context.enclosingDeclaration);
54101
+ let existingFakeScope;
54102
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind) {
54103
+ existingFakeScope = context.enclosingDeclaration;
54104
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind) {
54105
+ existingFakeScope = context.enclosingDeclaration.parent;
54106
+ }
54107
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
54108
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
54109
+ let newLocals;
54110
+ addAll((name, symbol) => {
54111
+ if (!locals.has(name)) {
54112
+ newLocals = append(newLocals, name);
54113
+ locals.set(name, symbol);
54114
+ }
54115
+ });
54116
+ if (!newLocals)
54117
+ return;
54118
+ const oldCleanup = cleanup;
54119
+ function undo() {
54120
+ forEach(newLocals, (s) => locals.delete(s));
54121
+ oldCleanup == null ? void 0 : oldCleanup();
54122
+ }
54123
+ if (existingFakeScope) {
54124
+ cleanup = undo;
54125
+ } else {
54126
+ const fakeScope = parseNodeFactory.createBlock(emptyArray);
54127
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
54128
+ fakeScope.locals = locals;
54129
+ const saveEnclosingDeclaration = context.enclosingDeclaration;
54130
+ setParent(fakeScope, saveEnclosingDeclaration);
54131
+ context.enclosingDeclaration = fakeScope;
54132
+ cleanup = () => {
54133
+ context.enclosingDeclaration = saveEnclosingDeclaration;
54134
+ undo();
54135
+ };
54136
+ }
54137
+ };
54138
+ var pushFakeScope = pushFakeScope2;
54139
+ pushFakeScope2(
54140
+ "params",
54141
+ (add) => {
54142
+ for (const param of expandedParams ?? emptyArray) {
54143
+ if (!forEach(param.declarations, (d) => {
54144
+ if (isParameter(d) && isBindingPattern(d.name)) {
54145
+ bindPattern(d.name);
54146
+ return true;
54147
+ }
54148
+ return void 0;
54149
+ function bindPattern(p) {
54150
+ forEach(p.elements, (e) => {
54151
+ switch (e.kind) {
54152
+ case 232 /* OmittedExpression */:
54153
+ return;
54154
+ case 208 /* BindingElement */:
54155
+ return bindElement(e);
54156
+ default:
54157
+ return Debug.assertNever(e);
54158
+ }
54159
+ });
54160
+ }
54161
+ function bindElement(e) {
54162
+ if (isBindingPattern(e.name)) {
54163
+ return bindPattern(e.name);
54164
+ }
54165
+ const symbol = getSymbolOfDeclaration(e);
54166
+ add(symbol.escapedName, symbol);
54167
+ }
54168
+ })) {
54169
+ add(param.escapedName, param);
54170
+ }
54171
+ }
54172
+ }
54173
+ );
54174
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
54175
+ pushFakeScope2(
54176
+ "typeParams",
54177
+ (add) => {
54178
+ for (const typeParam of typeParameters ?? emptyArray) {
54179
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
54180
+ add(typeParamName, typeParam.symbol);
54181
+ }
54182
+ }
54183
+ );
54184
+ }
54185
+ return cleanup;
54186
+ }
54187
+ }
54030
54188
  function tryGetThisParameterDeclaration(signature, context) {
54031
54189
  if (signature.thisParameter) {
54032
54190
  return symbolToParameterDeclaration(signature.thisParameter, context);
@@ -54645,6 +54803,9 @@ function createTypeChecker(host) {
54645
54803
  if (initial.typeParameterSymbolList) {
54646
54804
  initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
54647
54805
  }
54806
+ if (initial.typeParameterNamesByTextNextNameCount) {
54807
+ initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
54808
+ }
54648
54809
  initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
54649
54810
  return initial;
54650
54811
  }
@@ -54652,7 +54813,16 @@ function createTypeChecker(host) {
54652
54813
  return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
54653
54814
  }
54654
54815
  function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
54655
- return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54816
+ if (!(getObjectFlags(type) & 4 /* Reference */))
54817
+ return true;
54818
+ if (!isTypeReferenceNode(existing))
54819
+ return true;
54820
+ void getTypeFromTypeReference(existing);
54821
+ const symbol = getNodeLinks(existing).resolvedSymbol;
54822
+ const existingTarget = symbol && getDeclaredTypeOfSymbol(symbol);
54823
+ if (!existingTarget || existingTarget !== type.target)
54824
+ return true;
54825
+ return length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54656
54826
  }
54657
54827
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
54658
54828
  while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
@@ -54735,7 +54905,28 @@ function createTypeChecker(host) {
54735
54905
  return { introducesError, node };
54736
54906
  }
54737
54907
  const meaning = getMeaningOfEntityNameReference(node);
54738
- const sym = resolveEntityName(
54908
+ let sym;
54909
+ if (isThisIdentifier(leftmost)) {
54910
+ sym = getSymbolOfDeclaration(getThisContainer(
54911
+ leftmost,
54912
+ /*includeArrowFunctions*/
54913
+ false,
54914
+ /*includeClassComputedPropertyName*/
54915
+ false
54916
+ ));
54917
+ if (isSymbolAccessible(
54918
+ sym,
54919
+ leftmost,
54920
+ meaning,
54921
+ /*shouldComputeAliasesToMakeVisible*/
54922
+ false
54923
+ ).accessibility !== 0 /* Accessible */) {
54924
+ introducesError = true;
54925
+ context.tracker.reportInaccessibleThisError();
54926
+ }
54927
+ return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
54928
+ }
54929
+ sym = resolveEntityName(
54739
54930
  leftmost,
54740
54931
  meaning,
54741
54932
  /*ignoreErrors*/
@@ -54744,27 +54935,44 @@ function createTypeChecker(host) {
54744
54935
  true
54745
54936
  );
54746
54937
  if (sym) {
54747
- if (isSymbolAccessible(
54938
+ if (sym.flags & 1 /* FunctionScopedVariable */ && sym.valueDeclaration) {
54939
+ if (isParameterDeclaration(sym.valueDeclaration)) {
54940
+ return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
54941
+ }
54942
+ }
54943
+ if (!(sym.flags & 262144 /* TypeParameter */) && // Type parameters are visible in the curent context if they are are resolvable
54944
+ !isDeclarationName(node) && isSymbolAccessible(
54748
54945
  sym,
54749
54946
  context.enclosingDeclaration,
54750
54947
  meaning,
54751
54948
  /*shouldComputeAliasesToMakeVisible*/
54752
54949
  false
54753
54950
  ).accessibility !== 0 /* Accessible */) {
54754
- if (!isDeclarationName(node)) {
54755
- introducesError = true;
54756
- }
54951
+ introducesError = true;
54757
54952
  } else {
54758
54953
  context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
54759
54954
  }
54760
- if (isIdentifier(node)) {
54955
+ return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
54956
+ }
54957
+ return { introducesError, node };
54958
+ function attachSymbolToLeftmostIdentifier(node2) {
54959
+ if (node2 === leftmost) {
54761
54960
  const type = getDeclaredTypeOfSymbol(sym);
54762
- const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
54961
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
54763
54962
  name.symbol = sym;
54764
- return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */), node) };
54963
+ return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
54765
54964
  }
54965
+ const updated = visitEachChild(
54966
+ node2,
54967
+ (c) => attachSymbolToLeftmostIdentifier(c),
54968
+ /*context*/
54969
+ void 0
54970
+ );
54971
+ if (updated !== node2) {
54972
+ setTextRange(updated, node2);
54973
+ }
54974
+ return updated;
54766
54975
  }
54767
- return { introducesError, node };
54768
54976
  }
54769
54977
  function tryReuseExistingTypeNodeHelper(context, existing) {
54770
54978
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
@@ -54777,6 +54985,22 @@ function createTypeChecker(host) {
54777
54985
  }
54778
54986
  return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
54779
54987
  function visitExistingNodeTreeSymbols(node) {
54988
+ const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
54989
+ const result = visitExistingNodeTreeSymbolsWorker(node);
54990
+ onExitNewScope == null ? void 0 : onExitNewScope();
54991
+ return result;
54992
+ }
54993
+ function onEnterNewScope(node) {
54994
+ const oldContex = context;
54995
+ context = cloneNodeBuilderContext(context);
54996
+ const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
54997
+ return onExitNewScope;
54998
+ function onExitNewScope() {
54999
+ cleanup == null ? void 0 : cleanup();
55000
+ context = oldContex;
55001
+ }
55002
+ }
55003
+ function visitExistingNodeTreeSymbolsWorker(node) {
54780
55004
  if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
54781
55005
  return factory.createKeywordTypeNode(133 /* AnyKeyword */);
54782
55006
  }
@@ -54909,11 +55133,12 @@ function createTypeChecker(host) {
54909
55133
  return visited;
54910
55134
  }
54911
55135
  if (isEntityName(node) || isEntityNameExpression(node)) {
55136
+ if (isDeclarationName(node)) {
55137
+ return node;
55138
+ }
54912
55139
  const { introducesError, node: result } = trackExistingEntityName(node, context);
54913
55140
  hadError = hadError || introducesError;
54914
- if (result !== node) {
54915
- return result;
54916
- }
55141
+ return result;
54917
55142
  }
54918
55143
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
54919
55144
  const visited = visitEachChild(
@@ -54927,6 +55152,21 @@ function createTypeChecker(host) {
54927
55152
  setEmitFlags(clone2, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
54928
55153
  return clone2;
54929
55154
  }
55155
+ if (isConditionalTypeNode(node)) {
55156
+ const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
55157
+ const disposeScope = onEnterNewScope(node);
55158
+ const extendType = visitNode(node.extendsType, visitExistingNodeTreeSymbols, isTypeNode);
55159
+ const trueType2 = visitNode(node.trueType, visitExistingNodeTreeSymbols, isTypeNode);
55160
+ disposeScope();
55161
+ const falseType2 = visitNode(node.falseType, visitExistingNodeTreeSymbols, isTypeNode);
55162
+ return factory.updateConditionalTypeNode(
55163
+ node,
55164
+ checkType,
55165
+ extendType,
55166
+ trueType2,
55167
+ falseType2
55168
+ );
55169
+ }
54930
55170
  return visitEachChild(
54931
55171
  node,
54932
55172
  visitExistingNodeTreeSymbols,
@@ -57068,6 +57308,9 @@ function createTypeChecker(host) {
57068
57308
  }
57069
57309
  }
57070
57310
  if (isParameter(declaration)) {
57311
+ if (!declaration.symbol) {
57312
+ return;
57313
+ }
57071
57314
  const func = declaration.parent;
57072
57315
  if (func.kind === 178 /* SetAccessor */ && hasBindableName(func)) {
57073
57316
  const getter = getDeclarationOfKind(getSymbolOfDeclaration(declaration.parent), 177 /* GetAccessor */);
@@ -58427,7 +58670,7 @@ function createTypeChecker(host) {
58427
58670
  for (const member of declaration.members) {
58428
58671
  if (hasBindableName(member)) {
58429
58672
  const memberSymbol = getSymbolOfDeclaration(member);
58430
- const value = getEnumMemberValue(member);
58673
+ const value = getEnumMemberValue(member).value;
58431
58674
  const memberType = getFreshTypeOfLiteralType(
58432
58675
  value !== void 0 ? getEnumLiteralType(value, getSymbolId(symbol), memberSymbol) : createComputedEnumType(memberSymbol)
58433
58676
  );
@@ -65563,8 +65806,8 @@ function createTypeChecker(host) {
65563
65806
  }
65564
65807
  return false;
65565
65808
  }
65566
- const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
65567
- const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */));
65809
+ const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
65810
+ const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */)).value;
65568
65811
  if (sourceValue !== targetValue) {
65569
65812
  const sourceIsString = typeof sourceValue === "string";
65570
65813
  const targetIsString = typeof targetValue === "string";
@@ -68142,6 +68385,9 @@ function createTypeChecker(host) {
68142
68385
  const resolved = resolveStructuredTypeMembers(type);
68143
68386
  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 */));
68144
68387
  }
68388
+ if (type.flags & 33554432 /* Substitution */) {
68389
+ return isWeakType(type.baseType);
68390
+ }
68145
68391
  if (type.flags & 2097152 /* Intersection */) {
68146
68392
  return every(type.types, isWeakType);
68147
68393
  }
@@ -70443,7 +70689,7 @@ function createTypeChecker(host) {
70443
70689
  return false;
70444
70690
  }
70445
70691
  function getFlowNodeId(flow) {
70446
- if (!flow.id || flow.id < 0) {
70692
+ if (flow.id <= 0) {
70447
70693
  flow.id = nextFlowId;
70448
70694
  nextFlowId++;
70449
70695
  }
@@ -71078,33 +71324,34 @@ function createTypeChecker(host) {
71078
71324
  }
71079
71325
  flow = flow.antecedent;
71080
71326
  } else if (flags & 4 /* BranchLabel */) {
71081
- return some(flow.antecedents, (f) => isReachableFlowNodeWorker(
71327
+ return some(flow.antecedent, (f) => isReachableFlowNodeWorker(
71082
71328
  f,
71083
71329
  /*noCacheCheck*/
71084
71330
  false
71085
71331
  ));
71086
71332
  } else if (flags & 8 /* LoopLabel */) {
71087
- const antecedents = flow.antecedents;
71333
+ const antecedents = flow.antecedent;
71088
71334
  if (antecedents === void 0 || antecedents.length === 0) {
71089
71335
  return false;
71090
71336
  }
71091
71337
  flow = antecedents[0];
71092
71338
  } else if (flags & 128 /* SwitchClause */) {
71093
- if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
71339
+ const data = flow.node;
71340
+ if (data.clauseStart === data.clauseEnd && isExhaustiveSwitchStatement(data.switchStatement)) {
71094
71341
  return false;
71095
71342
  }
71096
71343
  flow = flow.antecedent;
71097
71344
  } else if (flags & 1024 /* ReduceLabel */) {
71098
71345
  lastFlowNode = void 0;
71099
- const target = flow.target;
71100
- const saveAntecedents = target.antecedents;
71101
- target.antecedents = flow.antecedents;
71346
+ const target = flow.node.target;
71347
+ const saveAntecedents = target.antecedent;
71348
+ target.antecedent = flow.node.antecedents;
71102
71349
  const result = isReachableFlowNodeWorker(
71103
71350
  flow.antecedent,
71104
71351
  /*noCacheCheck*/
71105
71352
  false
71106
71353
  );
71107
- target.antecedents = saveAntecedents;
71354
+ target.antecedent = saveAntecedents;
71108
71355
  return result;
71109
71356
  } else {
71110
71357
  return !(flags & 1 /* Unreachable */);
@@ -71134,23 +71381,23 @@ function createTypeChecker(host) {
71134
71381
  }
71135
71382
  flow = flow.antecedent;
71136
71383
  } else if (flags & 4 /* BranchLabel */) {
71137
- return every(flow.antecedents, (f) => isPostSuperFlowNode(
71384
+ return every(flow.antecedent, (f) => isPostSuperFlowNode(
71138
71385
  f,
71139
71386
  /*noCacheCheck*/
71140
71387
  false
71141
71388
  ));
71142
71389
  } else if (flags & 8 /* LoopLabel */) {
71143
- flow = flow.antecedents[0];
71390
+ flow = flow.antecedent[0];
71144
71391
  } else if (flags & 1024 /* ReduceLabel */) {
71145
- const target = flow.target;
71146
- const saveAntecedents = target.antecedents;
71147
- target.antecedents = flow.antecedents;
71392
+ const target = flow.node.target;
71393
+ const saveAntecedents = target.antecedent;
71394
+ target.antecedent = flow.node.antecedents;
71148
71395
  const result = isPostSuperFlowNode(
71149
71396
  flow.antecedent,
71150
71397
  /*noCacheCheck*/
71151
71398
  false
71152
71399
  );
71153
- target.antecedents = saveAntecedents;
71400
+ target.antecedent = saveAntecedents;
71154
71401
  return result;
71155
71402
  } else {
71156
71403
  return !!(flags & 1 /* Unreachable */);
@@ -71242,8 +71489,8 @@ function createTypeChecker(host) {
71242
71489
  } else if (flags & 128 /* SwitchClause */) {
71243
71490
  type = getTypeAtSwitchClause(flow);
71244
71491
  } else if (flags & 12 /* Label */) {
71245
- if (flow.antecedents.length === 1) {
71246
- flow = flow.antecedents[0];
71492
+ if (flow.antecedent.length === 1) {
71493
+ flow = flow.antecedent[0];
71247
71494
  continue;
71248
71495
  }
71249
71496
  type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow);
@@ -71254,11 +71501,11 @@ function createTypeChecker(host) {
71254
71501
  continue;
71255
71502
  }
71256
71503
  } else if (flags & 1024 /* ReduceLabel */) {
71257
- const target = flow.target;
71258
- const saveAntecedents = target.antecedents;
71259
- target.antecedents = flow.antecedents;
71504
+ const target = flow.node.target;
71505
+ const saveAntecedents = target.antecedent;
71506
+ target.antecedent = flow.node.antecedents;
71260
71507
  type = getTypeAtFlowNode(flow.antecedent);
71261
- target.antecedents = saveAntecedents;
71508
+ target.antecedent = saveAntecedents;
71262
71509
  } else if (flags & 2 /* Start */) {
71263
71510
  const container = flow.node;
71264
71511
  if (container && container !== flowContainer && reference.kind !== 211 /* PropertyAccessExpression */ && reference.kind !== 212 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 219 /* ArrowFunction */)) {
@@ -71412,26 +71659,26 @@ function createTypeChecker(host) {
71412
71659
  return createFlowType(narrowedType, isIncomplete(flowType));
71413
71660
  }
71414
71661
  function getTypeAtSwitchClause(flow) {
71415
- const expr = skipParentheses(flow.switchStatement.expression);
71662
+ const expr = skipParentheses(flow.node.switchStatement.expression);
71416
71663
  const flowType = getTypeAtFlowNode(flow.antecedent);
71417
71664
  let type = getTypeFromFlowType(flowType);
71418
71665
  if (isMatchingReference(reference, expr)) {
71419
- type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71666
+ type = narrowTypeBySwitchOnDiscriminant(type, flow.node);
71420
71667
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
71421
- type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71668
+ type = narrowTypeBySwitchOnTypeOf(type, flow.node);
71422
71669
  } else if (expr.kind === 112 /* TrueKeyword */) {
71423
- type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71670
+ type = narrowTypeBySwitchOnTrue(type, flow.node);
71424
71671
  } else {
71425
71672
  if (strictNullChecks) {
71426
71673
  if (optionalChainContainsReference(expr, reference)) {
71427
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
71674
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
71428
71675
  } else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
71429
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
71676
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
71430
71677
  }
71431
71678
  }
71432
71679
  const access = getDiscriminantPropertyAccess(expr, type);
71433
71680
  if (access) {
71434
- type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71681
+ type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.node);
71435
71682
  }
71436
71683
  }
71437
71684
  return createFlowType(type, isIncomplete(flowType));
@@ -71441,8 +71688,8 @@ function createTypeChecker(host) {
71441
71688
  let subtypeReduction = false;
71442
71689
  let seenIncomplete = false;
71443
71690
  let bypassFlow;
71444
- for (const antecedent of flow.antecedents) {
71445
- if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) {
71691
+ for (const antecedent of flow.antecedent) {
71692
+ if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.node.clauseStart === antecedent.node.clauseEnd) {
71446
71693
  bypassFlow = antecedent;
71447
71694
  continue;
71448
71695
  }
@@ -71462,7 +71709,7 @@ function createTypeChecker(host) {
71462
71709
  if (bypassFlow) {
71463
71710
  const flowType = getTypeAtFlowNode(bypassFlow);
71464
71711
  const type = getTypeFromFlowType(flowType);
71465
- if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
71712
+ if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.node.switchStatement)) {
71466
71713
  if (type === declaredType && declaredType === initialType) {
71467
71714
  return type;
71468
71715
  }
@@ -71500,7 +71747,7 @@ function createTypeChecker(host) {
71500
71747
  const antecedentTypes = [];
71501
71748
  let subtypeReduction = false;
71502
71749
  let firstAntecedentType;
71503
- for (const antecedent of flow.antecedents) {
71750
+ for (const antecedent of flow.antecedent) {
71504
71751
  let flowType;
71505
71752
  if (!firstAntecedentType) {
71506
71753
  flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
@@ -71624,15 +71871,15 @@ function createTypeChecker(host) {
71624
71871
  }
71625
71872
  return narrowTypeByDiscriminant(type, access, (t) => narrowTypeByEquality(t, operator, value, assumeTrue));
71626
71873
  }
71627
- function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) {
71628
- if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
71629
- const clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd);
71874
+ function narrowTypeBySwitchOnDiscriminantProperty(type, access, data) {
71875
+ if (data.clauseStart < data.clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
71876
+ const clauseTypes = getSwitchClauseTypes(data.switchStatement).slice(data.clauseStart, data.clauseEnd);
71630
71877
  const candidate = getUnionType(map(clauseTypes, (t) => getConstituentTypeForKeyType(type, t) || unknownType));
71631
71878
  if (candidate !== unknownType) {
71632
71879
  return candidate;
71633
71880
  }
71634
71881
  }
71635
- return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd));
71882
+ return narrowTypeByDiscriminant(type, access, (t) => narrowTypeBySwitchOnDiscriminant(t, data));
71636
71883
  }
71637
71884
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
71638
71885
  if (isMatchingReference(reference, expr)) {
@@ -71877,11 +72124,11 @@ function createTypeChecker(host) {
71877
72124
  function narrowTypeByLiteralExpression(type, literal, assumeTrue) {
71878
72125
  return assumeTrue ? narrowTypeByTypeName(type, literal.text) : getAdjustedTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
71879
72126
  }
71880
- function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
72127
+ function narrowTypeBySwitchOptionalChainContainment(type, { switchStatement, clauseStart, clauseEnd }, clauseCheck) {
71881
72128
  const everyClauseChecks = clauseStart !== clauseEnd && every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
71882
72129
  return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
71883
72130
  }
71884
- function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
72131
+ function narrowTypeBySwitchOnDiscriminant(type, { switchStatement, clauseStart, clauseEnd }) {
71885
72132
  const switchTypes = getSwitchClauseTypes(switchStatement);
71886
72133
  if (!switchTypes.length) {
71887
72134
  return type;
@@ -71954,7 +72201,7 @@ function createTypeChecker(host) {
71954
72201
  )
71955
72202
  ));
71956
72203
  }
71957
- function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72204
+ function narrowTypeBySwitchOnTypeOf(type, { switchStatement, clauseStart, clauseEnd }) {
71958
72205
  const witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71959
72206
  if (!witnesses) {
71960
72207
  return type;
@@ -71968,7 +72215,7 @@ function createTypeChecker(host) {
71968
72215
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71969
72216
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
71970
72217
  }
71971
- function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
72218
+ function narrowTypeBySwitchOnTrue(type, { switchStatement, clauseStart, clauseEnd }) {
71972
72219
  const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
71973
72220
  const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
71974
72221
  for (let i = 0; i < clauseStart; i++) {
@@ -75110,7 +75357,11 @@ function createTypeChecker(host) {
75110
75357
  if (getPropertyOfObjectType(targetType, name) || getApplicableIndexInfoForName(targetType, name) || isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || isComparingJsxAttributes && isHyphenatedJsxName(name)) {
75111
75358
  return true;
75112
75359
  }
75113
- } else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
75360
+ }
75361
+ if (targetType.flags & 33554432 /* Substitution */) {
75362
+ return isKnownProperty(targetType.baseType, name, isComparingJsxAttributes);
75363
+ }
75364
+ if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
75114
75365
  for (const t of targetType.types) {
75115
75366
  if (isKnownProperty(t, name, isComparingJsxAttributes)) {
75116
75367
  return true;
@@ -75120,7 +75371,7 @@ function createTypeChecker(host) {
75120
75371
  return false;
75121
75372
  }
75122
75373
  function isExcessPropertyCheckTarget(type) {
75123
- 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));
75374
+ 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));
75124
75375
  }
75125
75376
  function checkJsxExpression(node, checkMode) {
75126
75377
  checkGrammarJsxExpression(node);
@@ -79258,20 +79509,19 @@ function createTypeChecker(host) {
79258
79509
  });
79259
79510
  }
79260
79511
  function checkIfExpressionRefinesParameter(func, expr, param, initType) {
79261
- const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
79262
- const trueCondition = {
79263
- flags: 32 /* TrueCondition */,
79264
- node: expr,
79265
- antecedent
79266
- };
79512
+ const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
79513
+ 2 /* Start */,
79514
+ /*node*/
79515
+ void 0,
79516
+ /*antecedent*/
79517
+ void 0
79518
+ );
79519
+ const trueCondition = createFlowNode(32 /* TrueCondition */, expr, antecedent);
79267
79520
  const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
79268
79521
  if (trueType2 === initType)
79269
79522
  return void 0;
79270
- const falseCondition = {
79271
- ...trueCondition,
79272
- flags: 64 /* FalseCondition */
79273
- };
79274
- const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
79523
+ const falseCondition = createFlowNode(64 /* FalseCondition */, expr, antecedent);
79524
+ const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
79275
79525
  return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
79276
79526
  }
79277
79527
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
@@ -80664,7 +80914,7 @@ function createTypeChecker(host) {
80664
80914
  ) || unknownType, isTemplateLiteralContextualType)) {
80665
80915
  return getTemplateLiteralType(texts, types);
80666
80916
  }
80667
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
80917
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
80668
80918
  return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
80669
80919
  }
80670
80920
  function isTemplateLiteralContextualType(type) {
@@ -85569,14 +85819,14 @@ function createTypeChecker(host) {
85569
85819
  let autoValue = 0;
85570
85820
  let previous;
85571
85821
  for (const member of node.members) {
85572
- const value = computeMemberValue(member, autoValue, previous);
85573
- getNodeLinks(member).enumMemberValue = value;
85574
- autoValue = typeof value === "number" ? value + 1 : void 0;
85822
+ const result = computeEnumMemberValue(member, autoValue, previous);
85823
+ getNodeLinks(member).enumMemberValue = result;
85824
+ autoValue = typeof result.value === "number" ? result.value + 1 : void 0;
85575
85825
  previous = member;
85576
85826
  }
85577
85827
  }
85578
85828
  }
85579
- function computeMemberValue(member, autoValue, previous) {
85829
+ function computeEnumMemberValue(member, autoValue, previous) {
85580
85830
  if (isComputedNonLiteralName(member.name)) {
85581
85831
  error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
85582
85832
  } else {
@@ -85586,34 +85836,43 @@ function createTypeChecker(host) {
85586
85836
  }
85587
85837
  }
85588
85838
  if (member.initializer) {
85589
- return computeConstantValue(member);
85839
+ return computeConstantEnumMemberValue(member);
85590
85840
  }
85591
85841
  if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
85592
- return void 0;
85842
+ return evaluatorResult(
85843
+ /*value*/
85844
+ void 0
85845
+ );
85593
85846
  }
85594
85847
  if (autoValue === void 0) {
85595
85848
  error2(member.name, Diagnostics.Enum_member_must_have_initializer);
85596
- return void 0;
85597
- }
85598
- if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer) && !isSyntacticallyNumericConstant(previous.initializer)) {
85599
- error2(
85600
- member.name,
85601
- Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
85849
+ return evaluatorResult(
85850
+ /*value*/
85851
+ void 0
85602
85852
  );
85603
85853
  }
85604
- return autoValue;
85854
+ if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer)) {
85855
+ const prevValue = getEnumMemberValue(previous);
85856
+ if (!(typeof prevValue.value === "number" && !prevValue.resolvedOtherFiles)) {
85857
+ error2(
85858
+ member.name,
85859
+ Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
85860
+ );
85861
+ }
85862
+ }
85863
+ return evaluatorResult(autoValue);
85605
85864
  }
85606
- function computeConstantValue(member) {
85865
+ function computeConstantEnumMemberValue(member) {
85607
85866
  const isConstEnum = isEnumConst(member.parent);
85608
85867
  const initializer = member.initializer;
85609
- const value = evaluate(initializer, member);
85610
- if (value !== void 0) {
85611
- if (isConstEnum && typeof value === "number" && !isFinite(value)) {
85868
+ const result = evaluate(initializer, member);
85869
+ if (result.value !== void 0) {
85870
+ if (isConstEnum && typeof result.value === "number" && !isFinite(result.value)) {
85612
85871
  error2(
85613
85872
  initializer,
85614
- 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
85873
+ 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
85615
85874
  );
85616
- } else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString(initializer)) {
85875
+ } else if (getIsolatedModules(compilerOptions) && typeof result.value === "string" && !result.isSyntacticallyString) {
85617
85876
  error2(
85618
85877
  initializer,
85619
85878
  Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
@@ -85627,19 +85886,7 @@ function createTypeChecker(host) {
85627
85886
  } else {
85628
85887
  checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
85629
85888
  }
85630
- return value;
85631
- }
85632
- function isSyntacticallyNumericConstant(expr) {
85633
- expr = skipOuterExpressions(expr);
85634
- switch (expr.kind) {
85635
- case 224 /* PrefixUnaryExpression */:
85636
- return isSyntacticallyNumericConstant(expr.operand);
85637
- case 226 /* BinaryExpression */:
85638
- return isSyntacticallyNumericConstant(expr.left) && isSyntacticallyNumericConstant(expr.right);
85639
- case 9 /* NumericLiteral */:
85640
- return true;
85641
- }
85642
- return false;
85889
+ return result;
85643
85890
  }
85644
85891
  function evaluateEntityNameExpression(expr, location) {
85645
85892
  const symbol = resolveEntityName(
@@ -85649,7 +85896,10 @@ function createTypeChecker(host) {
85649
85896
  true
85650
85897
  );
85651
85898
  if (!symbol)
85652
- return void 0;
85899
+ return evaluatorResult(
85900
+ /*value*/
85901
+ void 0
85902
+ );
85653
85903
  if (expr.kind === 80 /* Identifier */) {
85654
85904
  const identifier = expr;
85655
85905
  if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
@@ -85658,7 +85908,11 @@ function createTypeChecker(host) {
85658
85908
  /*diagnostic*/
85659
85909
  void 0
85660
85910
  )) {
85661
- return +identifier.escapedText;
85911
+ return evaluatorResult(
85912
+ +identifier.escapedText,
85913
+ /*isSyntacticallyString*/
85914
+ false
85915
+ );
85662
85916
  }
85663
85917
  }
85664
85918
  if (symbol.flags & 8 /* EnumMember */) {
@@ -85667,9 +85921,23 @@ function createTypeChecker(host) {
85667
85921
  if (isConstantVariable(symbol)) {
85668
85922
  const declaration = symbol.valueDeclaration;
85669
85923
  if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
85670
- return evaluate(declaration.initializer, declaration);
85924
+ const result = evaluate(declaration.initializer, declaration);
85925
+ if (location && getSourceFileOfNode(location) !== getSourceFileOfNode(declaration)) {
85926
+ return evaluatorResult(
85927
+ result.value,
85928
+ /*isSyntacticallyString*/
85929
+ false,
85930
+ /*resolvedOtherFiles*/
85931
+ true
85932
+ );
85933
+ }
85934
+ return result;
85671
85935
  }
85672
85936
  }
85937
+ return evaluatorResult(
85938
+ /*value*/
85939
+ void 0
85940
+ );
85673
85941
  }
85674
85942
  function evaluateElementAccessExpression(expr, location) {
85675
85943
  const root = expr.expression;
@@ -85684,20 +85952,31 @@ function createTypeChecker(host) {
85684
85952
  const name = escapeLeadingUnderscores(expr.argumentExpression.text);
85685
85953
  const member = rootSymbol.exports.get(name);
85686
85954
  if (member) {
85955
+ Debug.assert(getSourceFileOfNode(member.valueDeclaration) === getSourceFileOfNode(rootSymbol.valueDeclaration));
85687
85956
  return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
85688
85957
  }
85689
85958
  }
85690
85959
  }
85960
+ return evaluatorResult(
85961
+ /*value*/
85962
+ void 0
85963
+ );
85691
85964
  }
85692
85965
  function evaluateEnumMember(expr, symbol, location) {
85693
85966
  const declaration = symbol.valueDeclaration;
85694
85967
  if (!declaration || declaration === location) {
85695
85968
  error2(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
85696
- return void 0;
85969
+ return evaluatorResult(
85970
+ /*value*/
85971
+ void 0
85972
+ );
85697
85973
  }
85698
85974
  if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
85699
85975
  error2(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
85700
- return 0;
85976
+ return evaluatorResult(
85977
+ /*value*/
85978
+ 0
85979
+ );
85701
85980
  }
85702
85981
  return getEnumMemberValue(declaration);
85703
85982
  }
@@ -87838,7 +88117,10 @@ function createTypeChecker(host) {
87838
88117
  }
87839
88118
  function getEnumMemberValue(node) {
87840
88119
  computeEnumMemberValues(node.parent);
87841
- return getNodeLinks(node).enumMemberValue;
88120
+ return getNodeLinks(node).enumMemberValue ?? evaluatorResult(
88121
+ /*value*/
88122
+ void 0
88123
+ );
87842
88124
  }
87843
88125
  function canHaveConstantValue(node) {
87844
88126
  switch (node.kind) {
@@ -87851,13 +88133,13 @@ function createTypeChecker(host) {
87851
88133
  }
87852
88134
  function getConstantValue2(node) {
87853
88135
  if (node.kind === 306 /* EnumMember */) {
87854
- return getEnumMemberValue(node);
88136
+ return getEnumMemberValue(node).value;
87855
88137
  }
87856
88138
  const symbol = getNodeLinks(node).resolvedSymbol;
87857
88139
  if (symbol && symbol.flags & 8 /* EnumMember */) {
87858
88140
  const member = symbol.valueDeclaration;
87859
88141
  if (isEnumConst(member.parent)) {
87860
- return getEnumMemberValue(member);
88142
+ return getEnumMemberValue(member).value;
87861
88143
  }
87862
88144
  }
87863
88145
  return void 0;
@@ -88232,6 +88514,10 @@ function createTypeChecker(host) {
88232
88514
  const node = getParseTreeNode(nodeIn, canHaveConstantValue);
88233
88515
  return node ? getConstantValue2(node) : void 0;
88234
88516
  },
88517
+ getEnumMemberValue: (nodeIn) => {
88518
+ const node = getParseTreeNode(nodeIn, isEnumMember);
88519
+ return node ? getEnumMemberValue(node) : void 0;
88520
+ },
88235
88521
  collectLinkedAliases,
88236
88522
  getReferencedValueDeclaration,
88237
88523
  getReferencedValueDeclarations,
@@ -94637,7 +94923,8 @@ function transformTypeScript(context) {
94637
94923
  /*generateNameForComputedPropertyName*/
94638
94924
  false
94639
94925
  );
94640
- const valueExpression = transformEnumMemberDeclarationValue(member);
94926
+ const evaluated = resolver.getEnumMemberValue(member);
94927
+ const valueExpression = transformEnumMemberDeclarationValue(member, evaluated == null ? void 0 : evaluated.value);
94641
94928
  const innerAssignment = factory2.createAssignment(
94642
94929
  factory2.createElementAccessExpression(
94643
94930
  currentNamespaceContainerName,
@@ -94645,7 +94932,7 @@ function transformTypeScript(context) {
94645
94932
  ),
94646
94933
  valueExpression
94647
94934
  );
94648
- const outerAssignment = isSyntacticallyString(valueExpression) ? innerAssignment : factory2.createAssignment(
94935
+ const outerAssignment = typeof (evaluated == null ? void 0 : evaluated.value) === "string" || (evaluated == null ? void 0 : evaluated.isSyntacticallyString) ? innerAssignment : factory2.createAssignment(
94649
94936
  factory2.createElementAccessExpression(
94650
94937
  currentNamespaceContainerName,
94651
94938
  innerAssignment
@@ -94662,10 +94949,9 @@ function transformTypeScript(context) {
94662
94949
  member
94663
94950
  );
94664
94951
  }
94665
- function transformEnumMemberDeclarationValue(member) {
94666
- const value = resolver.getConstantValue(member);
94667
- if (value !== void 0) {
94668
- return typeof value === "string" ? factory2.createStringLiteral(value) : value < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-value)) : factory2.createNumericLiteral(value);
94952
+ function transformEnumMemberDeclarationValue(member, constantValue) {
94953
+ if (constantValue !== void 0) {
94954
+ return typeof constantValue === "string" ? factory2.createStringLiteral(constantValue) : constantValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-constantValue)) : factory2.createNumericLiteral(constantValue);
94669
94955
  } else {
94670
94956
  enableSubstitutionForNonQualifiedEnumMembers();
94671
94957
  if (member.initializer) {
@@ -116016,6 +116302,7 @@ var notImplementedResolver = {
116016
116302
  isEntityNameVisible: notImplemented,
116017
116303
  // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
116018
116304
  getConstantValue: notImplemented,
116305
+ getEnumMemberValue: notImplemented,
116019
116306
  getReferencedValueDeclaration: notImplemented,
116020
116307
  getReferencedValueDeclarations: notImplemented,
116021
116308
  getTypeReferenceSerializationKind: notImplemented,
@@ -131035,6 +131322,1123 @@ function verboseReportProjectStatus(state, configFileName, status) {
131035
131322
  }
131036
131323
  }
131037
131324
 
131325
+ // src/compiler/executeCommandLine.ts
131326
+ var StatisticType = /* @__PURE__ */ ((StatisticType2) => {
131327
+ StatisticType2[StatisticType2["time"] = 0] = "time";
131328
+ StatisticType2[StatisticType2["count"] = 1] = "count";
131329
+ StatisticType2[StatisticType2["memory"] = 2] = "memory";
131330
+ return StatisticType2;
131331
+ })(StatisticType || {});
131332
+ function countLines(program) {
131333
+ const counts2 = getCountsMap();
131334
+ forEach(program.getSourceFiles(), (file) => {
131335
+ const key = getCountKey(program, file);
131336
+ const lineCount = getLineStarts(file).length;
131337
+ counts2.set(key, counts2.get(key) + lineCount);
131338
+ });
131339
+ return counts2;
131340
+ }
131341
+ function getCountsMap() {
131342
+ const counts2 = /* @__PURE__ */ new Map();
131343
+ counts2.set("Library", 0);
131344
+ counts2.set("Definitions", 0);
131345
+ counts2.set("TypeScript", 0);
131346
+ counts2.set("JavaScript", 0);
131347
+ counts2.set("JSON", 0);
131348
+ counts2.set("Other", 0);
131349
+ return counts2;
131350
+ }
131351
+ function getCountKey(program, file) {
131352
+ if (program.isSourceFileDefaultLibrary(file)) {
131353
+ return "Library";
131354
+ } else if (file.isDeclarationFile) {
131355
+ return "Definitions";
131356
+ }
131357
+ const path = file.path;
131358
+ if (fileExtensionIsOneOf(path, supportedTSExtensionsFlat)) {
131359
+ return "TypeScript";
131360
+ } else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) {
131361
+ return "JavaScript";
131362
+ } else if (fileExtensionIs(path, ".json" /* Json */)) {
131363
+ return "JSON";
131364
+ } else {
131365
+ return "Other";
131366
+ }
131367
+ }
131368
+ function updateReportDiagnostic(sys2, existing, options) {
131369
+ return shouldBePretty(sys2, options) ? createDiagnosticReporter(
131370
+ sys2,
131371
+ /*pretty*/
131372
+ true
131373
+ ) : existing;
131374
+ }
131375
+ function defaultIsPretty(sys2) {
131376
+ return !!sys2.writeOutputIsTTY && sys2.writeOutputIsTTY() && !sys2.getEnvironmentVariable("NO_COLOR");
131377
+ }
131378
+ function shouldBePretty(sys2, options) {
131379
+ if (!options || typeof options.pretty === "undefined") {
131380
+ return defaultIsPretty(sys2);
131381
+ }
131382
+ return options.pretty;
131383
+ }
131384
+ function getOptionsForHelp(commandLine) {
131385
+ return !!commandLine.options.all ? sort(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) : filter(optionDeclarations.slice(), (v) => !!v.showInSimplifiedHelpView);
131386
+ }
131387
+ function printVersion(sys2) {
131388
+ sys2.write(getDiagnosticText(Diagnostics.Version_0, version) + sys2.newLine);
131389
+ }
131390
+ function createColors(sys2) {
131391
+ const showColors = defaultIsPretty(sys2);
131392
+ if (!showColors) {
131393
+ return {
131394
+ bold: (str) => str,
131395
+ blue: (str) => str,
131396
+ blueBackground: (str) => str,
131397
+ brightWhite: (str) => str
131398
+ };
131399
+ }
131400
+ function bold(str) {
131401
+ return `\x1B[1m${str}\x1B[22m`;
131402
+ }
131403
+ const isWindows = sys2.getEnvironmentVariable("OS") && sys2.getEnvironmentVariable("OS").toLowerCase().includes("windows");
131404
+ const isWindowsTerminal = sys2.getEnvironmentVariable("WT_SESSION");
131405
+ const isVSCode = sys2.getEnvironmentVariable("TERM_PROGRAM") && sys2.getEnvironmentVariable("TERM_PROGRAM") === "vscode";
131406
+ function blue(str) {
131407
+ if (isWindows && !isWindowsTerminal && !isVSCode) {
131408
+ return brightWhite(str);
131409
+ }
131410
+ return `\x1B[94m${str}\x1B[39m`;
131411
+ }
131412
+ const supportsRicherColors = sys2.getEnvironmentVariable("COLORTERM") === "truecolor" || sys2.getEnvironmentVariable("TERM") === "xterm-256color";
131413
+ function blueBackground(str) {
131414
+ if (supportsRicherColors) {
131415
+ return `\x1B[48;5;68m${str}\x1B[39;49m`;
131416
+ } else {
131417
+ return `\x1B[44m${str}\x1B[39;49m`;
131418
+ }
131419
+ }
131420
+ function brightWhite(str) {
131421
+ return `\x1B[97m${str}\x1B[39m`;
131422
+ }
131423
+ return {
131424
+ bold,
131425
+ blue,
131426
+ brightWhite,
131427
+ blueBackground
131428
+ };
131429
+ }
131430
+ function getDisplayNameTextOfOption(option) {
131431
+ return `--${option.name}${option.shortName ? `, -${option.shortName}` : ""}`;
131432
+ }
131433
+ function generateOptionOutput(sys2, option, rightAlignOfLeft, leftAlignOfRight) {
131434
+ var _a;
131435
+ const text = [];
131436
+ const colors = createColors(sys2);
131437
+ const name = getDisplayNameTextOfOption(option);
131438
+ const valueCandidates = getValueCandidate(option);
131439
+ const defaultValueDescription = typeof option.defaultValueDescription === "object" ? getDiagnosticText(option.defaultValueDescription) : formatDefaultValue(
131440
+ option.defaultValueDescription,
131441
+ option.type === "list" || option.type === "listOrElement" ? option.element.type : option.type
131442
+ );
131443
+ const terminalWidth = ((_a = sys2.getWidthOfTerminal) == null ? void 0 : _a.call(sys2)) ?? 0;
131444
+ if (terminalWidth >= 80) {
131445
+ let description3 = "";
131446
+ if (option.description) {
131447
+ description3 = getDiagnosticText(option.description);
131448
+ }
131449
+ text.push(...getPrettyOutput(
131450
+ name,
131451
+ description3,
131452
+ rightAlignOfLeft,
131453
+ leftAlignOfRight,
131454
+ terminalWidth,
131455
+ /*colorLeft*/
131456
+ true
131457
+ ), sys2.newLine);
131458
+ if (showAdditionalInfoOutput(valueCandidates, option)) {
131459
+ if (valueCandidates) {
131460
+ text.push(...getPrettyOutput(
131461
+ valueCandidates.valueType,
131462
+ valueCandidates.possibleValues,
131463
+ rightAlignOfLeft,
131464
+ leftAlignOfRight,
131465
+ terminalWidth,
131466
+ /*colorLeft*/
131467
+ false
131468
+ ), sys2.newLine);
131469
+ }
131470
+ if (defaultValueDescription) {
131471
+ text.push(...getPrettyOutput(
131472
+ getDiagnosticText(Diagnostics.default_Colon),
131473
+ defaultValueDescription,
131474
+ rightAlignOfLeft,
131475
+ leftAlignOfRight,
131476
+ terminalWidth,
131477
+ /*colorLeft*/
131478
+ false
131479
+ ), sys2.newLine);
131480
+ }
131481
+ }
131482
+ text.push(sys2.newLine);
131483
+ } else {
131484
+ text.push(colors.blue(name), sys2.newLine);
131485
+ if (option.description) {
131486
+ const description3 = getDiagnosticText(option.description);
131487
+ text.push(description3);
131488
+ }
131489
+ text.push(sys2.newLine);
131490
+ if (showAdditionalInfoOutput(valueCandidates, option)) {
131491
+ if (valueCandidates) {
131492
+ text.push(`${valueCandidates.valueType} ${valueCandidates.possibleValues}`);
131493
+ }
131494
+ if (defaultValueDescription) {
131495
+ if (valueCandidates)
131496
+ text.push(sys2.newLine);
131497
+ const diagType = getDiagnosticText(Diagnostics.default_Colon);
131498
+ text.push(`${diagType} ${defaultValueDescription}`);
131499
+ }
131500
+ text.push(sys2.newLine);
131501
+ }
131502
+ text.push(sys2.newLine);
131503
+ }
131504
+ return text;
131505
+ function formatDefaultValue(defaultValue, type) {
131506
+ return defaultValue !== void 0 && typeof type === "object" ? arrayFrom(type.entries()).filter(([, value]) => value === defaultValue).map(([name2]) => name2).join("/") : String(defaultValue);
131507
+ }
131508
+ function showAdditionalInfoOutput(valueCandidates2, option2) {
131509
+ const ignoreValues = ["string"];
131510
+ const ignoredDescriptions = [void 0, "false", "n/a"];
131511
+ const defaultValueDescription2 = option2.defaultValueDescription;
131512
+ if (option2.category === Diagnostics.Command_line_Options)
131513
+ return false;
131514
+ if (contains(ignoreValues, valueCandidates2 == null ? void 0 : valueCandidates2.possibleValues) && contains(ignoredDescriptions, defaultValueDescription2)) {
131515
+ return false;
131516
+ }
131517
+ return true;
131518
+ }
131519
+ function getPrettyOutput(left, right, rightAlignOfLeft2, leftAlignOfRight2, terminalWidth2, colorLeft) {
131520
+ const res = [];
131521
+ let isFirstLine = true;
131522
+ let remainRight = right;
131523
+ const rightCharacterNumber = terminalWidth2 - leftAlignOfRight2;
131524
+ while (remainRight.length > 0) {
131525
+ let curLeft = "";
131526
+ if (isFirstLine) {
131527
+ curLeft = left.padStart(rightAlignOfLeft2);
131528
+ curLeft = curLeft.padEnd(leftAlignOfRight2);
131529
+ curLeft = colorLeft ? colors.blue(curLeft) : curLeft;
131530
+ } else {
131531
+ curLeft = "".padStart(leftAlignOfRight2);
131532
+ }
131533
+ const curRight = remainRight.substr(0, rightCharacterNumber);
131534
+ remainRight = remainRight.slice(rightCharacterNumber);
131535
+ res.push(`${curLeft}${curRight}`);
131536
+ isFirstLine = false;
131537
+ }
131538
+ return res;
131539
+ }
131540
+ function getValueCandidate(option2) {
131541
+ if (option2.type === "object") {
131542
+ return void 0;
131543
+ }
131544
+ return {
131545
+ valueType: getValueType(option2),
131546
+ possibleValues: getPossibleValues(option2)
131547
+ };
131548
+ function getValueType(option3) {
131549
+ Debug.assert(option3.type !== "listOrElement");
131550
+ switch (option3.type) {
131551
+ case "string":
131552
+ case "number":
131553
+ case "boolean":
131554
+ return getDiagnosticText(Diagnostics.type_Colon);
131555
+ case "list":
131556
+ return getDiagnosticText(Diagnostics.one_or_more_Colon);
131557
+ default:
131558
+ return getDiagnosticText(Diagnostics.one_of_Colon);
131559
+ }
131560
+ }
131561
+ function getPossibleValues(option3) {
131562
+ let possibleValues;
131563
+ switch (option3.type) {
131564
+ case "string":
131565
+ case "number":
131566
+ case "boolean":
131567
+ possibleValues = option3.type;
131568
+ break;
131569
+ case "list":
131570
+ case "listOrElement":
131571
+ possibleValues = getPossibleValues(option3.element);
131572
+ break;
131573
+ case "object":
131574
+ possibleValues = "";
131575
+ break;
131576
+ default:
131577
+ const inverted = {};
131578
+ option3.type.forEach((value, name2) => {
131579
+ var _a2;
131580
+ if (!((_a2 = option3.deprecatedKeys) == null ? void 0 : _a2.has(name2))) {
131581
+ (inverted[value] || (inverted[value] = [])).push(name2);
131582
+ }
131583
+ });
131584
+ return Object.entries(inverted).map(([, synonyms]) => synonyms.join("/")).join(", ");
131585
+ }
131586
+ return possibleValues;
131587
+ }
131588
+ }
131589
+ }
131590
+ function generateGroupOptionOutput(sys2, optionsList) {
131591
+ let maxLength2 = 0;
131592
+ for (const option of optionsList) {
131593
+ const curLength = getDisplayNameTextOfOption(option).length;
131594
+ maxLength2 = maxLength2 > curLength ? maxLength2 : curLength;
131595
+ }
131596
+ const rightAlignOfLeftPart = maxLength2 + 2;
131597
+ const leftAlignOfRightPart = rightAlignOfLeftPart + 2;
131598
+ let lines = [];
131599
+ for (const option of optionsList) {
131600
+ const tmp = generateOptionOutput(sys2, option, rightAlignOfLeftPart, leftAlignOfRightPart);
131601
+ lines = [...lines, ...tmp];
131602
+ }
131603
+ if (lines[lines.length - 2] !== sys2.newLine) {
131604
+ lines.push(sys2.newLine);
131605
+ }
131606
+ return lines;
131607
+ }
131608
+ function generateSectionOptionsOutput(sys2, sectionName, options, subCategory, beforeOptionsDescription, afterOptionsDescription) {
131609
+ let res = [];
131610
+ res.push(createColors(sys2).bold(sectionName) + sys2.newLine + sys2.newLine);
131611
+ if (beforeOptionsDescription) {
131612
+ res.push(beforeOptionsDescription + sys2.newLine + sys2.newLine);
131613
+ }
131614
+ if (!subCategory) {
131615
+ res = [...res, ...generateGroupOptionOutput(sys2, options)];
131616
+ if (afterOptionsDescription) {
131617
+ res.push(afterOptionsDescription + sys2.newLine + sys2.newLine);
131618
+ }
131619
+ return res;
131620
+ }
131621
+ const categoryMap = /* @__PURE__ */ new Map();
131622
+ for (const option of options) {
131623
+ if (!option.category) {
131624
+ continue;
131625
+ }
131626
+ const curCategory = getDiagnosticText(option.category);
131627
+ const optionsOfCurCategory = categoryMap.get(curCategory) ?? [];
131628
+ optionsOfCurCategory.push(option);
131629
+ categoryMap.set(curCategory, optionsOfCurCategory);
131630
+ }
131631
+ categoryMap.forEach((value, key) => {
131632
+ res.push(`### ${key}${sys2.newLine}${sys2.newLine}`);
131633
+ res = [...res, ...generateGroupOptionOutput(sys2, value)];
131634
+ });
131635
+ if (afterOptionsDescription) {
131636
+ res.push(afterOptionsDescription + sys2.newLine + sys2.newLine);
131637
+ }
131638
+ return res;
131639
+ }
131640
+ function printEasyHelp(sys2, simpleOptions) {
131641
+ const colors = createColors(sys2);
131642
+ let output = [...getHeader(sys2, `${getDiagnosticText(Diagnostics.tsc_Colon_The_TypeScript_Compiler)} - ${getDiagnosticText(Diagnostics.Version_0, version)}`)];
131643
+ output.push(colors.bold(getDiagnosticText(Diagnostics.COMMON_COMMANDS)) + sys2.newLine + sys2.newLine);
131644
+ example("tsc", Diagnostics.Compiles_the_current_project_tsconfig_json_in_the_working_directory);
131645
+ example("tsc app.ts util.ts", Diagnostics.Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options);
131646
+ example("tsc -b", Diagnostics.Build_a_composite_project_in_the_working_directory);
131647
+ example("tsc --init", Diagnostics.Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory);
131648
+ example("tsc -p ./path/to/tsconfig.json", Diagnostics.Compiles_the_TypeScript_project_located_at_the_specified_path);
131649
+ example("tsc --help --all", Diagnostics.An_expanded_version_of_this_information_showing_all_possible_compiler_options);
131650
+ example(["tsc --noEmit", "tsc --target esnext"], Diagnostics.Compiles_the_current_project_with_additional_settings);
131651
+ const cliCommands = simpleOptions.filter((opt) => opt.isCommandLineOnly || opt.category === Diagnostics.Command_line_Options);
131652
+ const configOpts = simpleOptions.filter((opt) => !contains(cliCommands, opt));
131653
+ output = [
131654
+ ...output,
131655
+ ...generateSectionOptionsOutput(
131656
+ sys2,
131657
+ getDiagnosticText(Diagnostics.COMMAND_LINE_FLAGS),
131658
+ cliCommands,
131659
+ /*subCategory*/
131660
+ false,
131661
+ /*beforeOptionsDescription*/
131662
+ void 0,
131663
+ /*afterOptionsDescription*/
131664
+ void 0
131665
+ ),
131666
+ ...generateSectionOptionsOutput(
131667
+ sys2,
131668
+ getDiagnosticText(Diagnostics.COMMON_COMPILER_OPTIONS),
131669
+ configOpts,
131670
+ /*subCategory*/
131671
+ false,
131672
+ /*beforeOptionsDescription*/
131673
+ void 0,
131674
+ formatMessage(Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc")
131675
+ )
131676
+ ];
131677
+ for (const line of output) {
131678
+ sys2.write(line);
131679
+ }
131680
+ function example(ex, desc) {
131681
+ const examples = typeof ex === "string" ? [ex] : ex;
131682
+ for (const example2 of examples) {
131683
+ output.push(" " + colors.blue(example2) + sys2.newLine);
131684
+ }
131685
+ output.push(" " + getDiagnosticText(desc) + sys2.newLine + sys2.newLine);
131686
+ }
131687
+ }
131688
+ function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
131689
+ let output = [...getHeader(sys2, `${getDiagnosticText(Diagnostics.tsc_Colon_The_TypeScript_Compiler)} - ${getDiagnosticText(Diagnostics.Version_0, version)}`)];
131690
+ output = [...output, ...generateSectionOptionsOutput(
131691
+ sys2,
131692
+ getDiagnosticText(Diagnostics.ALL_COMPILER_OPTIONS),
131693
+ compilerOptions,
131694
+ /*subCategory*/
131695
+ true,
131696
+ /*beforeOptionsDescription*/
131697
+ void 0,
131698
+ formatMessage(Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc")
131699
+ )];
131700
+ output = [...output, ...generateSectionOptionsOutput(
131701
+ sys2,
131702
+ getDiagnosticText(Diagnostics.WATCH_OPTIONS),
131703
+ watchOptions,
131704
+ /*subCategory*/
131705
+ false,
131706
+ getDiagnosticText(Diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon)
131707
+ )];
131708
+ output = [...output, ...generateSectionOptionsOutput(
131709
+ sys2,
131710
+ getDiagnosticText(Diagnostics.BUILD_OPTIONS),
131711
+ buildOptions,
131712
+ /*subCategory*/
131713
+ false,
131714
+ formatMessage(Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")
131715
+ )];
131716
+ for (const line of output) {
131717
+ sys2.write(line);
131718
+ }
131719
+ }
131720
+ function printBuildHelp(sys2, buildOptions) {
131721
+ let output = [...getHeader(sys2, `${getDiagnosticText(Diagnostics.tsc_Colon_The_TypeScript_Compiler)} - ${getDiagnosticText(Diagnostics.Version_0, version)}`)];
131722
+ output = [...output, ...generateSectionOptionsOutput(
131723
+ sys2,
131724
+ getDiagnosticText(Diagnostics.BUILD_OPTIONS),
131725
+ buildOptions,
131726
+ /*subCategory*/
131727
+ false,
131728
+ formatMessage(Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")
131729
+ )];
131730
+ for (const line of output) {
131731
+ sys2.write(line);
131732
+ }
131733
+ }
131734
+ function getHeader(sys2, message) {
131735
+ var _a;
131736
+ const colors = createColors(sys2);
131737
+ const header = [];
131738
+ const terminalWidth = ((_a = sys2.getWidthOfTerminal) == null ? void 0 : _a.call(sys2)) ?? 0;
131739
+ const tsIconLength = 5;
131740
+ const tsIconFirstLine = colors.blueBackground("".padStart(tsIconLength));
131741
+ const tsIconSecondLine = colors.blueBackground(colors.brightWhite("TS ".padStart(tsIconLength)));
131742
+ if (terminalWidth >= message.length + tsIconLength) {
131743
+ const rightAlign = terminalWidth > 120 ? 120 : terminalWidth;
131744
+ const leftAlign = rightAlign - tsIconLength;
131745
+ header.push(message.padEnd(leftAlign) + tsIconFirstLine + sys2.newLine);
131746
+ header.push("".padStart(leftAlign) + tsIconSecondLine + sys2.newLine);
131747
+ } else {
131748
+ header.push(message + sys2.newLine);
131749
+ header.push(sys2.newLine);
131750
+ }
131751
+ return header;
131752
+ }
131753
+ function printHelp(sys2, commandLine) {
131754
+ if (!commandLine.options.all) {
131755
+ printEasyHelp(sys2, getOptionsForHelp(commandLine));
131756
+ } else {
131757
+ printAllHelp(sys2, getOptionsForHelp(commandLine), optionsForBuild, optionsForWatch);
131758
+ }
131759
+ }
131760
+ function executeCommandLineWorker(sys2, cb, commandLine) {
131761
+ let reportDiagnostic = createDiagnosticReporter(sys2);
131762
+ if (commandLine.options.build) {
131763
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_build_must_be_the_first_command_line_argument));
131764
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131765
+ }
131766
+ let configFileName;
131767
+ if (commandLine.options.locale) {
131768
+ validateLocaleAndSetLanguage(commandLine.options.locale, sys2, commandLine.errors);
131769
+ }
131770
+ if (commandLine.errors.length > 0) {
131771
+ commandLine.errors.forEach(reportDiagnostic);
131772
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131773
+ }
131774
+ if (commandLine.options.init) {
131775
+ writeConfigFile(sys2, reportDiagnostic, commandLine.options, commandLine.fileNames);
131776
+ return sys2.exit(0 /* Success */);
131777
+ }
131778
+ if (commandLine.options.version) {
131779
+ printVersion(sys2);
131780
+ return sys2.exit(0 /* Success */);
131781
+ }
131782
+ if (commandLine.options.help || commandLine.options.all) {
131783
+ printHelp(sys2, commandLine);
131784
+ return sys2.exit(0 /* Success */);
131785
+ }
131786
+ if (commandLine.options.watch && commandLine.options.listFilesOnly) {
131787
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
131788
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131789
+ }
131790
+ if (commandLine.options.project) {
131791
+ if (commandLine.fileNames.length !== 0) {
131792
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
131793
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131794
+ }
131795
+ const fileOrDirectory = normalizePath(commandLine.options.project);
131796
+ if (!fileOrDirectory || sys2.directoryExists(fileOrDirectory)) {
131797
+ configFileName = combinePaths(fileOrDirectory, "tsconfig.json");
131798
+ if (!sys2.fileExists(configFileName)) {
131799
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
131800
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131801
+ }
131802
+ } else {
131803
+ configFileName = fileOrDirectory;
131804
+ if (!sys2.fileExists(configFileName)) {
131805
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
131806
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131807
+ }
131808
+ }
131809
+ } else if (commandLine.fileNames.length === 0) {
131810
+ const searchPath = normalizePath(sys2.getCurrentDirectory());
131811
+ configFileName = findConfigFile(searchPath, (fileName) => sys2.fileExists(fileName));
131812
+ }
131813
+ if (commandLine.fileNames.length === 0 && !configFileName) {
131814
+ if (commandLine.options.showConfig) {
131815
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, normalizePath(sys2.getCurrentDirectory())));
131816
+ } else {
131817
+ printVersion(sys2);
131818
+ printHelp(sys2, commandLine);
131819
+ }
131820
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131821
+ }
131822
+ const currentDirectory = sys2.getCurrentDirectory();
131823
+ const commandLineOptions = convertToOptionsWithAbsolutePaths(
131824
+ commandLine.options,
131825
+ (fileName) => getNormalizedAbsolutePath(fileName, currentDirectory)
131826
+ );
131827
+ if (configFileName) {
131828
+ const extendedConfigCache = /* @__PURE__ */ new Map();
131829
+ const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys2, reportDiagnostic);
131830
+ if (commandLineOptions.showConfig) {
131831
+ if (configParseResult.errors.length !== 0) {
131832
+ reportDiagnostic = updateReportDiagnostic(
131833
+ sys2,
131834
+ reportDiagnostic,
131835
+ configParseResult.options
131836
+ );
131837
+ configParseResult.errors.forEach(reportDiagnostic);
131838
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131839
+ }
131840
+ sys2.write(JSON.stringify(convertToTSConfig(configParseResult, configFileName, sys2), null, 4) + sys2.newLine);
131841
+ return sys2.exit(0 /* Success */);
131842
+ }
131843
+ reportDiagnostic = updateReportDiagnostic(
131844
+ sys2,
131845
+ reportDiagnostic,
131846
+ configParseResult.options
131847
+ );
131848
+ if (isWatchSet(configParseResult.options)) {
131849
+ if (reportWatchModeWithoutSysSupport(sys2, reportDiagnostic))
131850
+ return;
131851
+ return createWatchOfConfigFile(
131852
+ sys2,
131853
+ cb,
131854
+ reportDiagnostic,
131855
+ configParseResult,
131856
+ commandLineOptions,
131857
+ commandLine.watchOptions,
131858
+ extendedConfigCache
131859
+ );
131860
+ } else if (isIncrementalCompilation(configParseResult.options)) {
131861
+ performIncrementalCompilation2(
131862
+ sys2,
131863
+ cb,
131864
+ reportDiagnostic,
131865
+ configParseResult
131866
+ );
131867
+ } else {
131868
+ performCompilation(
131869
+ sys2,
131870
+ cb,
131871
+ reportDiagnostic,
131872
+ configParseResult
131873
+ );
131874
+ }
131875
+ } else {
131876
+ if (commandLineOptions.showConfig) {
131877
+ sys2.write(JSON.stringify(convertToTSConfig(commandLine, combinePaths(currentDirectory, "tsconfig.json"), sys2), null, 4) + sys2.newLine);
131878
+ return sys2.exit(0 /* Success */);
131879
+ }
131880
+ reportDiagnostic = updateReportDiagnostic(
131881
+ sys2,
131882
+ reportDiagnostic,
131883
+ commandLineOptions
131884
+ );
131885
+ if (isWatchSet(commandLineOptions)) {
131886
+ if (reportWatchModeWithoutSysSupport(sys2, reportDiagnostic))
131887
+ return;
131888
+ return createWatchOfFilesAndCompilerOptions(
131889
+ sys2,
131890
+ cb,
131891
+ reportDiagnostic,
131892
+ commandLine.fileNames,
131893
+ commandLineOptions,
131894
+ commandLine.watchOptions
131895
+ );
131896
+ } else if (isIncrementalCompilation(commandLineOptions)) {
131897
+ performIncrementalCompilation2(
131898
+ sys2,
131899
+ cb,
131900
+ reportDiagnostic,
131901
+ { ...commandLine, options: commandLineOptions }
131902
+ );
131903
+ } else {
131904
+ performCompilation(
131905
+ sys2,
131906
+ cb,
131907
+ reportDiagnostic,
131908
+ { ...commandLine, options: commandLineOptions }
131909
+ );
131910
+ }
131911
+ }
131912
+ }
131913
+ function isBuild(commandLineArgs) {
131914
+ if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45 /* minus */) {
131915
+ const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase();
131916
+ return firstOption === "build" || firstOption === "b";
131917
+ }
131918
+ return false;
131919
+ }
131920
+ function executeCommandLine(system, cb, commandLineArgs) {
131921
+ if (isBuild(commandLineArgs)) {
131922
+ const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs.slice(1));
131923
+ if (buildOptions.generateCpuProfile && system.enableCPUProfiler) {
131924
+ system.enableCPUProfiler(buildOptions.generateCpuProfile, () => performBuild(
131925
+ system,
131926
+ cb,
131927
+ buildOptions,
131928
+ watchOptions,
131929
+ projects,
131930
+ errors
131931
+ ));
131932
+ } else {
131933
+ return performBuild(
131934
+ system,
131935
+ cb,
131936
+ buildOptions,
131937
+ watchOptions,
131938
+ projects,
131939
+ errors
131940
+ );
131941
+ }
131942
+ }
131943
+ const commandLine = parseCommandLine(commandLineArgs, (path) => system.readFile(path));
131944
+ if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
131945
+ system.enableCPUProfiler(commandLine.options.generateCpuProfile, () => executeCommandLineWorker(
131946
+ system,
131947
+ cb,
131948
+ commandLine
131949
+ ));
131950
+ } else {
131951
+ return executeCommandLineWorker(system, cb, commandLine);
131952
+ }
131953
+ }
131954
+ function reportWatchModeWithoutSysSupport(sys2, reportDiagnostic) {
131955
+ if (!sys2.watchFile || !sys2.watchDirectory) {
131956
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
131957
+ sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131958
+ return true;
131959
+ }
131960
+ return false;
131961
+ }
131962
+ var defaultJSDocParsingMode = 2 /* ParseForTypeErrors */;
131963
+ function performBuild(sys2, cb, buildOptions, watchOptions, projects, errors) {
131964
+ const reportDiagnostic = updateReportDiagnostic(
131965
+ sys2,
131966
+ createDiagnosticReporter(sys2),
131967
+ buildOptions
131968
+ );
131969
+ if (buildOptions.locale) {
131970
+ validateLocaleAndSetLanguage(buildOptions.locale, sys2, errors);
131971
+ }
131972
+ if (errors.length > 0) {
131973
+ errors.forEach(reportDiagnostic);
131974
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131975
+ }
131976
+ if (buildOptions.help) {
131977
+ printVersion(sys2);
131978
+ printBuildHelp(sys2, buildOpts);
131979
+ return sys2.exit(0 /* Success */);
131980
+ }
131981
+ if (projects.length === 0) {
131982
+ printVersion(sys2);
131983
+ printBuildHelp(sys2, buildOpts);
131984
+ return sys2.exit(0 /* Success */);
131985
+ }
131986
+ if (!sys2.getModifiedTime || !sys2.setModifiedTime || buildOptions.clean && !sys2.deleteFile) {
131987
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
131988
+ return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
131989
+ }
131990
+ if (buildOptions.watch) {
131991
+ if (reportWatchModeWithoutSysSupport(sys2, reportDiagnostic))
131992
+ return;
131993
+ const buildHost2 = createSolutionBuilderWithWatchHost(
131994
+ sys2,
131995
+ /*createProgram*/
131996
+ void 0,
131997
+ reportDiagnostic,
131998
+ createBuilderStatusReporter(sys2, shouldBePretty(sys2, buildOptions)),
131999
+ createWatchStatusReporter2(sys2, buildOptions)
132000
+ );
132001
+ buildHost2.jsDocParsingMode = defaultJSDocParsingMode;
132002
+ const solutionPerformance2 = enableSolutionPerformance(sys2, buildOptions);
132003
+ updateSolutionBuilderHost(sys2, cb, buildHost2, solutionPerformance2);
132004
+ const onWatchStatusChange = buildHost2.onWatchStatusChange;
132005
+ let reportBuildStatistics = false;
132006
+ buildHost2.onWatchStatusChange = (d, newLine, options, errorCount) => {
132007
+ onWatchStatusChange == null ? void 0 : onWatchStatusChange(d, newLine, options, errorCount);
132008
+ if (reportBuildStatistics && (d.code === Diagnostics.Found_0_errors_Watching_for_file_changes.code || d.code === Diagnostics.Found_1_error_Watching_for_file_changes.code)) {
132009
+ reportSolutionBuilderTimes(builder2, solutionPerformance2);
132010
+ }
132011
+ };
132012
+ const builder2 = createSolutionBuilderWithWatch(buildHost2, projects, buildOptions, watchOptions);
132013
+ builder2.build();
132014
+ reportSolutionBuilderTimes(builder2, solutionPerformance2);
132015
+ reportBuildStatistics = true;
132016
+ return builder2;
132017
+ }
132018
+ const buildHost = createSolutionBuilderHost(
132019
+ sys2,
132020
+ /*createProgram*/
132021
+ void 0,
132022
+ reportDiagnostic,
132023
+ createBuilderStatusReporter(sys2, shouldBePretty(sys2, buildOptions)),
132024
+ createReportErrorSummary(sys2, buildOptions)
132025
+ );
132026
+ buildHost.jsDocParsingMode = defaultJSDocParsingMode;
132027
+ const solutionPerformance = enableSolutionPerformance(sys2, buildOptions);
132028
+ updateSolutionBuilderHost(sys2, cb, buildHost, solutionPerformance);
132029
+ const builder = createSolutionBuilder(buildHost, projects, buildOptions);
132030
+ const exitStatus = buildOptions.clean ? builder.clean() : builder.build();
132031
+ reportSolutionBuilderTimes(builder, solutionPerformance);
132032
+ dumpTracingLegend();
132033
+ return sys2.exit(exitStatus);
132034
+ }
132035
+ function createReportErrorSummary(sys2, options) {
132036
+ return shouldBePretty(sys2, options) ? (errorCount, filesInError) => sys2.write(getErrorSummaryText(errorCount, filesInError, sys2.newLine, sys2)) : void 0;
132037
+ }
132038
+ function performCompilation(sys2, cb, reportDiagnostic, config) {
132039
+ const { fileNames, options, projectReferences } = config;
132040
+ const host = createCompilerHostWorker(
132041
+ options,
132042
+ /*setParentNodes*/
132043
+ void 0,
132044
+ sys2
132045
+ );
132046
+ host.jsDocParsingMode = defaultJSDocParsingMode;
132047
+ const currentDirectory = host.getCurrentDirectory();
132048
+ const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
132049
+ changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, currentDirectory, getCanonicalFileName));
132050
+ enableStatisticsAndTracing(
132051
+ sys2,
132052
+ options,
132053
+ /*isBuildMode*/
132054
+ false
132055
+ );
132056
+ const programOptions = {
132057
+ rootNames: fileNames,
132058
+ options,
132059
+ projectReferences,
132060
+ host,
132061
+ configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config)
132062
+ };
132063
+ const program = createProgram(programOptions);
132064
+ const exitStatus = emitFilesAndReportErrorsAndGetExitStatus(
132065
+ program,
132066
+ reportDiagnostic,
132067
+ (s) => sys2.write(s + sys2.newLine),
132068
+ createReportErrorSummary(sys2, options)
132069
+ );
132070
+ reportStatistics(
132071
+ sys2,
132072
+ program,
132073
+ /*solutionPerformance*/
132074
+ void 0
132075
+ );
132076
+ cb(program);
132077
+ return sys2.exit(exitStatus);
132078
+ }
132079
+ function performIncrementalCompilation2(sys2, cb, reportDiagnostic, config) {
132080
+ const { options, fileNames, projectReferences } = config;
132081
+ enableStatisticsAndTracing(
132082
+ sys2,
132083
+ options,
132084
+ /*isBuildMode*/
132085
+ false
132086
+ );
132087
+ const host = createIncrementalCompilerHost(options, sys2);
132088
+ host.jsDocParsingMode = defaultJSDocParsingMode;
132089
+ const exitStatus = performIncrementalCompilation({
132090
+ host,
132091
+ system: sys2,
132092
+ rootNames: fileNames,
132093
+ options,
132094
+ configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config),
132095
+ projectReferences,
132096
+ reportDiagnostic,
132097
+ reportErrorSummary: createReportErrorSummary(sys2, options),
132098
+ afterProgramEmitAndDiagnostics: (builderProgram) => {
132099
+ reportStatistics(
132100
+ sys2,
132101
+ builderProgram.getProgram(),
132102
+ /*solutionPerformance*/
132103
+ void 0
132104
+ );
132105
+ cb(builderProgram);
132106
+ }
132107
+ });
132108
+ return sys2.exit(exitStatus);
132109
+ }
132110
+ function updateSolutionBuilderHost(sys2, cb, buildHost, solutionPerformance) {
132111
+ updateCreateProgram(
132112
+ sys2,
132113
+ buildHost,
132114
+ /*isBuildMode*/
132115
+ true
132116
+ );
132117
+ buildHost.afterProgramEmitAndDiagnostics = (program) => {
132118
+ reportStatistics(sys2, program.getProgram(), solutionPerformance);
132119
+ cb(program);
132120
+ };
132121
+ }
132122
+ function updateCreateProgram(sys2, host, isBuildMode) {
132123
+ const compileUsingBuilder = host.createProgram;
132124
+ host.createProgram = (rootNames, options, host2, oldProgram, configFileParsingDiagnostics, projectReferences) => {
132125
+ Debug.assert(rootNames !== void 0 || options === void 0 && !!oldProgram);
132126
+ if (options !== void 0) {
132127
+ enableStatisticsAndTracing(sys2, options, isBuildMode);
132128
+ }
132129
+ return compileUsingBuilder(rootNames, options, host2, oldProgram, configFileParsingDiagnostics, projectReferences);
132130
+ };
132131
+ }
132132
+ function updateWatchCompilationHost(sys2, cb, watchCompilerHost) {
132133
+ watchCompilerHost.jsDocParsingMode = defaultJSDocParsingMode;
132134
+ updateCreateProgram(
132135
+ sys2,
132136
+ watchCompilerHost,
132137
+ /*isBuildMode*/
132138
+ false
132139
+ );
132140
+ const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
132141
+ watchCompilerHost.afterProgramCreate = (builderProgram) => {
132142
+ emitFilesUsingBuilder(builderProgram);
132143
+ reportStatistics(
132144
+ sys2,
132145
+ builderProgram.getProgram(),
132146
+ /*solutionPerformance*/
132147
+ void 0
132148
+ );
132149
+ cb(builderProgram);
132150
+ };
132151
+ }
132152
+ function createWatchStatusReporter2(sys2, options) {
132153
+ return createWatchStatusReporter(sys2, shouldBePretty(sys2, options));
132154
+ }
132155
+ function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend, extendedConfigCache) {
132156
+ const watchCompilerHost = createWatchCompilerHostOfConfigFile({
132157
+ configFileName: configParseResult.options.configFilePath,
132158
+ optionsToExtend,
132159
+ watchOptionsToExtend,
132160
+ system,
132161
+ reportDiagnostic,
132162
+ reportWatchStatus: createWatchStatusReporter2(system, configParseResult.options)
132163
+ });
132164
+ updateWatchCompilationHost(system, cb, watchCompilerHost);
132165
+ watchCompilerHost.configFileParsingResult = configParseResult;
132166
+ watchCompilerHost.extendedConfigCache = extendedConfigCache;
132167
+ return createWatchProgram(watchCompilerHost);
132168
+ }
132169
+ function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
132170
+ const watchCompilerHost = createWatchCompilerHostOfFilesAndCompilerOptions({
132171
+ rootFiles,
132172
+ options,
132173
+ watchOptions,
132174
+ system,
132175
+ reportDiagnostic,
132176
+ reportWatchStatus: createWatchStatusReporter2(system, options)
132177
+ });
132178
+ updateWatchCompilationHost(system, cb, watchCompilerHost);
132179
+ return createWatchProgram(watchCompilerHost);
132180
+ }
132181
+ function enableSolutionPerformance(system, options) {
132182
+ if (system === sys && options.extendedDiagnostics) {
132183
+ enable();
132184
+ return createSolutionPerfomrance();
132185
+ }
132186
+ }
132187
+ function createSolutionPerfomrance() {
132188
+ let statistics;
132189
+ return {
132190
+ addAggregateStatistic,
132191
+ forEachAggregateStatistics: forEachAggreateStatistics,
132192
+ clear: clear2
132193
+ };
132194
+ function addAggregateStatistic(s) {
132195
+ const existing = statistics == null ? void 0 : statistics.get(s.name);
132196
+ if (existing) {
132197
+ if (existing.type === 2 /* memory */)
132198
+ existing.value = Math.max(existing.value, s.value);
132199
+ else
132200
+ existing.value += s.value;
132201
+ } else {
132202
+ (statistics ?? (statistics = /* @__PURE__ */ new Map())).set(s.name, s);
132203
+ }
132204
+ }
132205
+ function forEachAggreateStatistics(cb) {
132206
+ statistics == null ? void 0 : statistics.forEach(cb);
132207
+ }
132208
+ function clear2() {
132209
+ statistics = void 0;
132210
+ }
132211
+ }
132212
+ function reportSolutionBuilderTimes(builder, solutionPerformance) {
132213
+ if (!solutionPerformance)
132214
+ return;
132215
+ if (!isEnabled()) {
132216
+ sys.write(Diagnostics.Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found.message + "\n");
132217
+ return;
132218
+ }
132219
+ const statistics = [];
132220
+ statistics.push(
132221
+ { name: "Projects in scope", value: getBuildOrderFromAnyBuildOrder(builder.getBuildOrder()).length, type: 1 /* count */ }
132222
+ );
132223
+ reportSolutionBuilderCountStatistic("SolutionBuilder::Projects built");
132224
+ reportSolutionBuilderCountStatistic("SolutionBuilder::Timestamps only updates");
132225
+ reportSolutionBuilderCountStatistic("SolutionBuilder::Bundles updated");
132226
+ solutionPerformance.forEachAggregateStatistics((s) => {
132227
+ s.name = `Aggregate ${s.name}`;
132228
+ statistics.push(s);
132229
+ });
132230
+ forEachMeasure((name, duration) => {
132231
+ if (isSolutionMarkOrMeasure(name))
132232
+ statistics.push({ name: `${getNameFromSolutionBuilderMarkOrMeasure(name)} time`, value: duration, type: 0 /* time */ });
132233
+ });
132234
+ disable();
132235
+ enable();
132236
+ solutionPerformance.clear();
132237
+ reportAllStatistics(sys, statistics);
132238
+ function reportSolutionBuilderCountStatistic(name) {
132239
+ const value = getCount(name);
132240
+ if (value) {
132241
+ statistics.push({ name: getNameFromSolutionBuilderMarkOrMeasure(name), value, type: 1 /* count */ });
132242
+ }
132243
+ }
132244
+ function getNameFromSolutionBuilderMarkOrMeasure(name) {
132245
+ return name.replace("SolutionBuilder::", "");
132246
+ }
132247
+ }
132248
+ function canReportDiagnostics(system, compilerOptions) {
132249
+ return system === sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
132250
+ }
132251
+ function canTrace(system, compilerOptions) {
132252
+ return system === sys && compilerOptions.generateTrace;
132253
+ }
132254
+ function enableStatisticsAndTracing(system, compilerOptions, isBuildMode) {
132255
+ if (canReportDiagnostics(system, compilerOptions)) {
132256
+ enable(system);
132257
+ }
132258
+ if (canTrace(system, compilerOptions)) {
132259
+ startTracing(isBuildMode ? "build" : "project", compilerOptions.generateTrace, compilerOptions.configFilePath);
132260
+ }
132261
+ }
132262
+ function isSolutionMarkOrMeasure(name) {
132263
+ return startsWith(name, "SolutionBuilder::");
132264
+ }
132265
+ function reportStatistics(sys2, program, solutionPerformance) {
132266
+ var _a;
132267
+ const compilerOptions = program.getCompilerOptions();
132268
+ if (canTrace(sys2, compilerOptions)) {
132269
+ (_a = tracing) == null ? void 0 : _a.stopTracing();
132270
+ }
132271
+ let statistics;
132272
+ if (canReportDiagnostics(sys2, compilerOptions)) {
132273
+ statistics = [];
132274
+ const memoryUsed = sys2.getMemoryUsage ? sys2.getMemoryUsage() : -1;
132275
+ reportCountStatistic("Files", program.getSourceFiles().length);
132276
+ const lineCounts = countLines(program);
132277
+ if (compilerOptions.extendedDiagnostics) {
132278
+ for (const [key, value] of lineCounts.entries()) {
132279
+ reportCountStatistic("Lines of " + key, value);
132280
+ }
132281
+ } else {
132282
+ reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count) => sum + count, 0));
132283
+ }
132284
+ reportCountStatistic("Identifiers", program.getIdentifierCount());
132285
+ reportCountStatistic("Symbols", program.getSymbolCount());
132286
+ reportCountStatistic("Types", program.getTypeCount());
132287
+ reportCountStatistic("Instantiations", program.getInstantiationCount());
132288
+ if (memoryUsed >= 0) {
132289
+ reportStatisticalValue(
132290
+ { name: "Memory used", value: memoryUsed, type: 2 /* memory */ },
132291
+ /*aggregate*/
132292
+ true
132293
+ );
132294
+ }
132295
+ const isPerformanceEnabled = isEnabled();
132296
+ const programTime = isPerformanceEnabled ? getDuration("Program") : 0;
132297
+ const bindTime = isPerformanceEnabled ? getDuration("Bind") : 0;
132298
+ const checkTime = isPerformanceEnabled ? getDuration("Check") : 0;
132299
+ const emitTime = isPerformanceEnabled ? getDuration("Emit") : 0;
132300
+ if (compilerOptions.extendedDiagnostics) {
132301
+ const caches = program.getRelationCacheSizes();
132302
+ reportCountStatistic("Assignability cache size", caches.assignable);
132303
+ reportCountStatistic("Identity cache size", caches.identity);
132304
+ reportCountStatistic("Subtype cache size", caches.subtype);
132305
+ reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
132306
+ if (isPerformanceEnabled) {
132307
+ forEachMeasure((name, duration) => {
132308
+ if (!isSolutionMarkOrMeasure(name))
132309
+ reportTimeStatistic(
132310
+ `${name} time`,
132311
+ duration,
132312
+ /*aggregate*/
132313
+ true
132314
+ );
132315
+ });
132316
+ }
132317
+ } else if (isPerformanceEnabled) {
132318
+ reportTimeStatistic(
132319
+ "I/O read",
132320
+ getDuration("I/O Read"),
132321
+ /*aggregate*/
132322
+ true
132323
+ );
132324
+ reportTimeStatistic(
132325
+ "I/O write",
132326
+ getDuration("I/O Write"),
132327
+ /*aggregate*/
132328
+ true
132329
+ );
132330
+ reportTimeStatistic(
132331
+ "Parse time",
132332
+ programTime,
132333
+ /*aggregate*/
132334
+ true
132335
+ );
132336
+ reportTimeStatistic(
132337
+ "Bind time",
132338
+ bindTime,
132339
+ /*aggregate*/
132340
+ true
132341
+ );
132342
+ reportTimeStatistic(
132343
+ "Check time",
132344
+ checkTime,
132345
+ /*aggregate*/
132346
+ true
132347
+ );
132348
+ reportTimeStatistic(
132349
+ "Emit time",
132350
+ emitTime,
132351
+ /*aggregate*/
132352
+ true
132353
+ );
132354
+ }
132355
+ if (isPerformanceEnabled) {
132356
+ reportTimeStatistic(
132357
+ "Total time",
132358
+ programTime + bindTime + checkTime + emitTime,
132359
+ /*aggregate*/
132360
+ false
132361
+ );
132362
+ }
132363
+ reportAllStatistics(sys2, statistics);
132364
+ if (!isPerformanceEnabled) {
132365
+ sys2.write(Diagnostics.Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found.message + "\n");
132366
+ } else {
132367
+ if (solutionPerformance) {
132368
+ forEachMeasure((name) => {
132369
+ if (!isSolutionMarkOrMeasure(name))
132370
+ clearMeasures(name);
132371
+ });
132372
+ forEachMark((name) => {
132373
+ if (!isSolutionMarkOrMeasure(name))
132374
+ clearMarks(name);
132375
+ });
132376
+ } else {
132377
+ disable();
132378
+ }
132379
+ }
132380
+ }
132381
+ function reportStatisticalValue(s, aggregate) {
132382
+ statistics.push(s);
132383
+ if (aggregate)
132384
+ solutionPerformance == null ? void 0 : solutionPerformance.addAggregateStatistic(s);
132385
+ }
132386
+ function reportCountStatistic(name, count) {
132387
+ reportStatisticalValue(
132388
+ { name, value: count, type: 1 /* count */ },
132389
+ /*aggregate*/
132390
+ true
132391
+ );
132392
+ }
132393
+ function reportTimeStatistic(name, time, aggregate) {
132394
+ reportStatisticalValue({ name, value: time, type: 0 /* time */ }, aggregate);
132395
+ }
132396
+ }
132397
+ function reportAllStatistics(sys2, statistics) {
132398
+ let nameSize = 0;
132399
+ let valueSize = 0;
132400
+ for (const s of statistics) {
132401
+ if (s.name.length > nameSize) {
132402
+ nameSize = s.name.length;
132403
+ }
132404
+ const value = statisticValue(s);
132405
+ if (value.length > valueSize) {
132406
+ valueSize = value.length;
132407
+ }
132408
+ }
132409
+ for (const s of statistics) {
132410
+ sys2.write(`${s.name}:`.padEnd(nameSize + 2) + statisticValue(s).toString().padStart(valueSize) + sys2.newLine);
132411
+ }
132412
+ }
132413
+ function statisticValue(s) {
132414
+ switch (s.type) {
132415
+ case 1 /* count */:
132416
+ return "" + s.value;
132417
+ case 0 /* time */:
132418
+ return (s.value / 1e3).toFixed(2) + "s";
132419
+ case 2 /* memory */:
132420
+ return Math.round(s.value / 1e3) + "K";
132421
+ default:
132422
+ Debug.assertNever(s.type);
132423
+ }
132424
+ }
132425
+ function writeConfigFile(sys2, reportDiagnostic, options, fileNames) {
132426
+ const currentDirectory = sys2.getCurrentDirectory();
132427
+ const file = normalizePath(combinePaths(currentDirectory, "tsconfig.json"));
132428
+ if (sys2.fileExists(file)) {
132429
+ reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
132430
+ } else {
132431
+ sys2.writeFile(file, generateTSConfig(options, fileNames, sys2.newLine));
132432
+ const output = [sys2.newLine, ...getHeader(sys2, "Created a new tsconfig.json with:")];
132433
+ output.push(getCompilerOptionsDiffValue(options, sys2.newLine) + sys2.newLine + sys2.newLine);
132434
+ output.push(`You can learn more at https://aka.ms/tsconfig` + sys2.newLine);
132435
+ for (const line of output) {
132436
+ sys2.write(line);
132437
+ }
132438
+ }
132439
+ return;
132440
+ }
132441
+
131038
132442
  // src/jsTyping/_namespaces/ts.JsTyping.ts
131039
132443
  var ts_JsTyping_exports = {};
131040
132444
  __export(ts_JsTyping_exports, {
@@ -144390,11 +145794,14 @@ var NodeObject = class {
144390
145794
  constructor(kind, pos, end) {
144391
145795
  this.pos = pos;
144392
145796
  this.end = end;
145797
+ this.kind = kind;
145798
+ this.id = 0;
144393
145799
  this.flags = 0 /* None */;
144394
145800
  this.modifierFlagsCache = 0 /* None */;
144395
145801
  this.transformFlags = 0 /* None */;
144396
145802
  this.parent = void 0;
144397
- this.kind = kind;
145803
+ this.original = void 0;
145804
+ this.emitNode = void 0;
144398
145805
  }
144399
145806
  assertHasRealPosition(message) {
144400
145807
  Debug.assert(!positionIsSynthesized(this.pos) && !positionIsSynthesized(this.end), message || "Node must have a real position for this operation");
@@ -144445,7 +145852,7 @@ var NodeObject = class {
144445
145852
  }
144446
145853
  getChildren(sourceFile) {
144447
145854
  this.assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine");
144448
- return this._children || (this._children = createChildren(this, sourceFile));
145855
+ return getNodeChildren(this) ?? setNodeChildren(this, createChildren(this, sourceFile));
144449
145856
  }
144450
145857
  getFirstToken(sourceFile) {
144451
145858
  this.assertHasRealPosition();
@@ -144521,24 +145928,27 @@ function addSyntheticNodes(nodes, pos, end, parent2) {
144521
145928
  }
144522
145929
  function createSyntaxList(nodes, parent2) {
144523
145930
  const list = createNode(352 /* SyntaxList */, nodes.pos, nodes.end, parent2);
144524
- list._children = [];
145931
+ const children = [];
144525
145932
  let pos = nodes.pos;
144526
145933
  for (const node of nodes) {
144527
- addSyntheticNodes(list._children, pos, node.pos, parent2);
144528
- list._children.push(node);
145934
+ addSyntheticNodes(children, pos, node.pos, parent2);
145935
+ children.push(node);
144529
145936
  pos = node.end;
144530
145937
  }
144531
- addSyntheticNodes(list._children, pos, nodes.end, parent2);
145938
+ addSyntheticNodes(children, pos, nodes.end, parent2);
145939
+ setNodeChildren(list, children);
144532
145940
  return list;
144533
145941
  }
144534
145942
  var TokenOrIdentifierObject = class {
144535
- constructor(pos, end) {
145943
+ constructor(kind, pos, end) {
144536
145944
  this.pos = pos;
144537
145945
  this.end = end;
145946
+ this.kind = kind;
145947
+ this.id = 0;
144538
145948
  this.flags = 0 /* None */;
144539
- this.modifierFlagsCache = 0 /* None */;
144540
145949
  this.transformFlags = 0 /* None */;
144541
145950
  this.parent = void 0;
145951
+ this.emitNode = void 0;
144542
145952
  }
144543
145953
  getSourceFile() {
144544
145954
  return getSourceFileOfNode(this);
@@ -144591,10 +146001,20 @@ var TokenOrIdentifierObject = class {
144591
146001
  };
144592
146002
  var SymbolObject = class {
144593
146003
  constructor(flags, name) {
144594
- this.id = 0;
144595
- this.mergeId = 0;
144596
146004
  this.flags = flags;
144597
146005
  this.escapedName = name;
146006
+ this.declarations = void 0;
146007
+ this.valueDeclaration = void 0;
146008
+ this.id = 0;
146009
+ this.mergeId = 0;
146010
+ this.parent = void 0;
146011
+ this.members = void 0;
146012
+ this.exports = void 0;
146013
+ this.exportSymbol = void 0;
146014
+ this.constEnumOnlyModule = void 0;
146015
+ this.isReferenced = void 0;
146016
+ this.lastAssignmentPos = void 0;
146017
+ this.links = void 0;
144598
146018
  }
144599
146019
  getFlags() {
144600
146020
  return this.flags;
@@ -144674,34 +146094,29 @@ var SymbolObject = class {
144674
146094
  };
144675
146095
  var TokenObject = class extends TokenOrIdentifierObject {
144676
146096
  constructor(kind, pos, end) {
144677
- super(pos, end);
144678
- this.kind = kind;
146097
+ super(kind, pos, end);
144679
146098
  }
144680
146099
  };
144681
146100
  var IdentifierObject = class extends TokenOrIdentifierObject {
144682
- constructor(_kind, pos, end) {
144683
- super(pos, end);
144684
- this.kind = 80 /* Identifier */;
146101
+ constructor(kind, pos, end) {
146102
+ super(kind, pos, end);
144685
146103
  }
144686
146104
  get text() {
144687
146105
  return idText(this);
144688
146106
  }
144689
146107
  };
144690
- IdentifierObject.prototype.kind = 80 /* Identifier */;
144691
146108
  var PrivateIdentifierObject = class extends TokenOrIdentifierObject {
144692
- constructor(_kind, pos, end) {
144693
- super(pos, end);
144694
- this.kind = 81 /* PrivateIdentifier */;
146109
+ constructor(kind, pos, end) {
146110
+ super(kind, pos, end);
144695
146111
  }
144696
146112
  get text() {
144697
146113
  return idText(this);
144698
146114
  }
144699
146115
  };
144700
- PrivateIdentifierObject.prototype.kind = 81 /* PrivateIdentifier */;
144701
146116
  var TypeObject = class {
144702
146117
  constructor(checker, flags) {
144703
- this.checker = checker;
144704
146118
  this.flags = flags;
146119
+ this.checker = checker;
144705
146120
  }
144706
146121
  getFlags() {
144707
146122
  return this.flags;
@@ -144791,8 +146206,8 @@ var TypeObject = class {
144791
146206
  var SignatureObject = class {
144792
146207
  // same
144793
146208
  constructor(checker, flags) {
144794
- this.checker = checker;
144795
146209
  this.flags = flags;
146210
+ this.checker = checker;
144796
146211
  }
144797
146212
  getDeclaration() {
144798
146213
  return this.declaration;
@@ -144888,7 +146303,6 @@ function findBaseOfDeclaration(checker, declaration, cb) {
144888
146303
  var SourceFileObject = class extends NodeObject {
144889
146304
  constructor(kind, pos, end) {
144890
146305
  super(kind, pos, end);
144891
- this.kind = 307 /* SourceFile */;
144892
146306
  }
144893
146307
  update(newText, textChangeRange) {
144894
146308
  return updateSourceFile(this, newText, textChangeRange);
@@ -145039,7 +146453,7 @@ var SourceMapSourceObject = class {
145039
146453
  constructor(fileName, text, skipTrivia2) {
145040
146454
  this.fileName = fileName;
145041
146455
  this.text = text;
145042
- this.skipTrivia = skipTrivia2;
146456
+ this.skipTrivia = skipTrivia2 || ((pos) => pos);
145043
146457
  }
145044
146458
  getLineAndCharacterOfPosition(pos) {
145045
146459
  return getLineAndCharacterOfPosition(this, pos);
@@ -145682,6 +147096,9 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
145682
147096
  function shouldGetType(sourceFile, node, position) {
145683
147097
  switch (node.kind) {
145684
147098
  case 80 /* Identifier */:
147099
+ if (node.flags & 16777216 /* JSDoc */ && !isInJSFile(node) && (node.parent.kind === 171 /* PropertySignature */ && node.parent.name === node || findAncestor(node, (n) => n.kind === 169 /* Parameter */))) {
147100
+ return false;
147101
+ }
145685
147102
  return !isLabelName(node) && !isTagName(node) && !isConstTypeReference(node.parent);
145686
147103
  case 211 /* PropertyAccessExpression */:
145687
147104
  case 166 /* QualifiedName */:
@@ -150175,7 +151592,8 @@ function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program)
150175
151592
  const checker = program.getTypeChecker();
150176
151593
  for (const specifier2 of nonTypeOnlySpecifiers) {
150177
151594
  const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
150178
- return !isValidTypeOnlyAliasUseSite(usage);
151595
+ const symbol = checker.getSymbolAtLocation(usage);
151596
+ return !!symbol && checker.symbolIsValue(symbol) || !isValidTypeOnlyAliasUseSite(usage);
150179
151597
  });
150180
151598
  if (isUsedAsValue) {
150181
151599
  return false;
@@ -173560,7 +174978,8 @@ var SmartIndenter;
173560
174978
  return childKind !== 290 /* JsxClosingFragment */;
173561
174979
  case 193 /* IntersectionType */:
173562
174980
  case 192 /* UnionType */:
173563
- if (childKind === 187 /* TypeLiteral */ || childKind === 189 /* TupleType */) {
174981
+ case 238 /* SatisfiesExpression */:
174982
+ if (childKind === 187 /* TypeLiteral */ || childKind === 189 /* TupleType */ || childKind === 200 /* MappedType */) {
173564
174983
  return false;
173565
174984
  }
173566
174985
  break;
@@ -173728,6 +175147,7 @@ __export(ts_exports2, {
173728
175147
  SignatureKind: () => SignatureKind,
173729
175148
  SmartSelectionRange: () => ts_SmartSelectionRange_exports,
173730
175149
  SnippetKind: () => SnippetKind,
175150
+ StatisticType: () => StatisticType,
173731
175151
  StructureIsReused: () => StructureIsReused,
173732
175152
  SymbolAccessibility: () => SymbolAccessibility,
173733
175153
  SymbolDisplay: () => ts_SymbolDisplay_exports,
@@ -173976,6 +175396,7 @@ __export(ts_exports2, {
173976
175396
  createExternalHelpersImportDeclarationIfNeeded: () => createExternalHelpersImportDeclarationIfNeeded,
173977
175397
  createFileDiagnostic: () => createFileDiagnostic,
173978
175398
  createFileDiagnosticFromMessageChain: () => createFileDiagnosticFromMessageChain,
175399
+ createFlowNode: () => createFlowNode,
173979
175400
  createForOfBindingStatement: () => createForOfBindingStatement,
173980
175401
  createGetCanonicalFileName: () => createGetCanonicalFileName,
173981
175402
  createGetSourceFile: () => createGetSourceFile,
@@ -174107,7 +175528,9 @@ __export(ts_exports2, {
174107
175528
  escapeSnippetText: () => escapeSnippetText,
174108
175529
  escapeString: () => escapeString,
174109
175530
  escapeTemplateSubstitution: () => escapeTemplateSubstitution,
175531
+ evaluatorResult: () => evaluatorResult,
174110
175532
  every: () => every,
175533
+ executeCommandLine: () => executeCommandLine,
174111
175534
  expandPreOrPostfixIncrementOrDecrementExpression: () => expandPreOrPostfixIncrementOrDecrementExpression,
174112
175535
  explainFiles: () => explainFiles,
174113
175536
  explainIfFileIsRedirectAndImpliedFormat: () => explainIfFileIsRedirectAndImpliedFormat,
@@ -174473,6 +175896,7 @@ __export(ts_exports2, {
174473
175896
  getNewLineOrDefaultFromHost: () => getNewLineOrDefaultFromHost,
174474
175897
  getNewTargetContainer: () => getNewTargetContainer,
174475
175898
  getNextJSDocCommentLocation: () => getNextJSDocCommentLocation,
175899
+ getNodeChildren: () => getNodeChildren,
174476
175900
  getNodeForGeneratedName: () => getNodeForGeneratedName,
174477
175901
  getNodeId: () => getNodeId,
174478
175902
  getNodeKind: () => getNodeKind,
@@ -174795,6 +176219,7 @@ __export(ts_exports2, {
174795
176219
  isBooleanLiteral: () => isBooleanLiteral,
174796
176220
  isBreakOrContinueStatement: () => isBreakOrContinueStatement,
174797
176221
  isBreakStatement: () => isBreakStatement,
176222
+ isBuild: () => isBuild,
174798
176223
  isBuildInfoFile: () => isBuildInfoFile,
174799
176224
  isBuilderProgram: () => isBuilderProgram2,
174800
176225
  isBundle: () => isBundle,
@@ -175326,7 +176751,6 @@ __export(ts_exports2, {
175326
176751
  isSuperProperty: () => isSuperProperty,
175327
176752
  isSupportedSourceFileName: () => isSupportedSourceFileName,
175328
176753
  isSwitchStatement: () => isSwitchStatement,
175329
- isSyntacticallyString: () => isSyntacticallyString,
175330
176754
  isSyntaxList: () => isSyntaxList,
175331
176755
  isSyntheticExpression: () => isSyntheticExpression,
175332
176756
  isSyntheticReference: () => isSyntheticReference,
@@ -175658,6 +177082,7 @@ __export(ts_exports2, {
175658
177082
  setInternalEmitFlags: () => setInternalEmitFlags,
175659
177083
  setLocalizedDiagnosticMessages: () => setLocalizedDiagnosticMessages,
175660
177084
  setModuleDefaultHelper: () => setModuleDefaultHelper,
177085
+ setNodeChildren: () => setNodeChildren,
175661
177086
  setNodeFlags: () => setNodeFlags,
175662
177087
  setObjectAllocator: () => setObjectAllocator,
175663
177088
  setOriginalNode: () => setOriginalNode,
@@ -175852,6 +177277,7 @@ __export(ts_exports2, {
175852
177277
  unorderedRemoveItem: () => unorderedRemoveItem,
175853
177278
  unorderedRemoveItemAt: () => unorderedRemoveItemAt,
175854
177279
  unreachableCodeIsError: () => unreachableCodeIsError,
177280
+ unsetNodeChildren: () => unsetNodeChildren,
175855
177281
  unusedLabelIsError: () => unusedLabelIsError,
175856
177282
  unwrapInnermostStatementOfLabel: () => unwrapInnermostStatementOfLabel,
175857
177283
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
@@ -187944,6 +189370,7 @@ if (typeof console !== "undefined") {
187944
189370
  SignatureKind,
187945
189371
  SmartSelectionRange,
187946
189372
  SnippetKind,
189373
+ StatisticType,
187947
189374
  StructureIsReused,
187948
189375
  SymbolAccessibility,
187949
189376
  SymbolDisplay,
@@ -188192,6 +189619,7 @@ if (typeof console !== "undefined") {
188192
189619
  createExternalHelpersImportDeclarationIfNeeded,
188193
189620
  createFileDiagnostic,
188194
189621
  createFileDiagnosticFromMessageChain,
189622
+ createFlowNode,
188195
189623
  createForOfBindingStatement,
188196
189624
  createGetCanonicalFileName,
188197
189625
  createGetSourceFile,
@@ -188323,7 +189751,9 @@ if (typeof console !== "undefined") {
188323
189751
  escapeSnippetText,
188324
189752
  escapeString,
188325
189753
  escapeTemplateSubstitution,
189754
+ evaluatorResult,
188326
189755
  every,
189756
+ executeCommandLine,
188327
189757
  expandPreOrPostfixIncrementOrDecrementExpression,
188328
189758
  explainFiles,
188329
189759
  explainIfFileIsRedirectAndImpliedFormat,
@@ -188689,6 +190119,7 @@ if (typeof console !== "undefined") {
188689
190119
  getNewLineOrDefaultFromHost,
188690
190120
  getNewTargetContainer,
188691
190121
  getNextJSDocCommentLocation,
190122
+ getNodeChildren,
188692
190123
  getNodeForGeneratedName,
188693
190124
  getNodeId,
188694
190125
  getNodeKind,
@@ -189011,6 +190442,7 @@ if (typeof console !== "undefined") {
189011
190442
  isBooleanLiteral,
189012
190443
  isBreakOrContinueStatement,
189013
190444
  isBreakStatement,
190445
+ isBuild,
189014
190446
  isBuildInfoFile,
189015
190447
  isBuilderProgram,
189016
190448
  isBundle,
@@ -189542,7 +190974,6 @@ if (typeof console !== "undefined") {
189542
190974
  isSuperProperty,
189543
190975
  isSupportedSourceFileName,
189544
190976
  isSwitchStatement,
189545
- isSyntacticallyString,
189546
190977
  isSyntaxList,
189547
190978
  isSyntheticExpression,
189548
190979
  isSyntheticReference,
@@ -189874,6 +191305,7 @@ if (typeof console !== "undefined") {
189874
191305
  setInternalEmitFlags,
189875
191306
  setLocalizedDiagnosticMessages,
189876
191307
  setModuleDefaultHelper,
191308
+ setNodeChildren,
189877
191309
  setNodeFlags,
189878
191310
  setObjectAllocator,
189879
191311
  setOriginalNode,
@@ -190068,6 +191500,7 @@ if (typeof console !== "undefined") {
190068
191500
  unorderedRemoveItem,
190069
191501
  unorderedRemoveItemAt,
190070
191502
  unreachableCodeIsError,
191503
+ unsetNodeChildren,
190071
191504
  unusedLabelIsError,
190072
191505
  unwrapInnermostStatementOfLabel,
190073
191506
  updateErrorForNoInputFiles,