@typescript-deploys/pr-build 5.6.0-pr-58760-2 → 5.6.0-pr-58514-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-insiders.20240603`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240610`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -7873,7 +7873,8 @@ var Diagnostics = {
7873
7873
  Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
7874
7874
  await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block."),
7875
7875
  _0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled: diag(18055, 1 /* Error */, "_0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is__18055", "'{0}' has a string type, but must have syntactically recognizable string syntax when 'isolatedModules' is enabled."),
7876
- Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled: diag(18056, 1 /* Error */, "Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is__18056", "Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled.")
7876
+ Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled: diag(18056, 1 /* Error */, "Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is__18056", "Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled."),
7877
+ String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020: diag(18057, 1 /* Error */, "String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es_18057", "String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'.")
7877
7878
  };
7878
7879
 
7879
7880
  // src/compiler/scanner.ts
@@ -8033,16 +8034,16 @@ var textToToken = new Map(Object.entries({
8033
8034
  "#": 63 /* HashToken */,
8034
8035
  "`": 62 /* BacktickToken */
8035
8036
  }));
8036
- var charToRegExpFlag = new Map(Object.entries({
8037
- d: 1 /* HasIndices */,
8038
- g: 2 /* Global */,
8039
- i: 4 /* IgnoreCase */,
8040
- m: 8 /* Multiline */,
8041
- s: 16 /* DotAll */,
8042
- u: 32 /* Unicode */,
8043
- v: 64 /* UnicodeSets */,
8044
- y: 128 /* Sticky */
8045
- }));
8037
+ var charCodeToRegExpFlag = /* @__PURE__ */ new Map([
8038
+ [100 /* d */, 1 /* HasIndices */],
8039
+ [103 /* g */, 2 /* Global */],
8040
+ [105 /* i */, 4 /* IgnoreCase */],
8041
+ [109 /* m */, 8 /* Multiline */],
8042
+ [115 /* s */, 16 /* DotAll */],
8043
+ [117 /* u */, 32 /* Unicode */],
8044
+ [118 /* v */, 64 /* UnicodeSets */],
8045
+ [121 /* y */, 128 /* Sticky */]
8046
+ ]);
8046
8047
  var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
8047
8048
  [1 /* HasIndices */, 9 /* RegularExpressionFlagsHasIndices */],
8048
8049
  [16 /* DotAll */, 5 /* RegularExpressionFlagsDotAll */],
@@ -8098,9 +8099,9 @@ function tokenToString(t) {
8098
8099
  function stringToToken(s) {
8099
8100
  return textToToken.get(s);
8100
8101
  }
8101
- var regExpFlagChars = makeReverseMap(charToRegExpFlag);
8102
- function characterToRegularExpressionFlag(c) {
8103
- return charToRegExpFlag.get(c);
8102
+ var regExpFlagCharCodes = makeReverseMap(charCodeToRegExpFlag);
8103
+ function characterCodeToRegularExpressionFlag(ch) {
8104
+ return charCodeToRegExpFlag.get(ch);
8104
8105
  }
8105
8106
  function computeLineStarts(text) {
8106
8107
  const result = [];
@@ -9795,24 +9796,25 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9795
9796
  pos++;
9796
9797
  let regExpFlags = 0 /* None */;
9797
9798
  while (true) {
9798
- const ch = charCodeChecked(pos);
9799
+ const ch = codePointChecked(pos);
9799
9800
  if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
9800
9801
  break;
9801
9802
  }
9803
+ const size = charSize(ch);
9802
9804
  if (reportErrors2) {
9803
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
9805
+ const flag = characterCodeToRegularExpressionFlag(ch);
9804
9806
  if (flag === void 0) {
9805
- error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
9807
+ error(Diagnostics.Unknown_regular_expression_flag, pos, size);
9806
9808
  } else if (regExpFlags & flag) {
9807
- error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
9809
+ error(Diagnostics.Duplicate_regular_expression_flag, pos, size);
9808
9810
  } else if (((regExpFlags | flag) & 96 /* AnyUnicodeMode */) === 96 /* AnyUnicodeMode */) {
9809
- error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, 1);
9811
+ error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, size);
9810
9812
  } else {
9811
9813
  regExpFlags |= flag;
9812
- checkRegularExpressionFlagAvailable(flag, pos);
9814
+ checkRegularExpressionFlagAvailability(flag, size);
9813
9815
  }
9814
9816
  }
9815
- pos++;
9817
+ pos += size;
9816
9818
  }
9817
9819
  if (reportErrors2) {
9818
9820
  scanRange(startOfRegExpBody, endOfRegExpBody - startOfRegExpBody, () => {
@@ -10027,22 +10029,23 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10027
10029
  }
10028
10030
  function scanPatternModifiers(currFlags) {
10029
10031
  while (true) {
10030
- const ch = charCodeChecked(pos);
10032
+ const ch = codePointChecked(pos);
10031
10033
  if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
10032
10034
  break;
10033
10035
  }
10034
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
10036
+ const size = charSize(ch);
10037
+ const flag = characterCodeToRegularExpressionFlag(ch);
10035
10038
  if (flag === void 0) {
10036
- error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
10039
+ error(Diagnostics.Unknown_regular_expression_flag, pos, size);
10037
10040
  } else if (currFlags & flag) {
10038
- error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
10041
+ error(Diagnostics.Duplicate_regular_expression_flag, pos, size);
10039
10042
  } else if (!(flag & 28 /* Modifiers */)) {
10040
- error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
10043
+ error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, size);
10041
10044
  } else {
10042
10045
  currFlags |= flag;
10043
- checkRegularExpressionFlagAvailable(flag, pos);
10046
+ checkRegularExpressionFlagAvailability(flag, size);
10044
10047
  }
10045
- pos++;
10048
+ pos += size;
10046
10049
  }
10047
10050
  return currFlags;
10048
10051
  }
@@ -10646,6 +10649,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10646
10649
  forEach(groupNameReferences, (reference) => {
10647
10650
  if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
10648
10651
  error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
10652
+ if (groupSpecifiers) {
10653
+ const suggestion = getSpellingSuggestion(reference.name, groupSpecifiers, identity);
10654
+ if (suggestion) {
10655
+ error(Diagnostics.Did_you_mean_0, reference.pos, reference.end - reference.pos, suggestion);
10656
+ }
10657
+ }
10649
10658
  }
10650
10659
  });
10651
10660
  forEach(decimalEscapes, (escape) => {
@@ -10658,10 +10667,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10658
10667
  }
10659
10668
  });
10660
10669
  }
10661
- function checkRegularExpressionFlagAvailable(flag, pos2) {
10670
+ function checkRegularExpressionFlagAvailability(flag, size) {
10662
10671
  const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10663
10672
  if (availableFrom && languageVersion < availableFrom) {
10664
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
10673
+ error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, getNameOfScriptTarget(availableFrom));
10665
10674
  }
10666
10675
  }
10667
10676
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
@@ -12777,7 +12786,16 @@ function isJSDocTypeExpressionOrChild(node) {
12777
12786
  return !!findAncestor(node, isJSDocTypeExpression);
12778
12787
  }
12779
12788
  function isExportNamespaceAsDefaultDeclaration(node) {
12780
- return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default");
12789
+ return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && moduleExportNameIsDefault(node.exportClause.name));
12790
+ }
12791
+ function moduleExportNameTextUnescaped(node) {
12792
+ return node.kind === 11 /* StringLiteral */ ? node.text : unescapeLeadingUnderscores(node.escapedText);
12793
+ }
12794
+ function moduleExportNameTextEscaped(node) {
12795
+ return node.kind === 11 /* StringLiteral */ ? escapeLeadingUnderscores(node.text) : node.escapedText;
12796
+ }
12797
+ function moduleExportNameIsDefault(node) {
12798
+ return (node.kind === 11 /* StringLiteral */ ? node.text : node.escapedText) === "default" /* Default */;
12781
12799
  }
12782
12800
  function getTextOfNodeFromSourceText(sourceText, node, includeTrivia = false) {
12783
12801
  if (nodeIsMissing(node)) {
@@ -19171,7 +19189,7 @@ function createNameResolver({
19171
19189
  }
19172
19190
  break;
19173
19191
  }
19174
- if (isSelfReferenceLocation(location)) {
19192
+ if (isSelfReferenceLocation(location, lastLocation)) {
19175
19193
  lastSelfReferenceLocation = location;
19176
19194
  }
19177
19195
  lastLocation = location;
@@ -19272,8 +19290,10 @@ function createNameResolver({
19272
19290
  }
19273
19291
  return !getImmediatelyInvokedFunctionExpression(location);
19274
19292
  }
19275
- function isSelfReferenceLocation(node) {
19293
+ function isSelfReferenceLocation(node, lastLocation) {
19276
19294
  switch (node.kind) {
19295
+ case 169 /* Parameter */:
19296
+ return !!lastLocation && lastLocation === node.name;
19277
19297
  case 262 /* FunctionDeclaration */:
19278
19298
  case 263 /* ClassDeclaration */:
19279
19299
  case 264 /* InterfaceDeclaration */:
@@ -19329,12 +19349,6 @@ function unwrapParenthesizedExpression(o) {
19329
19349
  }
19330
19350
  return o;
19331
19351
  }
19332
- function unwrapParenthesizedType(o) {
19333
- while (o.kind === 196 /* ParenthesizedType */) {
19334
- o = o.type;
19335
- }
19336
- return o;
19337
- }
19338
19352
  function hasInferredType(node) {
19339
19353
  Debug.type(node);
19340
19354
  switch (node.kind) {
@@ -26051,6 +26065,9 @@ function isNamedExports(node) {
26051
26065
  function isExportSpecifier(node) {
26052
26066
  return node.kind === 281 /* ExportSpecifier */;
26053
26067
  }
26068
+ function isModuleExportName(node) {
26069
+ return node.kind === 80 /* Identifier */ || node.kind === 11 /* StringLiteral */;
26070
+ }
26054
26071
  function isNotEmittedStatement(node) {
26055
26072
  return node.kind === 353 /* NotEmittedStatement */;
26056
26073
  }
@@ -26749,6 +26766,9 @@ function getLocalNameForExternalImport(factory2, node, sourceFile) {
26749
26766
  const namespaceDeclaration = getNamespaceDeclarationNode(node);
26750
26767
  if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) {
26751
26768
  const name = namespaceDeclaration.name;
26769
+ if (name.kind === 11 /* StringLiteral */) {
26770
+ return factory2.getGeneratedNameForNode(node);
26771
+ }
26752
26772
  return isGeneratedIdentifier(name) ? name : factory2.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name));
26753
26773
  }
26754
26774
  if (node.kind === 272 /* ImportDeclaration */ && node.importClause) {
@@ -29084,6 +29104,9 @@ var Parser;
29084
29104
  if (token() === 161 /* FromKeyword */ && lookAhead(nextTokenIsStringLiteral)) {
29085
29105
  return false;
29086
29106
  }
29107
+ if (token() === 11 /* StringLiteral */) {
29108
+ return true;
29109
+ }
29087
29110
  return tokenIsIdentifierOrKeyword(token());
29088
29111
  case 13 /* JsxAttributes */:
29089
29112
  return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
@@ -33532,6 +33555,12 @@ var Parser;
33532
33555
  const name = parseIdentifier();
33533
33556
  return finishNode(factory2.createNamespaceImport(name), pos);
33534
33557
  }
33558
+ function canParseModuleExportName() {
33559
+ return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
33560
+ }
33561
+ function parseModuleExportName(parseName) {
33562
+ return token() === 11 /* StringLiteral */ ? parseLiteralNode() : parseName();
33563
+ }
33535
33564
  function parseNamedImportsOrExports(kind) {
33536
33565
  const pos = getNodePos();
33537
33566
  const node = kind === 275 /* NamedImports */ ? factory2.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 19 /* OpenBraceToken */, 20 /* CloseBraceToken */)) : factory2.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 19 /* OpenBraceToken */, 20 /* CloseBraceToken */));
@@ -33552,42 +33581,51 @@ var Parser;
33552
33581
  let isTypeOnly = false;
33553
33582
  let propertyName;
33554
33583
  let canParseAsKeyword = true;
33555
- let name = parseIdentifierName();
33556
- if (name.escapedText === "type") {
33584
+ let name = parseModuleExportName(parseIdentifierName);
33585
+ if (name.kind === 80 /* Identifier */ && name.escapedText === "type") {
33557
33586
  if (token() === 130 /* AsKeyword */) {
33558
33587
  const firstAs = parseIdentifierName();
33559
33588
  if (token() === 130 /* AsKeyword */) {
33560
33589
  const secondAs = parseIdentifierName();
33561
- if (tokenIsIdentifierOrKeyword(token())) {
33590
+ if (canParseModuleExportName()) {
33562
33591
  isTypeOnly = true;
33563
33592
  propertyName = firstAs;
33564
- name = parseNameWithKeywordCheck();
33593
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33565
33594
  canParseAsKeyword = false;
33566
33595
  } else {
33567
33596
  propertyName = name;
33568
33597
  name = secondAs;
33569
33598
  canParseAsKeyword = false;
33570
33599
  }
33571
- } else if (tokenIsIdentifierOrKeyword(token())) {
33600
+ } else if (canParseModuleExportName()) {
33572
33601
  propertyName = name;
33573
33602
  canParseAsKeyword = false;
33574
- name = parseNameWithKeywordCheck();
33603
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33575
33604
  } else {
33576
33605
  isTypeOnly = true;
33577
33606
  name = firstAs;
33578
33607
  }
33579
- } else if (tokenIsIdentifierOrKeyword(token())) {
33608
+ } else if (canParseModuleExportName()) {
33580
33609
  isTypeOnly = true;
33581
- name = parseNameWithKeywordCheck();
33610
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33582
33611
  }
33583
33612
  }
33584
33613
  if (canParseAsKeyword && token() === 130 /* AsKeyword */) {
33585
33614
  propertyName = name;
33586
33615
  parseExpected(130 /* AsKeyword */);
33587
- name = parseNameWithKeywordCheck();
33616
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33588
33617
  }
33589
- if (kind === 276 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
33590
- parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
33618
+ if (kind === 276 /* ImportSpecifier */) {
33619
+ if (name.kind !== 80 /* Identifier */) {
33620
+ parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected);
33621
+ name = setTextRangePosEnd(createMissingNode(
33622
+ 80 /* Identifier */,
33623
+ /*reportAtCurrentPosition*/
33624
+ false
33625
+ ), name.pos, name.pos);
33626
+ } else if (checkIdentifierIsKeyword) {
33627
+ parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
33628
+ }
33591
33629
  }
33592
33630
  const node = kind === 276 /* ImportSpecifier */ ? factory2.createImportSpecifier(isTypeOnly, propertyName, name) : factory2.createExportSpecifier(isTypeOnly, propertyName, name);
33593
33631
  return finishNode(node, pos);
@@ -33599,7 +33637,7 @@ var Parser;
33599
33637
  }
33600
33638
  }
33601
33639
  function parseNamespaceExport(pos) {
33602
- return finishNode(factory2.createNamespaceExport(parseIdentifierName()), pos);
33640
+ return finishNode(factory2.createNamespaceExport(parseModuleExportName(parseIdentifierName)), pos);
33603
33641
  }
33604
33642
  function parseExportDeclaration(pos, hasJSDoc, modifiers) {
33605
33643
  const savedAwaitContext = inAwaitContext();
@@ -41123,6 +41161,9 @@ function getModuleInstanceStateWorker(node, visited) {
41123
41161
  }
41124
41162
  function getModuleInstanceStateForAliasTarget(specifier, visited) {
41125
41163
  const name = specifier.propertyName || specifier.name;
41164
+ if (name.kind !== 80 /* Identifier */) {
41165
+ return 1 /* Instantiated */;
41166
+ }
41126
41167
  let p = specifier.parent;
41127
41168
  while (p) {
41128
41169
  if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) {
@@ -41367,7 +41408,7 @@ function createBinder() {
41367
41408
  }
41368
41409
  function declareSymbol(symbolTable, parent2, node, includes, excludes, isReplaceableByMethod, isComputedName) {
41369
41410
  Debug.assert(isComputedName || !hasDynamicName(node));
41370
- const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default";
41411
+ const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && moduleExportNameIsDefault(node.name);
41371
41412
  const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent2 ? "default" /* Default */ : getDeclarationName(node);
41372
41413
  let symbol;
41373
41414
  if (name === void 0) {
@@ -45155,7 +45196,8 @@ function createTypeChecker(host) {
45155
45196
  isUndefinedIdentifierExpression(node) {
45156
45197
  Debug.assert(isExpressionNode(node));
45157
45198
  return getSymbolAtLocation(node) === undefinedSymbol;
45158
- }
45199
+ },
45200
+ isDefinitelyReferenceToGlobalSymbolObject
45159
45201
  });
45160
45202
  var evaluate = createEvaluator({
45161
45203
  evaluateElementAccessExpression,
@@ -46112,6 +46154,21 @@ function createTypeChecker(host) {
46112
46154
  ];
46113
46155
  initializeTypeChecker();
46114
46156
  return checker;
46157
+ function isDefinitelyReferenceToGlobalSymbolObject(node) {
46158
+ if (!isPropertyAccessExpression(node)) return false;
46159
+ if (!isIdentifier(node.name)) return false;
46160
+ if (!isPropertyAccessExpression(node.expression) && !isIdentifier(node.expression)) return false;
46161
+ if (isIdentifier(node.expression)) {
46162
+ return idText(node.expression) === "Symbol" && getResolvedSymbol(node.expression) === (getGlobalSymbol(
46163
+ "Symbol",
46164
+ 111551 /* Value */ | 1048576 /* ExportValue */,
46165
+ /*diagnostic*/
46166
+ void 0
46167
+ ) || unknownSymbol);
46168
+ }
46169
+ if (!isIdentifier(node.expression.expression)) return false;
46170
+ return idText(node.expression.name) === "Symbol" && idText(node.expression.expression) === "globalThis" && getResolvedSymbol(node.expression.expression) === globalThisSymbol;
46171
+ }
46115
46172
  function getCachedType(key) {
46116
46173
  return key ? cachedTypes.get(key) : void 0;
46117
46174
  }
@@ -47140,7 +47197,7 @@ function createTypeChecker(host) {
47140
47197
  const isExport = typeOnlyDeclaration.kind === 281 /* ExportSpecifier */ || typeOnlyDeclaration.kind === 278 /* ExportDeclaration */;
47141
47198
  const message = isExport ? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
47142
47199
  const relatedMessage = isExport ? Diagnostics._0_was_exported_here : Diagnostics._0_was_imported_here;
47143
- const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
47200
+ const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : moduleExportNameTextUnescaped(typeOnlyDeclaration.name);
47144
47201
  addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
47145
47202
  }
47146
47203
  }
@@ -47384,12 +47441,12 @@ function createTypeChecker(host) {
47384
47441
  if (valueSymbol.exports) result.exports = new Map(valueSymbol.exports);
47385
47442
  return result;
47386
47443
  }
47387
- function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
47444
+ function getExportOfModule(symbol, nameText, specifier, dontResolveAlias) {
47388
47445
  var _a;
47389
47446
  if (symbol.flags & 1536 /* Module */) {
47390
- const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
47447
+ const exportSymbol = getExportsOfSymbol(symbol).get(nameText);
47391
47448
  const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
47392
- const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(name.escapedText);
47449
+ const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(nameText);
47393
47450
  markSymbolOfAliasDeclarationIfTypeOnly(
47394
47451
  specifier,
47395
47452
  exportSymbol,
@@ -47397,7 +47454,7 @@ function createTypeChecker(host) {
47397
47454
  /*overwriteEmpty*/
47398
47455
  false,
47399
47456
  exportStarDeclaration,
47400
- name.escapedText
47457
+ nameText
47401
47458
  );
47402
47459
  return resolved;
47403
47460
  }
@@ -47415,10 +47472,11 @@ function createTypeChecker(host) {
47415
47472
  const moduleSpecifier = getExternalModuleRequireArgument(node) || node.moduleSpecifier;
47416
47473
  const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
47417
47474
  const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
47418
- if (!isIdentifier(name)) {
47475
+ if (!isIdentifier(name) && name.kind !== 11 /* StringLiteral */) {
47419
47476
  return void 0;
47420
47477
  }
47421
- const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
47478
+ const nameText = moduleExportNameTextEscaped(name);
47479
+ const suppressInteropError = nameText === "default" /* Default */ && allowSyntheticDefaultImports;
47422
47480
  const targetSymbol = resolveESModuleSymbol(
47423
47481
  moduleSymbol,
47424
47482
  moduleSpecifier,
@@ -47427,7 +47485,7 @@ function createTypeChecker(host) {
47427
47485
  suppressInteropError
47428
47486
  );
47429
47487
  if (targetSymbol) {
47430
- if (name.escapedText) {
47488
+ if (nameText || name.kind === 11 /* StringLiteral */) {
47431
47489
  if (isShorthandAmbientModuleSymbol(moduleSymbol)) {
47432
47490
  return moduleSymbol;
47433
47491
  }
@@ -47435,16 +47493,16 @@ function createTypeChecker(host) {
47435
47493
  if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) {
47436
47494
  symbolFromVariable = getPropertyOfType(
47437
47495
  getTypeOfSymbol(targetSymbol),
47438
- name.escapedText,
47496
+ nameText,
47439
47497
  /*skipObjectFunctionPropertyAugment*/
47440
47498
  true
47441
47499
  );
47442
47500
  } else {
47443
- symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
47501
+ symbolFromVariable = getPropertyOfVariable(targetSymbol, nameText);
47444
47502
  }
47445
47503
  symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
47446
- let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
47447
- if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
47504
+ let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
47505
+ if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
47448
47506
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
47449
47507
  if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47450
47508
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
@@ -47462,7 +47520,7 @@ function createTypeChecker(host) {
47462
47520
  var _a;
47463
47521
  const moduleName = getFullyQualifiedName(moduleSymbol, node);
47464
47522
  const declarationName = declarationNameToString(name);
47465
- const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
47523
+ const suggestion = isIdentifier(name) ? getSuggestedSymbolForNonexistentModule(name, targetSymbol) : void 0;
47466
47524
  if (suggestion !== void 0) {
47467
47525
  const suggestionName = symbolToString(suggestion);
47468
47526
  const diagnostic = error(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
@@ -47484,7 +47542,7 @@ function createTypeChecker(host) {
47484
47542
  }
47485
47543
  function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
47486
47544
  var _a, _b;
47487
- const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(name.escapedText);
47545
+ const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(moduleExportNameTextEscaped(name));
47488
47546
  const exports2 = moduleSymbol.exports;
47489
47547
  if (localSymbol) {
47490
47548
  const exportedEqualsSymbol = exports2 == null ? void 0 : exports2.get("export=" /* ExportEquals */);
@@ -47516,7 +47574,7 @@ function createTypeChecker(host) {
47516
47574
  }
47517
47575
  }
47518
47576
  function getTargetOfImportSpecifier(node, dontResolveAlias) {
47519
- if (isImportSpecifier(node) && idText(node.propertyName || node.name) === "default" /* Default */) {
47577
+ if (isImportSpecifier(node) && moduleExportNameIsDefault(node.propertyName || node.name)) {
47520
47578
  const specifier = getModuleSpecifierForImportOrExport(node);
47521
47579
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47522
47580
  if (moduleSymbol) {
@@ -47560,19 +47618,23 @@ function createTypeChecker(host) {
47560
47618
  }
47561
47619
  }
47562
47620
  function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
47563
- if (idText(node.propertyName || node.name) === "default" /* Default */) {
47621
+ const name = node.propertyName || node.name;
47622
+ if (moduleExportNameIsDefault(name)) {
47564
47623
  const specifier = getModuleSpecifierForImportOrExport(node);
47565
47624
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47566
47625
  if (moduleSymbol) {
47567
47626
  return getTargetofModuleDefault(moduleSymbol, node, !!dontResolveAlias);
47568
47627
  }
47569
47628
  }
47570
- const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : resolveEntityName(
47571
- node.propertyName || node.name,
47572
- meaning,
47573
- /*ignoreErrors*/
47574
- false,
47575
- dontResolveAlias
47629
+ const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : name.kind === 11 /* StringLiteral */ ? void 0 : (
47630
+ // Skip for invalid syntax like this: export { "x" }
47631
+ resolveEntityName(
47632
+ name,
47633
+ meaning,
47634
+ /*ignoreErrors*/
47635
+ false,
47636
+ dontResolveAlias
47637
+ )
47576
47638
  );
47577
47639
  markSymbolOfAliasDeclarationIfTypeOnly(
47578
47640
  node,
@@ -51622,7 +51684,7 @@ function createTypeChecker(host) {
51622
51684
  return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51623
51685
  }
51624
51686
  function tryVisitSimpleTypeNode(node) {
51625
- const innerNode = unwrapParenthesizedType(node);
51687
+ const innerNode = skipTypeParentheses(node);
51626
51688
  switch (innerNode.kind) {
51627
51689
  case 183 /* TypeReference */:
51628
51690
  return tryVisitTypeReference(innerNode);
@@ -52169,9 +52231,10 @@ function createTypeChecker(host) {
52169
52231
  if (index >= 0) {
52170
52232
  const exportDecl = statements[index];
52171
52233
  const replacements = mapDefined(exportDecl.exportClause.elements, (e) => {
52172
- if (!e.propertyName) {
52234
+ if (!e.propertyName && e.name.kind !== 11 /* StringLiteral */) {
52235
+ const name = e.name;
52173
52236
  const indices = indicesOf(statements);
52174
- const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], e.name));
52237
+ const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], name));
52175
52238
  if (length(associatedIndices) && every(associatedIndices, (i) => canHaveExportModifier(statements[i]))) {
52176
52239
  for (const index2 of associatedIndices) {
52177
52240
  statements[index2] = addExportModifier(statements[index2]);
@@ -52805,7 +52868,7 @@ function createTypeChecker(host) {
52805
52868
  function getSomeTargetNameFromDeclarations(declarations) {
52806
52869
  return firstDefined(declarations, (d) => {
52807
52870
  if (isImportSpecifier(d) || isExportSpecifier(d)) {
52808
- return idText(d.propertyName || d.name);
52871
+ return moduleExportNameTextUnescaped(d.propertyName || d.name);
52809
52872
  }
52810
52873
  if (isBinaryExpression(d) || isExportAssignment(d)) {
52811
52874
  const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -52823,7 +52886,7 @@ function createTypeChecker(host) {
52823
52886
  });
52824
52887
  }
52825
52888
  function serializeAsAlias(symbol, localName, modifierFlags) {
52826
- var _a2, _b, _c, _d, _e, _f;
52889
+ var _a2, _b, _c, _d, _e;
52827
52890
  const node = getDeclarationOfAliasSymbol(symbol);
52828
52891
  if (!node) return Debug.fail();
52829
52892
  const target = getMergedSymbol(getTargetOfAliasDeclaration(
@@ -53021,8 +53084,11 @@ function createTypeChecker(host) {
53021
53084
  }
53022
53085
  case 281 /* ExportSpecifier */:
53023
53086
  const specifier = node.parent.parent.moduleSpecifier;
53024
- if (specifier && ((_f = node.propertyName) == null ? void 0 : _f.escapedText) === "default" /* Default */) {
53025
- verbatimTargetName = "default" /* Default */;
53087
+ if (specifier) {
53088
+ const propertyName = node.propertyName;
53089
+ if (propertyName && moduleExportNameIsDefault(propertyName)) {
53090
+ verbatimTargetName = "default" /* Default */;
53091
+ }
53026
53092
  }
53027
53093
  serializeExportSpecifier(
53028
53094
  unescapeLeadingUnderscores(symbol.escapedName),
@@ -53735,7 +53801,7 @@ function createTypeChecker(host) {
53735
53801
  }
53736
53802
  function collectLinkedAliases(node, setVisibility) {
53737
53803
  let exportSymbol;
53738
- if (node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53804
+ if (node.kind !== 11 /* StringLiteral */ && node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53739
53805
  exportSymbol = resolveName(
53740
53806
  node,
53741
53807
  node,
@@ -69308,9 +69374,10 @@ function createTypeChecker(host) {
69308
69374
  return;
69309
69375
  case 281 /* ExportSpecifier */:
69310
69376
  const exportDeclaration = node.parent.parent;
69311
- if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
69377
+ const name = node.propertyName || node.name;
69378
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier && name.kind !== 11 /* StringLiteral */) {
69312
69379
  const symbol = resolveEntityName(
69313
- node.propertyName || node.name,
69380
+ name,
69314
69381
  111551 /* Value */,
69315
69382
  /*ignoreErrors*/
69316
69383
  true,
@@ -69604,6 +69671,9 @@ function createTypeChecker(host) {
69604
69671
  function markExportSpecifierAliasReferenced(location) {
69605
69672
  if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) {
69606
69673
  const exportedName = location.propertyName || location.name;
69674
+ if (exportedName.kind === 11 /* StringLiteral */) {
69675
+ return;
69676
+ }
69607
69677
  const symbol = resolveName(
69608
69678
  exportedName,
69609
69679
  exportedName.escapedText,
@@ -69618,7 +69688,7 @@ function createTypeChecker(host) {
69618
69688
  const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
69619
69689
  if (!target || getSymbolFlags(target) & 111551 /* Value */) {
69620
69690
  markExportAsReferenced(location);
69621
- markIdentifierAliasReferenced(location.propertyName || location.name);
69691
+ markIdentifierAliasReferenced(exportedName);
69622
69692
  }
69623
69693
  }
69624
69694
  return;
@@ -83214,6 +83284,16 @@ function createTypeChecker(host) {
83214
83284
  }
83215
83285
  return true;
83216
83286
  }
83287
+ function checkModuleExportName(name, allowStringLiteral = true) {
83288
+ if (name === void 0 || name.kind !== 11 /* StringLiteral */) {
83289
+ return;
83290
+ }
83291
+ if (!allowStringLiteral) {
83292
+ grammarErrorOnNode(name, Diagnostics.Identifier_expected);
83293
+ } else if (moduleKind === 5 /* ES2015 */ || moduleKind === 6 /* ES2020 */) {
83294
+ grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020);
83295
+ }
83296
+ }
83217
83297
  function checkAliasSymbol(node) {
83218
83298
  var _a, _b, _c, _d;
83219
83299
  let symbol = getSymbolOfDeclaration(node);
@@ -83225,7 +83305,7 @@ function createTypeChecker(host) {
83225
83305
  Debug.assert(node.kind !== 280 /* NamespaceExport */);
83226
83306
  if (node.kind === 281 /* ExportSpecifier */) {
83227
83307
  const diag2 = error(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
83228
- const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get((node.propertyName || node.name).escapedText);
83308
+ const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get(moduleExportNameTextEscaped(node.propertyName || node.name));
83229
83309
  if (alreadyExportedSymbol === target) {
83230
83310
  const exportingDeclaration = (_c = alreadyExportedSymbol.declarations) == null ? void 0 : _c.find(isJSDocNode);
83231
83311
  if (exportingDeclaration) {
@@ -83280,7 +83360,7 @@ function createTypeChecker(host) {
83280
83360
  if (compilerOptions.verbatimModuleSyntax) {
83281
83361
  Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name");
83282
83362
  const message = compilerOptions.verbatimModuleSyntax && isInternalModuleImportEqualsDeclaration(node) ? Diagnostics.An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled : isType ? Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled;
83283
- const name = idText(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83363
+ const name = moduleExportNameTextUnescaped(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83284
83364
  addTypeOnlyDeclarationRelatedInfo(
83285
83365
  error(node, message, name),
83286
83366
  isType ? void 0 : typeOnlyAlias,
@@ -83294,7 +83374,7 @@ function createTypeChecker(host) {
83294
83374
  }
83295
83375
  case 281 /* ExportSpecifier */: {
83296
83376
  if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) {
83297
- const name = idText(node.propertyName || node.name);
83377
+ const name = moduleExportNameTextUnescaped(node.propertyName || node.name);
83298
83378
  const diagnostic = isType ? error(node, Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type, isolatedModulesLikeFlagName) : error(node, Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_1_is_enabled, name, isolatedModulesLikeFlagName);
83299
83379
  addTypeOnlyDeclarationRelatedInfo(diagnostic, isType ? void 0 : typeOnlyAlias, name);
83300
83380
  break;
@@ -83344,8 +83424,11 @@ function createTypeChecker(host) {
83344
83424
  function checkImportBinding(node) {
83345
83425
  checkCollisionsForDeclarationName(node, node.name);
83346
83426
  checkAliasSymbol(node);
83347
- if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83348
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83427
+ if (node.kind === 276 /* ImportSpecifier */) {
83428
+ checkModuleExportName(node.propertyName);
83429
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83430
+ checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83431
+ }
83349
83432
  }
83350
83433
  }
83351
83434
  function checkImportAttributes(declaration) {
@@ -83466,6 +83549,7 @@ function createTypeChecker(host) {
83466
83549
  error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
83467
83550
  } else if (node.exportClause) {
83468
83551
  checkAliasSymbol(node.exportClause);
83552
+ checkModuleExportName(node.exportClause.name);
83469
83553
  }
83470
83554
  if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83471
83555
  if (node.exportClause) {
@@ -83496,6 +83580,9 @@ function createTypeChecker(host) {
83496
83580
  }
83497
83581
  function checkExportSpecifier(node) {
83498
83582
  checkAliasSymbol(node);
83583
+ const hasModuleSpecifier = node.parent.parent.moduleSpecifier !== void 0;
83584
+ checkModuleExportName(node.propertyName, hasModuleSpecifier);
83585
+ checkModuleExportName(node.name);
83499
83586
  if (getEmitDeclarations(compilerOptions)) {
83500
83587
  collectLinkedAliases(
83501
83588
  node.propertyName || node.name,
@@ -83503,8 +83590,11 @@ function createTypeChecker(host) {
83503
83590
  true
83504
83591
  );
83505
83592
  }
83506
- if (!node.parent.parent.moduleSpecifier) {
83593
+ if (!hasModuleSpecifier) {
83507
83594
  const exportedName = node.propertyName || node.name;
83595
+ if (exportedName.kind === 11 /* StringLiteral */) {
83596
+ return;
83597
+ }
83508
83598
  const symbol = resolveName(
83509
83599
  exportedName,
83510
83600
  exportedName.escapedText,
@@ -83520,7 +83610,7 @@ function createTypeChecker(host) {
83520
83610
  markLinkedReferences(node, 7 /* ExportSpecifier */);
83521
83611
  }
83522
83612
  } else {
83523
- if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
83613
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
83524
83614
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83525
83615
  }
83526
83616
  }
@@ -84675,7 +84765,11 @@ function createTypeChecker(host) {
84675
84765
  }
84676
84766
  function getExportSpecifierLocalTargetSymbol(node) {
84677
84767
  if (isExportSpecifier(node)) {
84678
- return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84768
+ const name = node.propertyName || node.name;
84769
+ return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : name.kind === 11 /* StringLiteral */ ? void 0 : (
84770
+ // Skip for invalid syntax like this: export { "x" }
84771
+ resolveEntityName(name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)
84772
+ );
84679
84773
  } else {
84680
84774
  return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84681
84775
  }
@@ -85646,7 +85740,8 @@ function createTypeChecker(host) {
85646
85740
  resolveExternalModuleSymbol(sym);
85647
85741
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
85648
85742
  },
85649
- isImportRequiredByAugmentation
85743
+ isImportRequiredByAugmentation,
85744
+ isDefinitelyReferenceToGlobalSymbolObject
85650
85745
  };
85651
85746
  function isImportRequiredByAugmentation(node) {
85652
85747
  const file = getSourceFileOfNode(node);
@@ -87485,7 +87580,7 @@ function isDeclarationNameOrImportPropertyName(name) {
87485
87580
  switch (name.parent.kind) {
87486
87581
  case 276 /* ImportSpecifier */:
87487
87582
  case 281 /* ExportSpecifier */:
87488
- return isIdentifier(name);
87583
+ return isIdentifier(name) || name.kind === 11 /* StringLiteral */;
87489
87584
  default:
87490
87585
  return isDeclarationName(name);
87491
87586
  }
@@ -88730,7 +88825,7 @@ var visitEachChildTable = {
88730
88825
  return context.factory.updateImportSpecifier(
88731
88826
  node,
88732
88827
  node.isTypeOnly,
88733
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88828
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88734
88829
  Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88735
88830
  );
88736
88831
  },
@@ -88761,8 +88856,8 @@ var visitEachChildTable = {
88761
88856
  return context.factory.updateExportSpecifier(
88762
88857
  node,
88763
88858
  node.isTypeOnly,
88764
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88765
- Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88859
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88860
+ Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName))
88766
88861
  );
88767
88862
  },
88768
88863
  // Module references
@@ -89306,7 +89401,7 @@ function containsDefaultReference(node) {
89306
89401
  return some(node.elements, isNamedDefaultReference);
89307
89402
  }
89308
89403
  function isNamedDefaultReference(e) {
89309
- return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
89404
+ return moduleExportNameIsDefault(e.propertyName || e.name);
89310
89405
  }
89311
89406
  function chainBundle(context, transformSourceFile) {
89312
89407
  return transformSourceFileOrBundle;
@@ -89382,9 +89477,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89382
89477
  hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
89383
89478
  } else {
89384
89479
  const name = node.exportClause.name;
89385
- if (!uniqueExports.get(idText(name))) {
89480
+ const nameText = moduleExportNameTextUnescaped(name);
89481
+ if (!uniqueExports.get(nameText)) {
89386
89482
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89387
- uniqueExports.set(idText(name), true);
89483
+ uniqueExports.set(nameText, true);
89388
89484
  exportedNames = append(exportedNames, name);
89389
89485
  }
89390
89486
  hasImportStar = true;
@@ -89442,20 +89538,23 @@ function collectExternalModuleInfo(context, sourceFile) {
89442
89538
  return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, exportedFunctions, externalHelpersImportDeclaration };
89443
89539
  function addExportedNamesForExportDeclaration(node) {
89444
89540
  for (const specifier of cast(node.exportClause, isNamedExports).elements) {
89445
- if (!uniqueExports.get(idText(specifier.name))) {
89541
+ const specifierNameText = moduleExportNameTextUnescaped(specifier.name);
89542
+ if (!uniqueExports.get(specifierNameText)) {
89446
89543
  const name = specifier.propertyName || specifier.name;
89447
- if (!node.moduleSpecifier) {
89448
- exportSpecifiers.add(name, specifier);
89449
- }
89450
- const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89451
- if (decl) {
89452
- if (decl.kind === 262 /* FunctionDeclaration */) {
89453
- addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
89454
- continue;
89544
+ if (name.kind !== 11 /* StringLiteral */) {
89545
+ if (!node.moduleSpecifier) {
89546
+ exportSpecifiers.add(name, specifier);
89547
+ }
89548
+ const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89549
+ if (decl) {
89550
+ if (decl.kind === 262 /* FunctionDeclaration */) {
89551
+ addExportedFunctionDeclaration(decl, specifier.name, moduleExportNameIsDefault(specifier.name));
89552
+ continue;
89553
+ }
89554
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89455
89555
  }
89456
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89457
89556
  }
89458
- uniqueExports.set(idText(specifier.name), true);
89557
+ uniqueExports.set(specifierNameText, true);
89459
89558
  exportedNames = append(exportedNames, specifier.name);
89460
89559
  }
89461
89560
  }
@@ -89469,9 +89568,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89469
89568
  }
89470
89569
  } else {
89471
89570
  name ?? (name = node.name);
89472
- if (!uniqueExports.get(idText(name))) {
89571
+ const nameText = moduleExportNameTextUnescaped(name);
89572
+ if (!uniqueExports.get(nameText)) {
89473
89573
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89474
- uniqueExports.set(idText(name), true);
89574
+ uniqueExports.set(nameText, true);
89475
89575
  }
89476
89576
  }
89477
89577
  }
@@ -106748,7 +106848,7 @@ function transformModule(context) {
106748
106848
  factory2.createExpressionStatement(
106749
106849
  reduceLeft(
106750
106850
  currentModuleInfo.exportedNames.slice(i, i + chunkSize),
106751
- (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev),
106851
+ (prev, nextId) => nextId.kind === 11 /* StringLiteral */ ? factory2.createAssignment(factory2.createElementAccessExpression(factory2.createIdentifier("exports"), factory2.createStringLiteral(nextId.text)), prev) : factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev),
106752
106852
  factory2.createVoidZero()
106753
106853
  )
106754
106854
  )
@@ -107071,7 +107171,10 @@ function transformModule(context) {
107071
107171
  append(statements, createUnderscoreUnderscoreESModule());
107072
107172
  }
107073
107173
  if (some(currentModuleInfo.exportedNames)) {
107074
- append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
107174
+ append(
107175
+ statements,
107176
+ factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => nextId.kind === 11 /* StringLiteral */ ? factory2.createAssignment(factory2.createElementAccessExpression(factory2.createIdentifier("exports"), factory2.createStringLiteral(nextId.text)), prev) : factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero()))
107177
+ );
107075
107178
  }
107076
107179
  for (const f of currentModuleInfo.exportedFunctions) {
107077
107180
  appendExportsOfHoistedDeclaration(statements, f);
@@ -107942,17 +108045,16 @@ function transformModule(context) {
107942
108045
  );
107943
108046
  }
107944
108047
  for (const specifier of node.exportClause.elements) {
107945
- const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && idText(specifier.propertyName || specifier.name) === "default";
107946
- const exportedValue = factory2.createPropertyAccessExpression(
107947
- exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName,
107948
- specifier.propertyName || specifier.name
107949
- );
108048
+ const specifierName = specifier.propertyName || specifier.name;
108049
+ const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && moduleExportNameIsDefault(specifierName);
108050
+ const target = exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName;
108051
+ const exportedValue = specifierName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, specifierName) : factory2.createPropertyAccessExpression(target, specifierName);
107950
108052
  statements.push(
107951
108053
  setOriginalNode(
107952
108054
  setTextRange(
107953
108055
  factory2.createExpressionStatement(
107954
108056
  createExportExpression(
107955
- factory2.getExportName(specifier),
108057
+ specifier.name.kind === 11 /* StringLiteral */ ? factory2.cloneNode(specifier.name) : factory2.getExportName(specifier),
107956
108058
  exportedValue,
107957
108059
  /*location*/
107958
108060
  void 0,
@@ -107977,7 +108079,7 @@ function transformModule(context) {
107977
108079
  factory2.cloneNode(node.exportClause.name),
107978
108080
  getHelperExpressionForExport(
107979
108081
  node,
107980
- moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
108082
+ moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : node.exportClause.name.kind === 11 /* StringLiteral */ ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
107981
108083
  )
107982
108084
  )
107983
108085
  ),
@@ -108307,10 +108409,13 @@ function transformModule(context) {
108307
108409
  return statements;
108308
108410
  }
108309
108411
  function appendExportStatement(statements, seen, exportName, expression, location, allowComments, liveBinding) {
108310
- if (!seen.has(exportName)) {
108412
+ if (exportName.kind !== 11 /* StringLiteral */) {
108413
+ if (seen.has(exportName)) {
108414
+ return statements;
108415
+ }
108311
108416
  seen.set(exportName, true);
108312
- statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108313
108417
  }
108418
+ statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108314
108419
  return statements;
108315
108420
  }
108316
108421
  function createUnderscoreUnderscoreESModule() {
@@ -108380,7 +108485,10 @@ function transformModule(context) {
108380
108485
  ])
108381
108486
  ]
108382
108487
  ) : factory2.createAssignment(
108383
- factory2.createPropertyAccessExpression(
108488
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(
108489
+ factory2.createIdentifier("exports"),
108490
+ factory2.cloneNode(name)
108491
+ ) : factory2.createPropertyAccessExpression(
108384
108492
  factory2.createIdentifier("exports"),
108385
108493
  factory2.cloneNode(name)
108386
108494
  ),
@@ -108516,11 +108624,9 @@ function transformModule(context) {
108516
108624
  );
108517
108625
  } else if (isImportSpecifier(importDeclaration)) {
108518
108626
  const name = importDeclaration.propertyName || importDeclaration.name;
108627
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
108519
108628
  return setTextRange(
108520
- factory2.createPropertyAccessExpression(
108521
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
108522
- factory2.cloneNode(name)
108523
- ),
108629
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(name)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(name)),
108524
108630
  /*location*/
108525
108631
  node
108526
108632
  );
@@ -108808,7 +108914,7 @@ function transformSystemModule(context) {
108808
108914
  const exportedNames = [];
108809
108915
  if (moduleInfo.exportedNames) {
108810
108916
  for (const exportedLocalName of moduleInfo.exportedNames) {
108811
- if (exportedLocalName.escapedText === "default") {
108917
+ if (moduleExportNameIsDefault(exportedLocalName)) {
108812
108918
  continue;
108813
108919
  }
108814
108920
  exportedNames.push(
@@ -108986,10 +109092,10 @@ function transformSystemModule(context) {
108986
109092
  for (const e of entry.exportClause.elements) {
108987
109093
  properties.push(
108988
109094
  factory2.createPropertyAssignment(
108989
- factory2.createStringLiteral(idText(e.name)),
109095
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.name)),
108990
109096
  factory2.createElementAccessExpression(
108991
109097
  parameterName,
108992
- factory2.createStringLiteral(idText(e.propertyName || e.name))
109098
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.propertyName || e.name))
108993
109099
  )
108994
109100
  )
108995
109101
  );
@@ -109016,7 +109122,7 @@ function transformSystemModule(context) {
109016
109122
  /*typeArguments*/
109017
109123
  void 0,
109018
109124
  [
109019
- factory2.createStringLiteral(idText(entry.exportClause.name)),
109125
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(entry.exportClause.name)),
109020
109126
  parameterName
109021
109127
  ]
109022
109128
  )
@@ -109356,7 +109462,7 @@ function transformSystemModule(context) {
109356
109462
  const exportSpecifiers = moduleInfo.exportSpecifiers.get(name);
109357
109463
  if (exportSpecifiers) {
109358
109464
  for (const exportSpecifier of exportSpecifiers) {
109359
- if (exportSpecifier.name.escapedText !== excludeName) {
109465
+ if (moduleExportNameTextUnescaped(exportSpecifier.name) !== excludeName) {
109360
109466
  statements = appendExportStatement(statements, exportSpecifier.name, name);
109361
109467
  }
109362
109468
  }
@@ -109777,13 +109883,12 @@ function transformSystemModule(context) {
109777
109883
  node
109778
109884
  );
109779
109885
  } else if (isImportSpecifier(importDeclaration)) {
109886
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109887
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109780
109888
  return setTextRange(
109781
109889
  factory2.createPropertyAssignment(
109782
109890
  factory2.cloneNode(name),
109783
- factory2.createPropertyAccessExpression(
109784
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109785
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109786
- )
109891
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName))
109787
109892
  ),
109788
109893
  /*location*/
109789
109894
  node
@@ -109826,11 +109931,10 @@ function transformSystemModule(context) {
109826
109931
  node
109827
109932
  );
109828
109933
  } else if (isImportSpecifier(importDeclaration)) {
109934
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109935
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109829
109936
  return setTextRange(
109830
- factory2.createPropertyAccessExpression(
109831
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109832
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109833
- ),
109937
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName)),
109834
109938
  /*location*/
109835
109939
  node
109836
109940
  );
@@ -111421,15 +111525,17 @@ function transformDeclarations(context) {
111421
111525
  if (isDeclarationAndNotVisible(input)) return;
111422
111526
  if (hasDynamicName(input)) {
111423
111527
  if (isolatedDeclarations) {
111424
- if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111425
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111426
- return;
111427
- } else if (
111428
- // Type declarations just need to double-check that the input computed name is an entity name expression
111429
- (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111430
- ) {
111431
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111432
- return;
111528
+ if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
111529
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111530
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111531
+ return;
111532
+ } else if (
111533
+ // Type declarations just need to double-check that the input computed name is an entity name expression
111534
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111535
+ ) {
111536
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111537
+ return;
111538
+ }
111433
111539
  }
111434
111540
  } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
111435
111541
  return;
@@ -113045,10 +113151,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113045
113151
  emitSkipped = true;
113046
113152
  return;
113047
113153
  }
113048
- const buildInfo = host.getBuildInfo() || createBuildInfo(
113049
- /*program*/
113050
- void 0
113051
- );
113154
+ const buildInfo = host.getBuildInfo() || { version };
113052
113155
  writeFile(
113053
113156
  host,
113054
113157
  emitterDiagnostics,
@@ -113331,9 +113434,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113331
113434
  return encodeURI(sourceMapFile);
113332
113435
  }
113333
113436
  }
113334
- function createBuildInfo(program) {
113335
- return { program, version };
113336
- }
113337
113437
  function getBuildInfoText(buildInfo) {
113338
113438
  return JSON.stringify(buildInfo);
113339
113439
  }
@@ -113378,7 +113478,8 @@ var notImplementedResolver = {
113378
113478
  getJsxFragmentFactoryEntity: notImplemented,
113379
113479
  isBindingCapturedByNode: notImplemented,
113380
113480
  getDeclarationStatementsForSourceFile: notImplemented,
113381
- isImportRequiredByAugmentation: notImplemented
113481
+ isImportRequiredByAugmentation: notImplemented,
113482
+ isDefinitelyReferenceToGlobalSymbolObject: notImplemented
113382
113483
  };
113383
113484
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
113384
113485
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -118113,7 +118214,7 @@ function isIgnoredFileFromWildCardWatching({
118113
118214
  }
118114
118215
  return false;
118115
118216
  function hasSourceFile(file) {
118116
- return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.getState().fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118217
+ return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.state.fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118117
118218
  }
118118
118219
  function isSupportedScriptKind() {
118119
118220
  if (!getScriptKind) return false;
@@ -118134,9 +118235,6 @@ function isIgnoredFileFromWildCardWatching({
118134
118235
  }
118135
118236
  }
118136
118237
  }
118137
- function isBuilderProgram(program) {
118138
- return !!program.getState;
118139
- }
118140
118238
  function isEmittedFileOfProgram(program, file) {
118141
118239
  if (!program) {
118142
118240
  return false;
@@ -122694,6 +122792,13 @@ var BuilderState;
122694
122792
  })(BuilderState || (BuilderState = {}));
122695
122793
 
122696
122794
  // src/compiler/builder.ts
122795
+ function isBuilderProgramStateWithDefinedProgram(state) {
122796
+ return state.program !== void 0;
122797
+ }
122798
+ function toBuilderProgramStateWithDefinedProgram(state) {
122799
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
122800
+ return state;
122801
+ }
122697
122802
  function getBuilderFileEmit(options) {
122698
122803
  let result = 1 /* Js */;
122699
122804
  if (options.sourceMap) result = result | 2 /* JsMap */;
@@ -122958,7 +123063,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122958
123063
  const affectedFile = affectedFiles[affectedFilesIndex];
122959
123064
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
122960
123065
  state.affectedFilesIndex = affectedFilesIndex;
122961
- addToAffectedFilesPendingEmit(state, affectedFile.resolvedPath, getBuilderFileEmit(state.compilerOptions));
123066
+ addToAffectedFilesPendingEmit(
123067
+ state,
123068
+ affectedFile.resolvedPath,
123069
+ getBuilderFileEmit(state.compilerOptions)
123070
+ );
122962
123071
  handleDtsMayChangeOfAffectedFile(
122963
123072
  state,
122964
123073
  affectedFile,
@@ -122978,12 +123087,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122978
123087
  if (nextKey.done) {
122979
123088
  return void 0;
122980
123089
  }
122981
- const program = Debug.checkDefined(state.program);
122982
- const compilerOptions = program.getCompilerOptions();
122983
- if (compilerOptions.outFile) return program;
123090
+ const compilerOptions = state.program.getCompilerOptions();
123091
+ if (compilerOptions.outFile) return state.program;
122984
123092
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
122985
123093
  state,
122986
- program,
123094
+ state.program,
122987
123095
  nextKey.value,
122988
123096
  cancellationToken,
122989
123097
  host
@@ -123044,9 +123152,8 @@ function getNextPendingEmitDiagnosticsFile(state) {
123044
123152
  function removeDiagnosticsOfLibraryFiles(state) {
123045
123153
  if (!state.cleanedDiagnosticsOfLibFiles) {
123046
123154
  state.cleanedDiagnosticsOfLibFiles = true;
123047
- const program = Debug.checkDefined(state.program);
123048
- const options = program.getCompilerOptions();
123049
- forEach(program.getSourceFiles(), (f) => program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
123155
+ const options = state.program.getCompilerOptions();
123156
+ forEach(state.program.getSourceFiles(), (f) => state.program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, state.program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
123050
123157
  }
123051
123158
  }
123052
123159
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
@@ -123055,7 +123162,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
123055
123162
  removeDiagnosticsOfLibraryFiles(state);
123056
123163
  BuilderState.updateShapeSignature(
123057
123164
  state,
123058
- Debug.checkDefined(state.program),
123165
+ state.program,
123059
123166
  affectedFile,
123060
123167
  cancellationToken,
123061
123168
  host
@@ -123073,12 +123180,11 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
123073
123180
  function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
123074
123181
  removeSemanticDiagnosticsOf(state, path);
123075
123182
  if (!state.changedFilesSet.has(path)) {
123076
- const program = Debug.checkDefined(state.program);
123077
- const sourceFile = program.getSourceFileByPath(path);
123183
+ const sourceFile = state.program.getSourceFileByPath(path);
123078
123184
  if (sourceFile) {
123079
123185
  BuilderState.updateShapeSignature(
123080
123186
  state,
123081
- program,
123187
+ state.program,
123082
123188
  sourceFile,
123083
123189
  cancellationToken,
123084
123190
  host,
@@ -123086,9 +123192,17 @@ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken,
123086
123192
  true
123087
123193
  );
123088
123194
  if (invalidateJsFiles) {
123089
- addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
123195
+ addToAffectedFilesPendingEmit(
123196
+ state,
123197
+ path,
123198
+ getBuilderFileEmit(state.compilerOptions)
123199
+ );
123090
123200
  } else if (getEmitDeclarations(state.compilerOptions)) {
123091
- addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
123201
+ addToAffectedFilesPendingEmit(
123202
+ state,
123203
+ path,
123204
+ state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */
123205
+ );
123092
123206
  }
123093
123207
  }
123094
123208
  }
@@ -123155,7 +123269,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
123155
123269
  host
123156
123270
  );
123157
123271
  if (isChangedSignature(state, currentPath)) {
123158
- const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
123272
+ const currentSourceFile = state.program.getSourceFileByPath(currentPath);
123159
123273
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
123160
123274
  }
123161
123275
  }
@@ -123204,7 +123318,7 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
123204
123318
  function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123205
123319
  return concatenate(
123206
123320
  getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
123207
- Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
123321
+ state.program.getProgramDiagnostics(sourceFile)
123208
123322
  );
123209
123323
  }
123210
123324
  function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
@@ -123214,17 +123328,20 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
123214
123328
  if (cachedDiagnostics) {
123215
123329
  return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123216
123330
  }
123217
- const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123331
+ const diagnostics = state.program.getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123218
123332
  semanticDiagnosticsPerFile.set(path, diagnostics);
123219
123333
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123220
123334
  }
123221
- function isProgramBundleEmitBuildInfo(info) {
123335
+ function isIncrementalBundleEmitBuildInfo(info) {
123222
123336
  var _a;
123223
123337
  return !!((_a = info.options) == null ? void 0 : _a.outFile);
123224
123338
  }
123339
+ function isIncrementalBuildInfo(info) {
123340
+ return !!info.fileNames;
123341
+ }
123225
123342
  function getBuildInfo2(state) {
123226
123343
  var _a, _b;
123227
- const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
123344
+ const currentDirectory = state.program.getCurrentDirectory();
123228
123345
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
123229
123346
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
123230
123347
  const fileNames = [];
@@ -123237,14 +123354,14 @@ function getBuildInfo2(state) {
123237
123354
  tryAddRoot(key, fileId);
123238
123355
  return value.impliedFormat ? { version: value.version, impliedFormat: value.impliedFormat, signature: void 0, affectsGlobalScope: void 0 } : value.version;
123239
123356
  });
123240
- const program2 = {
123357
+ return {
123241
123358
  fileNames,
123242
123359
  fileInfos: fileInfos2,
123243
123360
  root,
123244
123361
  resolvedRoot: toResolvedRoot(),
123245
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123246
- semanticDiagnosticsPerFile: convertToProgramBuildInfoDiagnostics(),
123247
- emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123362
+ options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123363
+ semanticDiagnosticsPerFile: toIncrementalBuildInfoDiagnostics(),
123364
+ emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123248
123365
  changeFileSet: toChangeFileSet(),
123249
123366
  outSignature: state.outSignature,
123250
123367
  latestChangedDtsFile,
@@ -123254,10 +123371,10 @@ function getBuildInfo2(state) {
123254
123371
  // Pending emit is same as deteremined by compilerOptions
123255
123372
  state.programEmitPending
123256
123373
  )
123257
- )
123374
+ ),
123258
123375
  // Actual value
123376
+ version
123259
123377
  };
123260
- return createBuildInfo(program2);
123261
123378
  }
123262
123379
  let fileIdsList;
123263
123380
  let fileNamesToFileIdListId;
@@ -123312,7 +123429,7 @@ function getBuildInfo2(state) {
123312
123429
  toFileIdListId(state.referencedMap.getValues(key))
123313
123430
  ]);
123314
123431
  }
123315
- const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics();
123432
+ const semanticDiagnosticsPerFile = toIncrementalBuildInfoDiagnostics();
123316
123433
  let affectedFilesPendingEmit;
123317
123434
  if ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.size) {
123318
123435
  const fullEmitForOptions = getBuilderFileEmit(state.compilerOptions);
@@ -123336,22 +123453,22 @@ function getBuildInfo2(state) {
123336
123453
  }
123337
123454
  }
123338
123455
  }
123339
- const program = {
123456
+ return {
123340
123457
  fileNames,
123458
+ fileIdsList,
123341
123459
  fileInfos,
123342
123460
  root,
123343
123461
  resolvedRoot: toResolvedRoot(),
123344
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123345
- fileIdsList,
123462
+ options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123346
123463
  referencedMap,
123347
123464
  semanticDiagnosticsPerFile,
123348
- emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123465
+ emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123349
123466
  affectedFilesPendingEmit,
123350
123467
  changeFileSet: toChangeFileSet(),
123351
123468
  emitSignatures,
123352
- latestChangedDtsFile
123469
+ latestChangedDtsFile,
123470
+ version
123353
123471
  };
123354
- return createBuildInfo(program);
123355
123472
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
123356
123473
  return relativeToBuildInfo(getNormalizedAbsolutePath(path, currentDirectory));
123357
123474
  }
@@ -123399,13 +123516,13 @@ function getBuildInfo2(state) {
123399
123516
  });
123400
123517
  return result;
123401
123518
  }
123402
- function convertToProgramBuildInfoCompilerOptions(options) {
123519
+ function toIncrementalBuildInfoCompilerOptions(options) {
123403
123520
  let result;
123404
123521
  const { optionsNameMap } = getOptionsNameMap();
123405
123522
  for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) {
123406
123523
  const optionInfo = optionsNameMap.get(name.toLowerCase());
123407
123524
  if (optionInfo == null ? void 0 : optionInfo.affectsBuildInfo) {
123408
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(
123525
+ (result || (result = {}))[name] = toReusableCompilerOptionValue(
123409
123526
  optionInfo,
123410
123527
  options[name]
123411
123528
  );
@@ -123413,7 +123530,7 @@ function getBuildInfo2(state) {
123413
123530
  }
123414
123531
  return result;
123415
123532
  }
123416
- function convertToReusableCompilerOptionValue(option, value) {
123533
+ function toReusableCompilerOptionValue(option, value) {
123417
123534
  if (option) {
123418
123535
  Debug.assert(option.type !== "listOrElement");
123419
123536
  if (option.type === "list") {
@@ -123427,7 +123544,7 @@ function getBuildInfo2(state) {
123427
123544
  }
123428
123545
  return value;
123429
123546
  }
123430
- function convertToProgramBuildInfoDiagnostics() {
123547
+ function toIncrementalBuildInfoDiagnostics() {
123431
123548
  let result;
123432
123549
  state.fileInfos.forEach((_value, key) => {
123433
123550
  const value = state.semanticDiagnosticsPerFile.get(key);
@@ -123436,13 +123553,13 @@ function getBuildInfo2(state) {
123436
123553
  } else if (value.length) {
123437
123554
  result = append(result, [
123438
123555
  toFileId(key),
123439
- convertToReusableDiagnostics(value, key)
123556
+ toReusableDiagnostic(value, key)
123440
123557
  ]);
123441
123558
  }
123442
123559
  });
123443
123560
  return result;
123444
123561
  }
123445
- function convertToProgramBuildInfoEmitDiagnostics() {
123562
+ function toIncrementalBuildInfoEmitDiagnostics() {
123446
123563
  var _a2;
123447
123564
  let result;
123448
123565
  if (!((_a2 = state.emitDiagnosticsPerFile) == null ? void 0 : _a2.size)) return result;
@@ -123450,51 +123567,51 @@ function getBuildInfo2(state) {
123450
123567
  const value = state.emitDiagnosticsPerFile.get(key);
123451
123568
  result = append(result, [
123452
123569
  toFileId(key),
123453
- convertToReusableDiagnostics(value, key)
123570
+ toReusableDiagnostic(value, key)
123454
123571
  ]);
123455
123572
  }
123456
123573
  return result;
123457
123574
  }
123458
- function convertToReusableDiagnostics(diagnostics, diagnosticFilePath) {
123575
+ function toReusableDiagnostic(diagnostics, diagnosticFilePath) {
123459
123576
  Debug.assert(!!diagnostics.length);
123460
123577
  return diagnostics.map((diagnostic) => {
123461
- const result = convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
123578
+ const result = toReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
123462
123579
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
123463
123580
  result.reportDeprecated = diagnostic.reportsDeprecated;
123464
123581
  result.source = diagnostic.source;
123465
123582
  result.skippedOn = diagnostic.skippedOn;
123466
123583
  const { relatedInformation } = diagnostic;
123467
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
123584
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => toReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
123468
123585
  return result;
123469
123586
  });
123470
123587
  }
123471
- function convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
123588
+ function toReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
123472
123589
  const { file } = diagnostic;
123473
123590
  return {
123474
123591
  ...diagnostic,
123475
123592
  file: file ? file.resolvedPath === diagnosticFilePath ? void 0 : relativeToBuildInfo(file.resolvedPath) : false,
123476
- messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
123593
+ messageText: isString(diagnostic.messageText) ? diagnostic.messageText : toReusableDiagnosticMessageChain(diagnostic.messageText)
123477
123594
  };
123478
123595
  }
123479
- function convertToReusableDiagnosticMessageChain(chain) {
123596
+ function toReusableDiagnosticMessageChain(chain) {
123480
123597
  if (chain.repopulateInfo) {
123481
123598
  return {
123482
123599
  info: chain.repopulateInfo(),
123483
- next: convertToReusableDiagnosticMessageChainArray(chain.next)
123600
+ next: toReusableDiagnosticMessageChainArray(chain.next)
123484
123601
  };
123485
123602
  }
123486
- const next = convertToReusableDiagnosticMessageChainArray(chain.next);
123603
+ const next = toReusableDiagnosticMessageChainArray(chain.next);
123487
123604
  return next === chain.next ? chain : { ...chain, next };
123488
123605
  }
123489
- function convertToReusableDiagnosticMessageChainArray(array) {
123606
+ function toReusableDiagnosticMessageChainArray(array) {
123490
123607
  if (!array) return array;
123491
123608
  return forEach(array, (chain, index) => {
123492
- const reusable = convertToReusableDiagnosticMessageChain(chain);
123609
+ const reusable = toReusableDiagnosticMessageChain(chain);
123493
123610
  if (chain === reusable) return void 0;
123494
123611
  const result = index > 0 ? array.slice(0, index - 1) : [];
123495
123612
  result.push(reusable);
123496
123613
  for (let i = index + 1; i < array.length; i++) {
123497
- result.push(convertToReusableDiagnosticMessageChain(array[i]));
123614
+ result.push(toReusableDiagnosticMessageChain(array[i]));
123498
123615
  }
123499
123616
  return result;
123500
123617
  }) || array;
@@ -123566,24 +123683,27 @@ function computeSignature(text, host, data) {
123566
123683
  return (host.createHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
123567
123684
  }
123568
123685
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
123569
- let oldState = oldProgram && oldProgram.getState();
123686
+ let oldState = oldProgram && oldProgram.state;
123570
123687
  if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
123571
123688
  newProgram = void 0;
123572
123689
  oldState = void 0;
123573
123690
  return oldProgram;
123574
123691
  }
123575
123692
  const state = createBuilderProgramState(newProgram, oldState);
123576
- newProgram.getBuildInfo = () => getBuildInfo2(state);
123693
+ newProgram.getBuildInfo = () => getBuildInfo2(toBuilderProgramStateWithDefinedProgram(state));
123577
123694
  newProgram = void 0;
123578
123695
  oldProgram = void 0;
123579
123696
  oldState = void 0;
123580
- const getState = () => state;
123581
- const builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
123582
- builderProgram.getState = getState;
123697
+ const builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
123698
+ builderProgram.state = state;
123583
123699
  builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
123584
123700
  builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
123585
123701
  builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
123586
- builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(state, Debug.checkDefined(state.program), sourceFile);
123702
+ builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(
123703
+ state,
123704
+ Debug.checkDefined(state.program),
123705
+ sourceFile
123706
+ );
123587
123707
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
123588
123708
  builderProgram.emit = emit;
123589
123709
  builderProgram.releaseProgram = () => releaseCache(state);
@@ -123598,8 +123718,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123598
123718
  }
123599
123719
  return builderProgram;
123600
123720
  function emitBuildInfo(writeFile2, cancellationToken) {
123721
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123601
123722
  if (state.buildInfoEmitPending) {
123602
- const result = Debug.checkDefined(state.program).emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123723
+ const result = state.program.emitBuildInfo(
123724
+ writeFile2 || maybeBind(host, host.writeFile),
123725
+ cancellationToken
123726
+ );
123603
123727
  state.buildInfoEmitPending = false;
123604
123728
  return result;
123605
123729
  }
@@ -123607,6 +123731,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123607
123731
  }
123608
123732
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123609
123733
  var _a, _b, _c, _d;
123734
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123610
123735
  let affected = getNextAffectedFile(state, cancellationToken, host);
123611
123736
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123612
123737
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
@@ -123647,7 +123772,10 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123647
123772
  if (!affected) {
123648
123773
  if (!state.buildInfoEmitPending) return void 0;
123649
123774
  const affected2 = state.program;
123650
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123775
+ const result2 = affected2.emitBuildInfo(
123776
+ writeFile2 || maybeBind(host, host.writeFile),
123777
+ cancellationToken
123778
+ );
123651
123779
  state.buildInfoEmitPending = false;
123652
123780
  return { result: result2, affected: affected2 };
123653
123781
  }
@@ -123695,6 +123823,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123695
123823
  return { result, affected };
123696
123824
  }
123697
123825
  function getWriteFileCallback(writeFile2, customTransformers) {
123826
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123698
123827
  if (!getEmitDeclarations(state.compilerOptions)) return writeFile2 || maybeBind(host, host.writeFile);
123699
123828
  return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
123700
123829
  var _a, _b, _c;
@@ -123761,6 +123890,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123761
123890
  };
123762
123891
  }
123763
123892
  function emit(targetSourceFile, writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123893
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123764
123894
  if (kind === 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
123765
123895
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
123766
123896
  }
@@ -123773,7 +123903,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123773
123903
  let diagnostics;
123774
123904
  let emittedFiles = [];
123775
123905
  let affectedEmitResult;
123776
- while (affectedEmitResult = emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
123906
+ while (affectedEmitResult = emitNextAffectedFile(
123907
+ writeFile2,
123908
+ cancellationToken,
123909
+ emitOnlyDtsFiles,
123910
+ customTransformers
123911
+ )) {
123777
123912
  emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
123778
123913
  diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics);
123779
123914
  emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
@@ -123789,7 +123924,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123789
123924
  clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles);
123790
123925
  }
123791
123926
  }
123792
- return Debug.checkDefined(state.program).emit(
123927
+ return state.program.emit(
123793
123928
  targetSourceFile,
123794
123929
  getWriteFileCallback(writeFile2, customTransformers),
123795
123930
  cancellationToken,
@@ -123798,6 +123933,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123798
123933
  );
123799
123934
  }
123800
123935
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
123936
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123801
123937
  while (true) {
123802
123938
  const affected = getNextAffectedFile(state, cancellationToken, host);
123803
123939
  let result;
@@ -123835,6 +123971,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123835
123971
  }
123836
123972
  }
123837
123973
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
123974
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123838
123975
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
123839
123976
  if (sourceFile) {
123840
123977
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
@@ -123845,7 +123982,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123845
123982
  if (affectedResult.affected === state.program) return affectedResult.result;
123846
123983
  }
123847
123984
  let diagnostics;
123848
- for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
123985
+ for (const sourceFile2 of state.program.getSourceFiles()) {
123849
123986
  diagnostics = addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile2, cancellationToken));
123850
123987
  }
123851
123988
  return diagnostics || emptyArray;
@@ -123866,43 +124003,42 @@ function toBuilderFileEmit(value, fullEmitForOptions) {
123866
124003
  function toProgramEmitPending(value, options) {
123867
124004
  return !value ? getBuilderFileEmit(options || {}) : value;
123868
124005
  }
123869
- function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host) {
124006
+ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath, host) {
123870
124007
  var _a, _b, _c, _d;
123871
- const program = buildInfo.program;
123872
124008
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
123873
124009
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
123874
124010
  let state;
123875
- const filePaths = (_a = program.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
124011
+ const filePaths = (_a = buildInfo.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
123876
124012
  let filePathsSetList;
123877
- const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : void 0;
124013
+ const latestChangedDtsFile = buildInfo.latestChangedDtsFile ? toAbsolutePath(buildInfo.latestChangedDtsFile) : void 0;
123878
124014
  const fileInfos = /* @__PURE__ */ new Map();
123879
- const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123880
- if (isProgramBundleEmitBuildInfo(program)) {
123881
- program.fileInfos.forEach((fileInfo, index) => {
124015
+ const changedFilesSet = new Set(map(buildInfo.changeFileSet, toFilePath));
124016
+ if (isIncrementalBundleEmitBuildInfo(buildInfo)) {
124017
+ buildInfo.fileInfos.forEach((fileInfo, index) => {
123882
124018
  const path = toFilePath(index + 1);
123883
124019
  fileInfos.set(path, isString(fileInfo) ? { version: fileInfo, signature: void 0, affectsGlobalScope: void 0, impliedFormat: void 0 } : fileInfo);
123884
124020
  });
123885
124021
  state = {
123886
124022
  fileInfos,
123887
- compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123888
- semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123889
- emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
124023
+ compilerOptions: buildInfo.options ? convertToOptionsWithAbsolutePaths(buildInfo.options, toAbsolutePath) : {},
124024
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124025
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
123890
124026
  hasReusableDiagnostic: true,
123891
124027
  changedFilesSet,
123892
124028
  latestChangedDtsFile,
123893
- outSignature: program.outSignature,
123894
- programEmitPending: program.pendingEmit === void 0 ? void 0 : toProgramEmitPending(program.pendingEmit, program.options)
124029
+ outSignature: buildInfo.outSignature,
124030
+ programEmitPending: buildInfo.pendingEmit === void 0 ? void 0 : toProgramEmitPending(buildInfo.pendingEmit, buildInfo.options)
123895
124031
  };
123896
124032
  } else {
123897
- filePathsSetList = (_b = program.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
123898
- const emitSignatures = ((_c = program.options) == null ? void 0 : _c.composite) && !program.options.outFile ? /* @__PURE__ */ new Map() : void 0;
123899
- program.fileInfos.forEach((fileInfo, index) => {
124033
+ filePathsSetList = (_b = buildInfo.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
124034
+ const emitSignatures = ((_c = buildInfo.options) == null ? void 0 : _c.composite) && !buildInfo.options.outFile ? /* @__PURE__ */ new Map() : void 0;
124035
+ buildInfo.fileInfos.forEach((fileInfo, index) => {
123900
124036
  const path = toFilePath(index + 1);
123901
124037
  const stateFileInfo = toBuilderStateFileInfoForMultiEmit(fileInfo);
123902
124038
  fileInfos.set(path, stateFileInfo);
123903
124039
  if (emitSignatures && stateFileInfo.signature) emitSignatures.set(path, stateFileInfo.signature);
123904
124040
  });
123905
- (_d = program.emitSignatures) == null ? void 0 : _d.forEach((value) => {
124041
+ (_d = buildInfo.emitSignatures) == null ? void 0 : _d.forEach((value) => {
123906
124042
  if (isNumber(value)) emitSignatures.delete(toFilePath(value));
123907
124043
  else {
123908
124044
  const key = toFilePath(value[0]);
@@ -123915,22 +124051,22 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123915
124051
  );
123916
124052
  }
123917
124053
  });
123918
- const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
124054
+ const fullEmitForOptions = buildInfo.affectedFilesPendingEmit ? getBuilderFileEmit(buildInfo.options || {}) : void 0;
123919
124055
  state = {
123920
124056
  fileInfos,
123921
- compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123922
- referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
123923
- semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123924
- emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
124057
+ compilerOptions: buildInfo.options ? convertToOptionsWithAbsolutePaths(buildInfo.options, toAbsolutePath) : {},
124058
+ referencedMap: toManyToManyPathMap(buildInfo.referencedMap, buildInfo.options ?? {}),
124059
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124060
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
123925
124061
  hasReusableDiagnostic: true,
123926
- affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
124062
+ affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
123927
124063
  changedFilesSet,
123928
124064
  latestChangedDtsFile,
123929
124065
  emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
123930
124066
  };
123931
124067
  }
123932
124068
  return {
123933
- getState: () => state,
124069
+ state,
123934
124070
  saveEmitState: noop,
123935
124071
  restoreEmitState: noop,
123936
124072
  getProgram: notImplemented,
@@ -124024,15 +124160,15 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
124024
124160
  }
124025
124161
  }
124026
124162
  }
124027
- function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
124163
+ function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
124028
124164
  return {
124029
- getState: notImplemented,
124165
+ state: void 0,
124030
124166
  saveEmitState: noop,
124031
124167
  restoreEmitState: noop,
124032
124168
  getProgram,
124033
- getProgramOrUndefined: () => getState().program,
124034
- releaseProgram: () => getState().program = void 0,
124035
- getCompilerOptions: () => getState().compilerOptions,
124169
+ getProgramOrUndefined: () => state.program,
124170
+ releaseProgram: () => state.program = void 0,
124171
+ getCompilerOptions: () => state.compilerOptions,
124036
124172
  getSourceFile: (fileName) => getProgram().getSourceFile(fileName),
124037
124173
  getSourceFiles: () => getProgram().getSourceFiles(),
124038
124174
  getOptionsDiagnostics: (cancellationToken) => getProgram().getOptionsDiagnostics(cancellationToken),
@@ -124048,13 +124184,23 @@ function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics)
124048
124184
  close: noop
124049
124185
  };
124050
124186
  function getProgram() {
124051
- return Debug.checkDefined(getState().program);
124187
+ return Debug.checkDefined(state.program);
124052
124188
  }
124053
124189
  }
124054
124190
 
124055
124191
  // src/compiler/builderPublic.ts
124056
124192
  function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
124057
- return createBuilderProgram(1 /* EmitAndSemanticDiagnosticsBuilderProgram */, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
124193
+ return createBuilderProgram(
124194
+ 1 /* EmitAndSemanticDiagnosticsBuilderProgram */,
124195
+ getBuilderCreationParameters(
124196
+ newProgramOrRootNames,
124197
+ hostOrOptions,
124198
+ oldProgramOrHost,
124199
+ configFileParsingDiagnosticsOrOldProgram,
124200
+ configFileParsingDiagnostics,
124201
+ projectReferences
124202
+ )
124203
+ );
124058
124204
  }
124059
124205
 
124060
124206
  // src/compiler/resolutionCache.ts
@@ -125326,13 +125472,13 @@ function createTabularErrorsDisplay(filesInError, host) {
125326
125472
  });
125327
125473
  return tabularData;
125328
125474
  }
125329
- function isBuilderProgram2(program) {
125330
- return !!program.getState;
125475
+ function isBuilderProgram(program) {
125476
+ return !!program.state;
125331
125477
  }
125332
125478
  function listFiles(program, write) {
125333
125479
  const options = program.getCompilerOptions();
125334
125480
  if (options.explainFiles) {
125335
- explainFiles(isBuilderProgram2(program) ? program.getProgram() : program, write);
125481
+ explainFiles(isBuilderProgram(program) ? program.getProgram() : program, write);
125336
125482
  } else if (options.listFiles || options.listFilesOnly) {
125337
125483
  forEach(program.getSourceFiles(), (file) => {
125338
125484
  write(file.fileName);
@@ -125832,8 +125978,8 @@ function readBuilderProgram(compilerOptions, host) {
125832
125978
  if (!content) return void 0;
125833
125979
  buildInfo = getBuildInfo(buildInfoPath, content);
125834
125980
  }
125835
- if (!buildInfo || buildInfo.version !== version || !buildInfo.program) return void 0;
125836
- return createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host);
125981
+ if (!buildInfo || buildInfo.version !== version || !isIncrementalBuildInfo(buildInfo)) return void 0;
125982
+ return createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath, host);
125837
125983
  }
125838
125984
  function createIncrementalCompilerHost(options, system = sys) {
125839
125985
  const host = createCompilerHostWorker(
@@ -127548,7 +127694,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127548
127694
  let oldestOutputFileName;
127549
127695
  let oldestOutputFileTime = maximumDate;
127550
127696
  let buildInfoTime;
127551
- let buildInfoProgram;
127697
+ let incrementalBuildInfo;
127552
127698
  let buildInfoVersionMap;
127553
127699
  if (buildInfoPath) {
127554
127700
  const buildInfoCacheEntry2 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
@@ -127573,26 +127719,26 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127573
127719
  fileName: buildInfoPath
127574
127720
  };
127575
127721
  }
127576
- if (buildInfo.program && buildInfo.version !== version) {
127722
+ if (isIncrementalBuildInfo(buildInfo) && buildInfo.version !== version) {
127577
127723
  return {
127578
127724
  type: 13 /* TsVersionOutputOfDate */,
127579
127725
  version: buildInfo.version
127580
127726
  };
127581
127727
  }
127582
- if (buildInfo.program) {
127583
- if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) || buildInfo.program.pendingEmit !== void 0 : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127728
+ if (isIncrementalBuildInfo(buildInfo)) {
127729
+ if (((_a = buildInfo.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.emitDiagnosticsPerFile) == null ? void 0 : _c.length) || buildInfo.pendingEmit !== void 0 : (_d = buildInfo.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127584
127730
  return {
127585
127731
  type: 7 /* OutOfDateBuildInfo */,
127586
127732
  buildInfoFile: buildInfoPath
127587
127733
  };
127588
127734
  }
127589
- if (!project.options.noEmit && getPendingEmitKind(project.options, buildInfo.program.options || {})) {
127735
+ if (!project.options.noEmit && getPendingEmitKind(project.options, buildInfo.options || {})) {
127590
127736
  return {
127591
127737
  type: 8 /* OutOfDateOptions */,
127592
127738
  buildInfoFile: buildInfoPath
127593
127739
  };
127594
127740
  }
127595
- buildInfoProgram = buildInfo.program;
127741
+ incrementalBuildInfo = buildInfo;
127596
127742
  }
127597
127743
  oldestOutputFileTime = buildInfoTime;
127598
127744
  oldestOutputFileName = buildInfoPath;
@@ -127609,12 +127755,12 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127609
127755
  reason: `${inputFile} does not exist`
127610
127756
  };
127611
127757
  }
127612
- const inputPath = buildInfoProgram ? toPath2(state, inputFile) : void 0;
127758
+ const inputPath = incrementalBuildInfo ? toPath2(state, inputFile) : void 0;
127613
127759
  if (buildInfoTime && buildInfoTime < inputTime) {
127614
127760
  let version2;
127615
127761
  let currentVersion;
127616
- if (buildInfoProgram) {
127617
- if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
127762
+ if (incrementalBuildInfo) {
127763
+ if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host);
127618
127764
  const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath);
127619
127765
  version2 = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath);
127620
127766
  const text = version2 ? state.readFileWithCache(resolvedInputPath ?? inputFile) : void 0;
@@ -127633,10 +127779,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127633
127779
  newestInputFileName = inputFile;
127634
127780
  newestInputFileTime = inputTime;
127635
127781
  }
127636
- if (buildInfoProgram) seenRoots.add(inputPath);
127782
+ if (incrementalBuildInfo) seenRoots.add(inputPath);
127637
127783
  }
127638
- if (buildInfoProgram) {
127639
- if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
127784
+ if (incrementalBuildInfo) {
127785
+ if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host);
127640
127786
  const existingRoot = forEachEntry(
127641
127787
  buildInfoVersionMap.roots,
127642
127788
  // File was root file when project was built but its not any more
@@ -127783,7 +127929,7 @@ function getLatestChangedDtsTime(state, options, resolvedConfigPath) {
127783
127929
  if (!options.composite) return void 0;
127784
127930
  const entry = Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
127785
127931
  if (entry.latestChangedDtsTime !== void 0) return entry.latestChangedDtsTime || void 0;
127786
- const latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? state.host.getModifiedTime(getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, getDirectoryPath(entry.path))) : void 0;
127932
+ const latestChangedDtsTime = entry.buildInfo && isIncrementalBuildInfo(entry.buildInfo) && entry.buildInfo.latestChangedDtsFile ? state.host.getModifiedTime(getNormalizedAbsolutePath(entry.buildInfo.latestChangedDtsFile, getDirectoryPath(entry.path))) : void 0;
127787
127933
  entry.latestChangedDtsTime = latestChangedDtsTime || false;
127788
127934
  return latestChangedDtsTime;
127789
127935
  }
@@ -129747,7 +129893,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
129747
129893
  expression,
129748
129894
  /*includeBigInt*/
129749
129895
  false
129750
- )) {
129896
+ ) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
129751
129897
  context.tracker.reportInferenceFallback(prop.name);
129752
129898
  result = false;
129753
129899
  }