@typescript-deploys/pr-build 5.6.0-pr-57196-3 → 5.6.0-pr-58668-2

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.20240607`;
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)) {
@@ -26045,6 +26063,9 @@ function isNamedExports(node) {
26045
26063
  function isExportSpecifier(node) {
26046
26064
  return node.kind === 281 /* ExportSpecifier */;
26047
26065
  }
26066
+ function isModuleExportName(node) {
26067
+ return node.kind === 80 /* Identifier */ || node.kind === 11 /* StringLiteral */;
26068
+ }
26048
26069
  function isNotEmittedStatement(node) {
26049
26070
  return node.kind === 353 /* NotEmittedStatement */;
26050
26071
  }
@@ -26743,6 +26764,9 @@ function getLocalNameForExternalImport(factory2, node, sourceFile) {
26743
26764
  const namespaceDeclaration = getNamespaceDeclarationNode(node);
26744
26765
  if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) {
26745
26766
  const name = namespaceDeclaration.name;
26767
+ if (name.kind === 11 /* StringLiteral */) {
26768
+ return factory2.getGeneratedNameForNode(node);
26769
+ }
26746
26770
  return isGeneratedIdentifier(name) ? name : factory2.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name));
26747
26771
  }
26748
26772
  if (node.kind === 272 /* ImportDeclaration */ && node.importClause) {
@@ -29078,6 +29102,9 @@ var Parser;
29078
29102
  if (token() === 161 /* FromKeyword */ && lookAhead(nextTokenIsStringLiteral)) {
29079
29103
  return false;
29080
29104
  }
29105
+ if (token() === 11 /* StringLiteral */) {
29106
+ return true;
29107
+ }
29081
29108
  return tokenIsIdentifierOrKeyword(token());
29082
29109
  case 13 /* JsxAttributes */:
29083
29110
  return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
@@ -33526,6 +33553,12 @@ var Parser;
33526
33553
  const name = parseIdentifier();
33527
33554
  return finishNode(factory2.createNamespaceImport(name), pos);
33528
33555
  }
33556
+ function canParseModuleExportName() {
33557
+ return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
33558
+ }
33559
+ function parseModuleExportName(parseName) {
33560
+ return token() === 11 /* StringLiteral */ ? parseLiteralNode() : parseName();
33561
+ }
33529
33562
  function parseNamedImportsOrExports(kind) {
33530
33563
  const pos = getNodePos();
33531
33564
  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 */));
@@ -33546,42 +33579,51 @@ var Parser;
33546
33579
  let isTypeOnly = false;
33547
33580
  let propertyName;
33548
33581
  let canParseAsKeyword = true;
33549
- let name = parseIdentifierName();
33550
- if (name.escapedText === "type") {
33582
+ let name = parseModuleExportName(parseIdentifierName);
33583
+ if (name.kind === 80 /* Identifier */ && name.escapedText === "type") {
33551
33584
  if (token() === 130 /* AsKeyword */) {
33552
33585
  const firstAs = parseIdentifierName();
33553
33586
  if (token() === 130 /* AsKeyword */) {
33554
33587
  const secondAs = parseIdentifierName();
33555
- if (tokenIsIdentifierOrKeyword(token())) {
33588
+ if (canParseModuleExportName()) {
33556
33589
  isTypeOnly = true;
33557
33590
  propertyName = firstAs;
33558
- name = parseNameWithKeywordCheck();
33591
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33559
33592
  canParseAsKeyword = false;
33560
33593
  } else {
33561
33594
  propertyName = name;
33562
33595
  name = secondAs;
33563
33596
  canParseAsKeyword = false;
33564
33597
  }
33565
- } else if (tokenIsIdentifierOrKeyword(token())) {
33598
+ } else if (canParseModuleExportName()) {
33566
33599
  propertyName = name;
33567
33600
  canParseAsKeyword = false;
33568
- name = parseNameWithKeywordCheck();
33601
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33569
33602
  } else {
33570
33603
  isTypeOnly = true;
33571
33604
  name = firstAs;
33572
33605
  }
33573
- } else if (tokenIsIdentifierOrKeyword(token())) {
33606
+ } else if (canParseModuleExportName()) {
33574
33607
  isTypeOnly = true;
33575
- name = parseNameWithKeywordCheck();
33608
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33576
33609
  }
33577
33610
  }
33578
33611
  if (canParseAsKeyword && token() === 130 /* AsKeyword */) {
33579
33612
  propertyName = name;
33580
33613
  parseExpected(130 /* AsKeyword */);
33581
- name = parseNameWithKeywordCheck();
33614
+ name = parseModuleExportName(parseNameWithKeywordCheck);
33582
33615
  }
33583
- if (kind === 276 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
33584
- parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
33616
+ if (kind === 276 /* ImportSpecifier */) {
33617
+ if (name.kind !== 80 /* Identifier */) {
33618
+ parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected);
33619
+ name = setTextRangePosEnd(createMissingNode(
33620
+ 80 /* Identifier */,
33621
+ /*reportAtCurrentPosition*/
33622
+ false
33623
+ ), name.pos, name.pos);
33624
+ } else if (checkIdentifierIsKeyword) {
33625
+ parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
33626
+ }
33585
33627
  }
33586
33628
  const node = kind === 276 /* ImportSpecifier */ ? factory2.createImportSpecifier(isTypeOnly, propertyName, name) : factory2.createExportSpecifier(isTypeOnly, propertyName, name);
33587
33629
  return finishNode(node, pos);
@@ -33593,7 +33635,7 @@ var Parser;
33593
33635
  }
33594
33636
  }
33595
33637
  function parseNamespaceExport(pos) {
33596
- return finishNode(factory2.createNamespaceExport(parseIdentifierName()), pos);
33638
+ return finishNode(factory2.createNamespaceExport(parseModuleExportName(parseIdentifierName)), pos);
33597
33639
  }
33598
33640
  function parseExportDeclaration(pos, hasJSDoc, modifiers) {
33599
33641
  const savedAwaitContext = inAwaitContext();
@@ -41117,6 +41159,9 @@ function getModuleInstanceStateWorker(node, visited) {
41117
41159
  }
41118
41160
  function getModuleInstanceStateForAliasTarget(specifier, visited) {
41119
41161
  const name = specifier.propertyName || specifier.name;
41162
+ if (name.kind !== 80 /* Identifier */) {
41163
+ return 1 /* Instantiated */;
41164
+ }
41120
41165
  let p = specifier.parent;
41121
41166
  while (p) {
41122
41167
  if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) {
@@ -41361,7 +41406,7 @@ function createBinder() {
41361
41406
  }
41362
41407
  function declareSymbol(symbolTable, parent2, node, includes, excludes, isReplaceableByMethod, isComputedName) {
41363
41408
  Debug.assert(isComputedName || !hasDynamicName(node));
41364
- const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default";
41409
+ const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && moduleExportNameIsDefault(node.name);
41365
41410
  const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent2 ? "default" /* Default */ : getDeclarationName(node);
41366
41411
  let symbol;
41367
41412
  if (name === void 0) {
@@ -45149,7 +45194,8 @@ function createTypeChecker(host) {
45149
45194
  isUndefinedIdentifierExpression(node) {
45150
45195
  Debug.assert(isExpressionNode(node));
45151
45196
  return getSymbolAtLocation(node) === undefinedSymbol;
45152
- }
45197
+ },
45198
+ isDefinitelyReferenceToGlobalSymbolObject
45153
45199
  });
45154
45200
  var evaluate = createEvaluator({
45155
45201
  evaluateElementAccessExpression,
@@ -46106,6 +46152,21 @@ function createTypeChecker(host) {
46106
46152
  ];
46107
46153
  initializeTypeChecker();
46108
46154
  return checker;
46155
+ function isDefinitelyReferenceToGlobalSymbolObject(node) {
46156
+ if (!isPropertyAccessExpression(node)) return false;
46157
+ if (!isIdentifier(node.name)) return false;
46158
+ if (!isPropertyAccessExpression(node.expression) && !isIdentifier(node.expression)) return false;
46159
+ if (isIdentifier(node.expression)) {
46160
+ return idText(node.expression) === "Symbol" && getResolvedSymbol(node.expression) === (getGlobalSymbol(
46161
+ "Symbol",
46162
+ 111551 /* Value */ | 1048576 /* ExportValue */,
46163
+ /*diagnostic*/
46164
+ void 0
46165
+ ) || unknownSymbol);
46166
+ }
46167
+ if (!isIdentifier(node.expression.expression)) return false;
46168
+ return idText(node.expression.name) === "Symbol" && idText(node.expression.expression) === "globalThis" && getResolvedSymbol(node.expression.expression) === globalThisSymbol;
46169
+ }
46109
46170
  function getCachedType(key) {
46110
46171
  return key ? cachedTypes.get(key) : void 0;
46111
46172
  }
@@ -46452,6 +46513,8 @@ function createTypeChecker(host) {
46452
46513
  moduleName,
46453
46514
  moduleName,
46454
46515
  moduleNotFoundError,
46516
+ /*ignoreErrors*/
46517
+ false,
46455
46518
  /*isForAugmentation*/
46456
46519
  true
46457
46520
  );
@@ -47134,7 +47197,7 @@ function createTypeChecker(host) {
47134
47197
  const isExport = typeOnlyDeclaration.kind === 281 /* ExportSpecifier */ || typeOnlyDeclaration.kind === 278 /* ExportDeclaration */;
47135
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;
47136
47199
  const relatedMessage = isExport ? Diagnostics._0_was_exported_here : Diagnostics._0_was_imported_here;
47137
- const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
47200
+ const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : moduleExportNameTextUnescaped(typeOnlyDeclaration.name);
47138
47201
  addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
47139
47202
  }
47140
47203
  }
@@ -47378,12 +47441,12 @@ function createTypeChecker(host) {
47378
47441
  if (valueSymbol.exports) result.exports = new Map(valueSymbol.exports);
47379
47442
  return result;
47380
47443
  }
47381
- function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
47444
+ function getExportOfModule(symbol, nameText, specifier, dontResolveAlias) {
47382
47445
  var _a;
47383
47446
  if (symbol.flags & 1536 /* Module */) {
47384
- const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
47447
+ const exportSymbol = getExportsOfSymbol(symbol).get(nameText);
47385
47448
  const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
47386
- 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);
47387
47450
  markSymbolOfAliasDeclarationIfTypeOnly(
47388
47451
  specifier,
47389
47452
  exportSymbol,
@@ -47391,7 +47454,7 @@ function createTypeChecker(host) {
47391
47454
  /*overwriteEmpty*/
47392
47455
  false,
47393
47456
  exportStarDeclaration,
47394
- name.escapedText
47457
+ nameText
47395
47458
  );
47396
47459
  return resolved;
47397
47460
  }
@@ -47409,10 +47472,11 @@ function createTypeChecker(host) {
47409
47472
  const moduleSpecifier = getExternalModuleRequireArgument(node) || node.moduleSpecifier;
47410
47473
  const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
47411
47474
  const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
47412
- if (!isIdentifier(name)) {
47475
+ if (!isIdentifier(name) && name.kind !== 11 /* StringLiteral */) {
47413
47476
  return void 0;
47414
47477
  }
47415
- const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
47478
+ const nameText = moduleExportNameTextEscaped(name);
47479
+ const suppressInteropError = nameText === "default" /* Default */ && allowSyntheticDefaultImports;
47416
47480
  const targetSymbol = resolveESModuleSymbol(
47417
47481
  moduleSymbol,
47418
47482
  moduleSpecifier,
@@ -47421,7 +47485,7 @@ function createTypeChecker(host) {
47421
47485
  suppressInteropError
47422
47486
  );
47423
47487
  if (targetSymbol) {
47424
- if (name.escapedText) {
47488
+ if (nameText || name.kind === 11 /* StringLiteral */) {
47425
47489
  if (isShorthandAmbientModuleSymbol(moduleSymbol)) {
47426
47490
  return moduleSymbol;
47427
47491
  }
@@ -47429,16 +47493,16 @@ function createTypeChecker(host) {
47429
47493
  if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) {
47430
47494
  symbolFromVariable = getPropertyOfType(
47431
47495
  getTypeOfSymbol(targetSymbol),
47432
- name.escapedText,
47496
+ nameText,
47433
47497
  /*skipObjectFunctionPropertyAugment*/
47434
47498
  true
47435
47499
  );
47436
47500
  } else {
47437
- symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
47501
+ symbolFromVariable = getPropertyOfVariable(targetSymbol, nameText);
47438
47502
  }
47439
47503
  symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
47440
- let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
47441
- if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
47504
+ let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
47505
+ if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
47442
47506
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
47443
47507
  if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47444
47508
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
@@ -47456,7 +47520,7 @@ function createTypeChecker(host) {
47456
47520
  var _a;
47457
47521
  const moduleName = getFullyQualifiedName(moduleSymbol, node);
47458
47522
  const declarationName = declarationNameToString(name);
47459
- const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
47523
+ const suggestion = isIdentifier(name) ? getSuggestedSymbolForNonexistentModule(name, targetSymbol) : void 0;
47460
47524
  if (suggestion !== void 0) {
47461
47525
  const suggestionName = symbolToString(suggestion);
47462
47526
  const diagnostic = error(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
@@ -47478,7 +47542,7 @@ function createTypeChecker(host) {
47478
47542
  }
47479
47543
  function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
47480
47544
  var _a, _b;
47481
- 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));
47482
47546
  const exports2 = moduleSymbol.exports;
47483
47547
  if (localSymbol) {
47484
47548
  const exportedEqualsSymbol = exports2 == null ? void 0 : exports2.get("export=" /* ExportEquals */);
@@ -47510,7 +47574,7 @@ function createTypeChecker(host) {
47510
47574
  }
47511
47575
  }
47512
47576
  function getTargetOfImportSpecifier(node, dontResolveAlias) {
47513
- if (isImportSpecifier(node) && idText(node.propertyName || node.name) === "default" /* Default */) {
47577
+ if (isImportSpecifier(node) && moduleExportNameIsDefault(node.propertyName || node.name)) {
47514
47578
  const specifier = getModuleSpecifierForImportOrExport(node);
47515
47579
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47516
47580
  if (moduleSymbol) {
@@ -47554,19 +47618,23 @@ function createTypeChecker(host) {
47554
47618
  }
47555
47619
  }
47556
47620
  function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
47557
- if (idText(node.propertyName || node.name) === "default" /* Default */) {
47621
+ const name = node.propertyName || node.name;
47622
+ if (moduleExportNameIsDefault(name)) {
47558
47623
  const specifier = getModuleSpecifierForImportOrExport(node);
47559
47624
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47560
47625
  if (moduleSymbol) {
47561
47626
  return getTargetofModuleDefault(moduleSymbol, node, !!dontResolveAlias);
47562
47627
  }
47563
47628
  }
47564
- const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : resolveEntityName(
47565
- node.propertyName || node.name,
47566
- meaning,
47567
- /*ignoreErrors*/
47568
- false,
47569
- 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
+ )
47570
47638
  );
47571
47639
  markSymbolOfAliasDeclarationIfTypeOnly(
47572
47640
  node,
@@ -48014,14 +48082,14 @@ function createTypeChecker(host) {
48014
48082
  function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
48015
48083
  const isClassic = getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */;
48016
48084
  const errorMessage = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
48017
- return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? void 0 : errorMessage);
48085
+ return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? void 0 : errorMessage, ignoreErrors);
48018
48086
  }
48019
- function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation = false) {
48020
- return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
48087
+ function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, ignoreErrors = false, isForAugmentation = false) {
48088
+ return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, !ignoreErrors ? moduleReferenceExpression : void 0, isForAugmentation) : void 0;
48021
48089
  }
48022
48090
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
48023
48091
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
48024
- if (startsWith(moduleReference, "@types/")) {
48092
+ if (errorNode && startsWith(moduleReference, "@types/")) {
48025
48093
  const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
48026
48094
  const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
48027
48095
  error(errorNode, diag2, withoutAtTypePrefix, moduleReference);
@@ -48043,7 +48111,7 @@ function createTypeChecker(host) {
48043
48111
  const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
48044
48112
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
48045
48113
  const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
48046
- const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
48114
+ const resolutionDiagnostic = errorNode && resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
48047
48115
  const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
48048
48116
  if (sourceFile) {
48049
48117
  if (resolutionDiagnostic) {
@@ -48051,7 +48119,7 @@ function createTypeChecker(host) {
48051
48119
  }
48052
48120
  if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) {
48053
48121
  const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48054
- if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
48122
+ if (errorNode && importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
48055
48123
  error(
48056
48124
  errorNode,
48057
48125
  Diagnostics.A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead,
@@ -48060,13 +48128,13 @@ function createTypeChecker(host) {
48060
48128
  }
48061
48129
  } else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
48062
48130
  const importOrExport = ((_i = findAncestor(location, isImportDeclaration)) == null ? void 0 : _i.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48063
- if (!((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
48131
+ if (errorNode && !((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
48064
48132
  const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
48065
48133
  error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
48066
48134
  }
48067
48135
  }
48068
48136
  if (sourceFile.symbol) {
48069
- if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
48137
+ if (errorNode && resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
48070
48138
  errorOnImplicitAnyModule(
48071
48139
  /*isError*/
48072
48140
  false,
@@ -48077,7 +48145,7 @@ function createTypeChecker(host) {
48077
48145
  moduleReference
48078
48146
  );
48079
48147
  }
48080
- if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
48148
+ if (errorNode && (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */)) {
48081
48149
  const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
48082
48150
  const overrideHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
48083
48151
  if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !hasResolutionModeOverride(overrideHost)) {
@@ -48137,7 +48205,7 @@ function createTypeChecker(host) {
48137
48205
  }
48138
48206
  return getMergedSymbol(sourceFile.symbol);
48139
48207
  }
48140
- if (moduleNotFoundError) {
48208
+ if (errorNode && moduleNotFoundError) {
48141
48209
  error(errorNode, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
48142
48210
  }
48143
48211
  return void 0;
@@ -48152,6 +48220,9 @@ function createTypeChecker(host) {
48152
48220
  return getMergedSymbol(pattern.symbol);
48153
48221
  }
48154
48222
  }
48223
+ if (!errorNode) {
48224
+ return void 0;
48225
+ }
48155
48226
  if (resolvedModule && !resolutionExtensionIsTSOrJson(resolvedModule.extension) && resolutionDiagnostic === void 0 || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
48156
48227
  if (isForAugmentation) {
48157
48228
  const diag2 = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
@@ -51615,6 +51686,57 @@ function createTypeChecker(host) {
51615
51686
  function onEnterNewScope(node) {
51616
51687
  return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51617
51688
  }
51689
+ function tryVisitSimpleTypeNode(node) {
51690
+ const innerNode = skipTypeParentheses(node);
51691
+ switch (innerNode.kind) {
51692
+ case 183 /* TypeReference */:
51693
+ return tryVisitTypeReference(innerNode);
51694
+ case 186 /* TypeQuery */:
51695
+ return tryVisitTypeQuery(innerNode);
51696
+ case 199 /* IndexedAccessType */:
51697
+ return tryVisitIndexedAccess(innerNode);
51698
+ case 198 /* TypeOperator */:
51699
+ const typeOperatorNode = innerNode;
51700
+ if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
51701
+ return tryVisitKeyOf(typeOperatorNode);
51702
+ }
51703
+ }
51704
+ return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
51705
+ }
51706
+ function tryVisitIndexedAccess(node) {
51707
+ const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
51708
+ if (resultObjectType === void 0) {
51709
+ return void 0;
51710
+ }
51711
+ return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51712
+ }
51713
+ function tryVisitKeyOf(node) {
51714
+ Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
51715
+ const type = tryVisitSimpleTypeNode(node.type);
51716
+ if (type === void 0) {
51717
+ return void 0;
51718
+ }
51719
+ return factory.updateTypeOperatorNode(node, type);
51720
+ }
51721
+ function tryVisitTypeQuery(node) {
51722
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51723
+ if (!introducesError) {
51724
+ return factory.updateTypeQueryNode(
51725
+ node,
51726
+ exprName,
51727
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51728
+ );
51729
+ }
51730
+ const serializedName = serializeTypeName(
51731
+ context,
51732
+ node.exprName,
51733
+ /*isTypeOf*/
51734
+ true
51735
+ );
51736
+ if (serializedName) {
51737
+ return setTextRange2(context, serializedName, node.exprName);
51738
+ }
51739
+ }
51618
51740
  function tryVisitTypeReference(node) {
51619
51741
  if (canReuseTypeNode(context, node)) {
51620
51742
  const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
@@ -51748,13 +51870,13 @@ function createTypeChecker(host) {
51748
51870
  visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
51749
51871
  );
51750
51872
  }
51751
- if (isIndexedAccessTypeNode(node) && isTypeReferenceNode(node.objectType)) {
51752
- const objectType = tryVisitTypeReference(node.objectType);
51753
- if (!objectType) {
51873
+ if (isIndexedAccessTypeNode(node)) {
51874
+ const result = tryVisitIndexedAccess(node);
51875
+ if (!result) {
51754
51876
  hadError = true;
51755
51877
  return node;
51756
51878
  }
51757
- return factory.updateIndexedAccessTypeNode(node, objectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51879
+ return result;
51758
51880
  }
51759
51881
  if (isTypeReferenceNode(node)) {
51760
51882
  const result = tryVisitTypeReference(node);
@@ -51797,25 +51919,12 @@ function createTypeChecker(host) {
51797
51919
  return visited;
51798
51920
  }
51799
51921
  if (isTypeQueryNode(node)) {
51800
- const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51801
- if (introducesError) {
51802
- const serializedName = serializeTypeName(
51803
- context,
51804
- node.exprName,
51805
- /*isTypeOf*/
51806
- true
51807
- );
51808
- if (serializedName) {
51809
- return setTextRange2(context, serializedName, node.exprName);
51810
- }
51922
+ const result = tryVisitTypeQuery(node);
51923
+ if (!result) {
51811
51924
  hadError = true;
51812
51925
  return node;
51813
51926
  }
51814
- return factory.updateTypeQueryNode(
51815
- node,
51816
- exprName,
51817
- visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51818
- );
51927
+ return result;
51819
51928
  }
51820
51929
  if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
51821
51930
  const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
@@ -51880,14 +51989,12 @@ function createTypeChecker(host) {
51880
51989
  return node;
51881
51990
  }
51882
51991
  } else if (node.operator === 143 /* KeyOfKeyword */) {
51883
- if (isTypeReferenceNode(node.type)) {
51884
- const type = tryVisitTypeReference(node.type);
51885
- if (!type) {
51886
- hadError = true;
51887
- return node;
51888
- }
51889
- return factory.updateTypeOperatorNode(node, type);
51992
+ const result = tryVisitKeyOf(node);
51993
+ if (!result) {
51994
+ hadError = true;
51995
+ return node;
51890
51996
  }
51997
+ return result;
51891
51998
  }
51892
51999
  }
51893
52000
  return visitEachChild2(node, visitExistingNodeTreeSymbols);
@@ -52127,9 +52234,10 @@ function createTypeChecker(host) {
52127
52234
  if (index >= 0) {
52128
52235
  const exportDecl = statements[index];
52129
52236
  const replacements = mapDefined(exportDecl.exportClause.elements, (e) => {
52130
- if (!e.propertyName) {
52237
+ if (!e.propertyName && e.name.kind !== 11 /* StringLiteral */) {
52238
+ const name = e.name;
52131
52239
  const indices = indicesOf(statements);
52132
- const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], e.name));
52240
+ const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], name));
52133
52241
  if (length(associatedIndices) && every(associatedIndices, (i) => canHaveExportModifier(statements[i]))) {
52134
52242
  for (const index2 of associatedIndices) {
52135
52243
  statements[index2] = addExportModifier(statements[index2]);
@@ -52763,7 +52871,7 @@ function createTypeChecker(host) {
52763
52871
  function getSomeTargetNameFromDeclarations(declarations) {
52764
52872
  return firstDefined(declarations, (d) => {
52765
52873
  if (isImportSpecifier(d) || isExportSpecifier(d)) {
52766
- return idText(d.propertyName || d.name);
52874
+ return moduleExportNameTextUnescaped(d.propertyName || d.name);
52767
52875
  }
52768
52876
  if (isBinaryExpression(d) || isExportAssignment(d)) {
52769
52877
  const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -52781,7 +52889,7 @@ function createTypeChecker(host) {
52781
52889
  });
52782
52890
  }
52783
52891
  function serializeAsAlias(symbol, localName, modifierFlags) {
52784
- var _a2, _b, _c, _d, _e, _f;
52892
+ var _a2, _b, _c, _d, _e;
52785
52893
  const node = getDeclarationOfAliasSymbol(symbol);
52786
52894
  if (!node) return Debug.fail();
52787
52895
  const target = getMergedSymbol(getTargetOfAliasDeclaration(
@@ -52979,8 +53087,11 @@ function createTypeChecker(host) {
52979
53087
  }
52980
53088
  case 281 /* ExportSpecifier */:
52981
53089
  const specifier = node.parent.parent.moduleSpecifier;
52982
- if (specifier && ((_f = node.propertyName) == null ? void 0 : _f.escapedText) === "default" /* Default */) {
52983
- verbatimTargetName = "default" /* Default */;
53090
+ if (specifier) {
53091
+ const propertyName = node.propertyName;
53092
+ if (propertyName && moduleExportNameIsDefault(propertyName)) {
53093
+ verbatimTargetName = "default" /* Default */;
53094
+ }
52984
53095
  }
52985
53096
  serializeExportSpecifier(
52986
53097
  unescapeLeadingUnderscores(symbol.escapedName),
@@ -53693,7 +53804,7 @@ function createTypeChecker(host) {
53693
53804
  }
53694
53805
  function collectLinkedAliases(node, setVisibility) {
53695
53806
  let exportSymbol;
53696
- if (node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53807
+ if (node.kind !== 11 /* StringLiteral */ && node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53697
53808
  exportSymbol = resolveName(
53698
53809
  node,
53699
53810
  node,
@@ -69266,9 +69377,10 @@ function createTypeChecker(host) {
69266
69377
  return;
69267
69378
  case 281 /* ExportSpecifier */:
69268
69379
  const exportDeclaration = node.parent.parent;
69269
- if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
69380
+ const name = node.propertyName || node.name;
69381
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier && name.kind !== 11 /* StringLiteral */) {
69270
69382
  const symbol = resolveEntityName(
69271
- node.propertyName || node.name,
69383
+ name,
69272
69384
  111551 /* Value */,
69273
69385
  /*ignoreErrors*/
69274
69386
  true,
@@ -69562,6 +69674,9 @@ function createTypeChecker(host) {
69562
69674
  function markExportSpecifierAliasReferenced(location) {
69563
69675
  if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) {
69564
69676
  const exportedName = location.propertyName || location.name;
69677
+ if (exportedName.kind === 11 /* StringLiteral */) {
69678
+ return;
69679
+ }
69565
69680
  const symbol = resolveName(
69566
69681
  exportedName,
69567
69682
  exportedName.escapedText,
@@ -69576,7 +69691,7 @@ function createTypeChecker(host) {
69576
69691
  const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
69577
69692
  if (!target || getSymbolFlags(target) & 111551 /* Value */) {
69578
69693
  markExportAsReferenced(location);
69579
- markIdentifierAliasReferenced(location.propertyName || location.name);
69694
+ markIdentifierAliasReferenced(exportedName);
69580
69695
  }
69581
69696
  }
69582
69697
  return;
@@ -83172,6 +83287,16 @@ function createTypeChecker(host) {
83172
83287
  }
83173
83288
  return true;
83174
83289
  }
83290
+ function checkModuleExportName(name, allowStringLiteral = true) {
83291
+ if (name === void 0 || name.kind !== 11 /* StringLiteral */) {
83292
+ return;
83293
+ }
83294
+ if (!allowStringLiteral) {
83295
+ grammarErrorOnNode(name, Diagnostics.Identifier_expected);
83296
+ } else if (moduleKind === 5 /* ES2015 */ || moduleKind === 6 /* ES2020 */) {
83297
+ grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020);
83298
+ }
83299
+ }
83175
83300
  function checkAliasSymbol(node) {
83176
83301
  var _a, _b, _c, _d;
83177
83302
  let symbol = getSymbolOfDeclaration(node);
@@ -83183,7 +83308,7 @@ function createTypeChecker(host) {
83183
83308
  Debug.assert(node.kind !== 280 /* NamespaceExport */);
83184
83309
  if (node.kind === 281 /* ExportSpecifier */) {
83185
83310
  const diag2 = error(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
83186
- const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get((node.propertyName || node.name).escapedText);
83311
+ const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get(moduleExportNameTextEscaped(node.propertyName || node.name));
83187
83312
  if (alreadyExportedSymbol === target) {
83188
83313
  const exportingDeclaration = (_c = alreadyExportedSymbol.declarations) == null ? void 0 : _c.find(isJSDocNode);
83189
83314
  if (exportingDeclaration) {
@@ -83238,7 +83363,7 @@ function createTypeChecker(host) {
83238
83363
  if (compilerOptions.verbatimModuleSyntax) {
83239
83364
  Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name");
83240
83365
  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;
83241
- const name = idText(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83366
+ const name = moduleExportNameTextUnescaped(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83242
83367
  addTypeOnlyDeclarationRelatedInfo(
83243
83368
  error(node, message, name),
83244
83369
  isType ? void 0 : typeOnlyAlias,
@@ -83252,7 +83377,7 @@ function createTypeChecker(host) {
83252
83377
  }
83253
83378
  case 281 /* ExportSpecifier */: {
83254
83379
  if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) {
83255
- const name = idText(node.propertyName || node.name);
83380
+ const name = moduleExportNameTextUnescaped(node.propertyName || node.name);
83256
83381
  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);
83257
83382
  addTypeOnlyDeclarationRelatedInfo(diagnostic, isType ? void 0 : typeOnlyAlias, name);
83258
83383
  break;
@@ -83302,8 +83427,11 @@ function createTypeChecker(host) {
83302
83427
  function checkImportBinding(node) {
83303
83428
  checkCollisionsForDeclarationName(node, node.name);
83304
83429
  checkAliasSymbol(node);
83305
- if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83306
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83430
+ if (node.kind === 276 /* ImportSpecifier */) {
83431
+ checkModuleExportName(node.propertyName);
83432
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83433
+ checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83434
+ }
83307
83435
  }
83308
83436
  }
83309
83437
  function checkImportAttributes(declaration) {
@@ -83424,6 +83552,7 @@ function createTypeChecker(host) {
83424
83552
  error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
83425
83553
  } else if (node.exportClause) {
83426
83554
  checkAliasSymbol(node.exportClause);
83555
+ checkModuleExportName(node.exportClause.name);
83427
83556
  }
83428
83557
  if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83429
83558
  if (node.exportClause) {
@@ -83454,6 +83583,9 @@ function createTypeChecker(host) {
83454
83583
  }
83455
83584
  function checkExportSpecifier(node) {
83456
83585
  checkAliasSymbol(node);
83586
+ const hasModuleSpecifier = node.parent.parent.moduleSpecifier !== void 0;
83587
+ checkModuleExportName(node.propertyName, hasModuleSpecifier);
83588
+ checkModuleExportName(node.name);
83457
83589
  if (getEmitDeclarations(compilerOptions)) {
83458
83590
  collectLinkedAliases(
83459
83591
  node.propertyName || node.name,
@@ -83461,8 +83593,11 @@ function createTypeChecker(host) {
83461
83593
  true
83462
83594
  );
83463
83595
  }
83464
- if (!node.parent.parent.moduleSpecifier) {
83596
+ if (!hasModuleSpecifier) {
83465
83597
  const exportedName = node.propertyName || node.name;
83598
+ if (exportedName.kind === 11 /* StringLiteral */) {
83599
+ return;
83600
+ }
83466
83601
  const symbol = resolveName(
83467
83602
  exportedName,
83468
83603
  exportedName.escapedText,
@@ -83478,7 +83613,7 @@ function createTypeChecker(host) {
83478
83613
  markLinkedReferences(node, 7 /* ExportSpecifier */);
83479
83614
  }
83480
83615
  } else {
83481
- if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
83616
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
83482
83617
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83483
83618
  }
83484
83619
  }
@@ -84633,7 +84768,11 @@ function createTypeChecker(host) {
84633
84768
  }
84634
84769
  function getExportSpecifierLocalTargetSymbol(node) {
84635
84770
  if (isExportSpecifier(node)) {
84636
- return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84771
+ const name = node.propertyName || node.name;
84772
+ return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : name.kind === 11 /* StringLiteral */ ? void 0 : (
84773
+ // Skip for invalid syntax like this: export { "x" }
84774
+ resolveEntityName(name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)
84775
+ );
84637
84776
  } else {
84638
84777
  return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84639
84778
  }
@@ -85604,7 +85743,8 @@ function createTypeChecker(host) {
85604
85743
  resolveExternalModuleSymbol(sym);
85605
85744
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
85606
85745
  },
85607
- isImportRequiredByAugmentation
85746
+ isImportRequiredByAugmentation,
85747
+ isDefinitelyReferenceToGlobalSymbolObject
85608
85748
  };
85609
85749
  function isImportRequiredByAugmentation(node) {
85610
85750
  const file = getSourceFileOfNode(node);
@@ -87443,7 +87583,7 @@ function isDeclarationNameOrImportPropertyName(name) {
87443
87583
  switch (name.parent.kind) {
87444
87584
  case 276 /* ImportSpecifier */:
87445
87585
  case 281 /* ExportSpecifier */:
87446
- return isIdentifier(name);
87586
+ return isIdentifier(name) || name.kind === 11 /* StringLiteral */;
87447
87587
  default:
87448
87588
  return isDeclarationName(name);
87449
87589
  }
@@ -88688,7 +88828,7 @@ var visitEachChildTable = {
88688
88828
  return context.factory.updateImportSpecifier(
88689
88829
  node,
88690
88830
  node.isTypeOnly,
88691
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88831
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88692
88832
  Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88693
88833
  );
88694
88834
  },
@@ -88719,8 +88859,8 @@ var visitEachChildTable = {
88719
88859
  return context.factory.updateExportSpecifier(
88720
88860
  node,
88721
88861
  node.isTypeOnly,
88722
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88723
- Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88862
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88863
+ Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName))
88724
88864
  );
88725
88865
  },
88726
88866
  // Module references
@@ -89264,7 +89404,7 @@ function containsDefaultReference(node) {
89264
89404
  return some(node.elements, isNamedDefaultReference);
89265
89405
  }
89266
89406
  function isNamedDefaultReference(e) {
89267
- return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
89407
+ return moduleExportNameIsDefault(e.propertyName || e.name);
89268
89408
  }
89269
89409
  function chainBundle(context, transformSourceFile) {
89270
89410
  return transformSourceFileOrBundle;
@@ -89340,9 +89480,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89340
89480
  hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
89341
89481
  } else {
89342
89482
  const name = node.exportClause.name;
89343
- if (!uniqueExports.get(idText(name))) {
89483
+ const nameText = moduleExportNameTextUnescaped(name);
89484
+ if (!uniqueExports.get(nameText)) {
89344
89485
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89345
- uniqueExports.set(idText(name), true);
89486
+ uniqueExports.set(nameText, true);
89346
89487
  exportedNames = append(exportedNames, name);
89347
89488
  }
89348
89489
  hasImportStar = true;
@@ -89400,20 +89541,23 @@ function collectExternalModuleInfo(context, sourceFile) {
89400
89541
  return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, exportedFunctions, externalHelpersImportDeclaration };
89401
89542
  function addExportedNamesForExportDeclaration(node) {
89402
89543
  for (const specifier of cast(node.exportClause, isNamedExports).elements) {
89403
- if (!uniqueExports.get(idText(specifier.name))) {
89544
+ const specifierNameText = moduleExportNameTextUnescaped(specifier.name);
89545
+ if (!uniqueExports.get(specifierNameText)) {
89404
89546
  const name = specifier.propertyName || specifier.name;
89405
- if (!node.moduleSpecifier) {
89406
- exportSpecifiers.add(name, specifier);
89407
- }
89408
- const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89409
- if (decl) {
89410
- if (decl.kind === 262 /* FunctionDeclaration */) {
89411
- addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
89412
- continue;
89547
+ if (name.kind !== 11 /* StringLiteral */) {
89548
+ if (!node.moduleSpecifier) {
89549
+ exportSpecifiers.add(name, specifier);
89550
+ }
89551
+ const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89552
+ if (decl) {
89553
+ if (decl.kind === 262 /* FunctionDeclaration */) {
89554
+ addExportedFunctionDeclaration(decl, specifier.name, moduleExportNameIsDefault(specifier.name));
89555
+ continue;
89556
+ }
89557
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89413
89558
  }
89414
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89415
89559
  }
89416
- uniqueExports.set(idText(specifier.name), true);
89560
+ uniqueExports.set(specifierNameText, true);
89417
89561
  exportedNames = append(exportedNames, specifier.name);
89418
89562
  }
89419
89563
  }
@@ -89427,9 +89571,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89427
89571
  }
89428
89572
  } else {
89429
89573
  name ?? (name = node.name);
89430
- if (!uniqueExports.get(idText(name))) {
89574
+ const nameText = moduleExportNameTextUnescaped(name);
89575
+ if (!uniqueExports.get(nameText)) {
89431
89576
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89432
- uniqueExports.set(idText(name), true);
89577
+ uniqueExports.set(nameText, true);
89433
89578
  }
89434
89579
  }
89435
89580
  }
@@ -106706,7 +106851,7 @@ function transformModule(context) {
106706
106851
  factory2.createExpressionStatement(
106707
106852
  reduceLeft(
106708
106853
  currentModuleInfo.exportedNames.slice(i, i + chunkSize),
106709
- (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev),
106854
+ (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),
106710
106855
  factory2.createVoidZero()
106711
106856
  )
106712
106857
  )
@@ -107029,7 +107174,10 @@ function transformModule(context) {
107029
107174
  append(statements, createUnderscoreUnderscoreESModule());
107030
107175
  }
107031
107176
  if (some(currentModuleInfo.exportedNames)) {
107032
- append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
107177
+ append(
107178
+ statements,
107179
+ 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()))
107180
+ );
107033
107181
  }
107034
107182
  for (const f of currentModuleInfo.exportedFunctions) {
107035
107183
  appendExportsOfHoistedDeclaration(statements, f);
@@ -107900,17 +108048,16 @@ function transformModule(context) {
107900
108048
  );
107901
108049
  }
107902
108050
  for (const specifier of node.exportClause.elements) {
107903
- const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && idText(specifier.propertyName || specifier.name) === "default";
107904
- const exportedValue = factory2.createPropertyAccessExpression(
107905
- exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName,
107906
- specifier.propertyName || specifier.name
107907
- );
108051
+ const specifierName = specifier.propertyName || specifier.name;
108052
+ const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && moduleExportNameIsDefault(specifierName);
108053
+ const target = exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName;
108054
+ const exportedValue = specifierName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, specifierName) : factory2.createPropertyAccessExpression(target, specifierName);
107908
108055
  statements.push(
107909
108056
  setOriginalNode(
107910
108057
  setTextRange(
107911
108058
  factory2.createExpressionStatement(
107912
108059
  createExportExpression(
107913
- factory2.getExportName(specifier),
108060
+ specifier.name.kind === 11 /* StringLiteral */ ? factory2.cloneNode(specifier.name) : factory2.getExportName(specifier),
107914
108061
  exportedValue,
107915
108062
  /*location*/
107916
108063
  void 0,
@@ -107935,7 +108082,7 @@ function transformModule(context) {
107935
108082
  factory2.cloneNode(node.exportClause.name),
107936
108083
  getHelperExpressionForExport(
107937
108084
  node,
107938
- moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
108085
+ moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : node.exportClause.name.kind === 11 /* StringLiteral */ ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
107939
108086
  )
107940
108087
  )
107941
108088
  ),
@@ -108265,10 +108412,13 @@ function transformModule(context) {
108265
108412
  return statements;
108266
108413
  }
108267
108414
  function appendExportStatement(statements, seen, exportName, expression, location, allowComments, liveBinding) {
108268
- if (!seen.has(exportName)) {
108415
+ if (exportName.kind !== 11 /* StringLiteral */) {
108416
+ if (seen.has(exportName)) {
108417
+ return statements;
108418
+ }
108269
108419
  seen.set(exportName, true);
108270
- statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108271
108420
  }
108421
+ statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108272
108422
  return statements;
108273
108423
  }
108274
108424
  function createUnderscoreUnderscoreESModule() {
@@ -108338,7 +108488,10 @@ function transformModule(context) {
108338
108488
  ])
108339
108489
  ]
108340
108490
  ) : factory2.createAssignment(
108341
- factory2.createPropertyAccessExpression(
108491
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(
108492
+ factory2.createIdentifier("exports"),
108493
+ factory2.cloneNode(name)
108494
+ ) : factory2.createPropertyAccessExpression(
108342
108495
  factory2.createIdentifier("exports"),
108343
108496
  factory2.cloneNode(name)
108344
108497
  ),
@@ -108474,11 +108627,9 @@ function transformModule(context) {
108474
108627
  );
108475
108628
  } else if (isImportSpecifier(importDeclaration)) {
108476
108629
  const name = importDeclaration.propertyName || importDeclaration.name;
108630
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
108477
108631
  return setTextRange(
108478
- factory2.createPropertyAccessExpression(
108479
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
108480
- factory2.cloneNode(name)
108481
- ),
108632
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(name)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(name)),
108482
108633
  /*location*/
108483
108634
  node
108484
108635
  );
@@ -108766,7 +108917,7 @@ function transformSystemModule(context) {
108766
108917
  const exportedNames = [];
108767
108918
  if (moduleInfo.exportedNames) {
108768
108919
  for (const exportedLocalName of moduleInfo.exportedNames) {
108769
- if (exportedLocalName.escapedText === "default") {
108920
+ if (moduleExportNameIsDefault(exportedLocalName)) {
108770
108921
  continue;
108771
108922
  }
108772
108923
  exportedNames.push(
@@ -108944,10 +109095,10 @@ function transformSystemModule(context) {
108944
109095
  for (const e of entry.exportClause.elements) {
108945
109096
  properties.push(
108946
109097
  factory2.createPropertyAssignment(
108947
- factory2.createStringLiteral(idText(e.name)),
109098
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.name)),
108948
109099
  factory2.createElementAccessExpression(
108949
109100
  parameterName,
108950
- factory2.createStringLiteral(idText(e.propertyName || e.name))
109101
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.propertyName || e.name))
108951
109102
  )
108952
109103
  )
108953
109104
  );
@@ -108974,7 +109125,7 @@ function transformSystemModule(context) {
108974
109125
  /*typeArguments*/
108975
109126
  void 0,
108976
109127
  [
108977
- factory2.createStringLiteral(idText(entry.exportClause.name)),
109128
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(entry.exportClause.name)),
108978
109129
  parameterName
108979
109130
  ]
108980
109131
  )
@@ -109314,7 +109465,7 @@ function transformSystemModule(context) {
109314
109465
  const exportSpecifiers = moduleInfo.exportSpecifiers.get(name);
109315
109466
  if (exportSpecifiers) {
109316
109467
  for (const exportSpecifier of exportSpecifiers) {
109317
- if (exportSpecifier.name.escapedText !== excludeName) {
109468
+ if (moduleExportNameTextUnescaped(exportSpecifier.name) !== excludeName) {
109318
109469
  statements = appendExportStatement(statements, exportSpecifier.name, name);
109319
109470
  }
109320
109471
  }
@@ -109735,13 +109886,12 @@ function transformSystemModule(context) {
109735
109886
  node
109736
109887
  );
109737
109888
  } else if (isImportSpecifier(importDeclaration)) {
109889
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109890
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109738
109891
  return setTextRange(
109739
109892
  factory2.createPropertyAssignment(
109740
109893
  factory2.cloneNode(name),
109741
- factory2.createPropertyAccessExpression(
109742
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109743
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109744
- )
109894
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName))
109745
109895
  ),
109746
109896
  /*location*/
109747
109897
  node
@@ -109784,11 +109934,10 @@ function transformSystemModule(context) {
109784
109934
  node
109785
109935
  );
109786
109936
  } else if (isImportSpecifier(importDeclaration)) {
109937
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109938
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109787
109939
  return setTextRange(
109788
- factory2.createPropertyAccessExpression(
109789
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109790
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109791
- ),
109940
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName)),
109792
109941
  /*location*/
109793
109942
  node
109794
109943
  );
@@ -111379,15 +111528,17 @@ function transformDeclarations(context) {
111379
111528
  if (isDeclarationAndNotVisible(input)) return;
111380
111529
  if (hasDynamicName(input)) {
111381
111530
  if (isolatedDeclarations) {
111382
- if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111383
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111384
- return;
111385
- } else if (
111386
- // Type declarations just need to double-check that the input computed name is an entity name expression
111387
- (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111388
- ) {
111389
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111390
- return;
111531
+ if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
111532
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111533
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111534
+ return;
111535
+ } else if (
111536
+ // Type declarations just need to double-check that the input computed name is an entity name expression
111537
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111538
+ ) {
111539
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111540
+ return;
111541
+ }
111391
111542
  }
111392
111543
  } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
111393
111544
  return;
@@ -112755,16 +112906,16 @@ function isBuildInfoFile(file) {
112755
112906
  function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit = false, onlyBuildInfo, includeBuildInfo) {
112756
112907
  const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
112757
112908
  const options = host.getCompilerOptions();
112758
- if (options.outFile) {
112759
- if (sourceFiles.length) {
112760
- const bundle = factory.createBundle(sourceFiles);
112761
- const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112762
- if (result) {
112763
- return result;
112909
+ if (!onlyBuildInfo) {
112910
+ if (options.outFile) {
112911
+ if (sourceFiles.length) {
112912
+ const bundle = factory.createBundle(sourceFiles);
112913
+ const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112914
+ if (result) {
112915
+ return result;
112916
+ }
112764
112917
  }
112765
- }
112766
- } else {
112767
- if (!onlyBuildInfo) {
112918
+ } else {
112768
112919
  for (const sourceFile of sourceFiles) {
112769
112920
  const result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
112770
112921
  if (result) {
@@ -112772,14 +112923,14 @@ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDt
112772
112923
  }
112773
112924
  }
112774
112925
  }
112775
- if (includeBuildInfo) {
112776
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112777
- if (buildInfoPath) return action(
112778
- { buildInfoPath },
112779
- /*sourceFileOrBundle*/
112780
- void 0
112781
- );
112782
- }
112926
+ }
112927
+ if (includeBuildInfo) {
112928
+ const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112929
+ if (buildInfoPath) return action(
112930
+ { buildInfoPath },
112931
+ /*sourceFileOrBundle*/
112932
+ void 0
112933
+ );
112783
112934
  }
112784
112935
  }
112785
112936
  function getTsBuildInfoEmitOutputFilePath(options) {
@@ -112808,8 +112959,7 @@ function getOutputPathsForBundle(options, forceDtsPaths) {
112808
112959
  const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
112809
112960
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) ? removeFileExtension(outPath) + ".d.ts" /* Dts */ : void 0;
112810
112961
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112811
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112812
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath };
112962
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112813
112963
  }
112814
112964
  function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112815
112965
  const options = host.getCompilerOptions();
@@ -112823,7 +112973,7 @@ function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112823
112973
  const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? void 0 : getSourceMapFilePath(jsFilePath, options);
112824
112974
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) && !isJsonFile ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : void 0;
112825
112975
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112826
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: void 0 };
112976
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112827
112977
  }
112828
112978
  }
112829
112979
  function getSourceMapFilePath(jsFilePath, options) {
@@ -112872,7 +113022,7 @@ function createAddOutput() {
112872
113022
  }
112873
113023
  }
112874
113024
  function getSingleOutputFileNames(configFile, addOutput) {
112875
- const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(
113025
+ const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(
112876
113026
  configFile.options,
112877
113027
  /*forceDtsPaths*/
112878
113028
  false
@@ -112881,7 +113031,6 @@ function getSingleOutputFileNames(configFile, addOutput) {
112881
113031
  addOutput(sourceMapFilePath);
112882
113032
  addOutput(declarationFilePath);
112883
113033
  addOutput(declarationMapPath);
112884
- addOutput(buildInfoPath);
112885
113034
  }
112886
113035
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2) {
112887
113036
  if (isDeclarationFileName(inputFileName)) return;
@@ -112932,8 +113081,8 @@ function getAllProjectOutputs(configFile, ignoreCase) {
112932
113081
  for (const inputFileName of configFile.fileNames) {
112933
113082
  getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2);
112934
113083
  }
112935
- addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112936
113084
  }
113085
+ addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112937
113086
  return getOutputs();
112938
113087
  }
112939
113088
  function getFirstProjectOutput(configFile, ignoreCase) {
@@ -112962,7 +113111,7 @@ function getFirstProjectOutput(configFile, ignoreCase) {
112962
113111
  function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
112963
113112
  return !!forceDtsEmit && !!emitOnly;
112964
113113
  }
112965
- function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
113114
+ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit, skipBuildInfo) {
112966
113115
  var compilerOptions = host.getCompilerOptions();
112967
113116
  var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
112968
113117
  var emittedFilesList = compilerOptions.listEmittedFiles ? [] : void 0;
@@ -112978,7 +113127,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
112978
113127
  getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit),
112979
113128
  forceDtsEmit,
112980
113129
  onlyBuildInfo,
112981
- !targetSourceFile
113130
+ !targetSourceFile && !skipBuildInfo
112982
113131
  );
112983
113132
  exit();
112984
113133
  return {
@@ -113000,15 +113149,12 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113000
113149
  (_f = tracing) == null ? void 0 : _f.pop();
113001
113150
  }
113002
113151
  function emitBuildInfo(buildInfoPath) {
113003
- if (!buildInfoPath || targetSourceFile || emitSkipped) return;
113152
+ if (!buildInfoPath || targetSourceFile) return;
113004
113153
  if (host.isEmitBlocked(buildInfoPath)) {
113005
113154
  emitSkipped = true;
113006
113155
  return;
113007
113156
  }
113008
- const buildInfo = host.getBuildInfo() || createBuildInfo(
113009
- /*program*/
113010
- void 0
113011
- );
113157
+ const buildInfo = host.getBuildInfo() || { version };
113012
113158
  writeFile(
113013
113159
  host,
113014
113160
  emitterDiagnostics,
@@ -113291,9 +113437,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113291
113437
  return encodeURI(sourceMapFile);
113292
113438
  }
113293
113439
  }
113294
- function createBuildInfo(program) {
113295
- return { program, version };
113296
- }
113297
113440
  function getBuildInfoText(buildInfo) {
113298
113441
  return JSON.stringify(buildInfo);
113299
113442
  }
@@ -113338,7 +113481,8 @@ var notImplementedResolver = {
113338
113481
  getJsxFragmentFactoryEntity: notImplemented,
113339
113482
  isBindingCapturedByNode: notImplemented,
113340
113483
  getDeclarationStatementsForSourceFile: notImplemented,
113341
- isImportRequiredByAugmentation: notImplemented
113484
+ isImportRequiredByAugmentation: notImplemented,
113485
+ isDefinitelyReferenceToGlobalSymbolObject: notImplemented
113342
113486
  };
113343
113487
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
113344
113488
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -118073,7 +118217,7 @@ function isIgnoredFileFromWildCardWatching({
118073
118217
  }
118074
118218
  return false;
118075
118219
  function hasSourceFile(file) {
118076
- return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.getState().fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118220
+ return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.state.fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118077
118221
  }
118078
118222
  function isSupportedScriptKind() {
118079
118223
  if (!getScriptKind) return false;
@@ -118094,9 +118238,6 @@ function isIgnoredFileFromWildCardWatching({
118094
118238
  }
118095
118239
  }
118096
118240
  }
118097
- function isBuilderProgram(program) {
118098
- return !!program.getState;
118099
- }
118100
118241
  function isEmittedFileOfProgram(program, file) {
118101
118242
  if (!program) {
118102
118243
  return false;
@@ -119953,7 +120094,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119953
120094
  }
119954
120095
  function emitBuildInfo(writeFileCallback) {
119955
120096
  var _a2, _b2;
119956
- Debug.assert(!options.outFile);
119957
120097
  (_a2 = tracing) == null ? void 0 : _a2.push(
119958
120098
  tracing.Phase.Emit,
119959
120099
  "emitBuildInfo",
@@ -120008,7 +120148,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120008
120148
  function getTypeChecker() {
120009
120149
  return typeChecker || (typeChecker = createTypeChecker(program));
120010
120150
  }
120011
- function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit) {
120151
+ function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit, skipBuildInfo) {
120012
120152
  var _a2, _b2;
120013
120153
  (_a2 = tracing) == null ? void 0 : _a2.push(
120014
120154
  tracing.Phase.Emit,
@@ -120017,14 +120157,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120017
120157
  /*separateBeginAndEnd*/
120018
120158
  true
120019
120159
  );
120020
- const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit));
120160
+ const result = runWithCancellationToken(
120161
+ () => emitWorker(
120162
+ program,
120163
+ sourceFile,
120164
+ writeFileCallback,
120165
+ cancellationToken,
120166
+ emitOnly,
120167
+ transformers,
120168
+ forceDtsEmit,
120169
+ skipBuildInfo
120170
+ )
120171
+ );
120021
120172
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120022
120173
  return result;
120023
120174
  }
120024
120175
  function isEmitBlocked(emitFileName) {
120025
120176
  return hasEmitBlockingDiagnostics.has(toPath3(emitFileName));
120026
120177
  }
120027
- function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit) {
120178
+ function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit, skipBuildInfo) {
120028
120179
  if (!forceDtsEmit) {
120029
120180
  const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
120030
120181
  if (result) return result;
@@ -120046,7 +120197,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120046
120197
  emitOnly,
120047
120198
  /*onlyBuildInfo*/
120048
120199
  false,
120049
- forceDtsEmit
120200
+ forceDtsEmit,
120201
+ skipBuildInfo
120050
120202
  )
120051
120203
  );
120052
120204
  mark("afterEmit");
@@ -122178,7 +122330,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122178
122330
  const options = program.getCompilerOptions();
122179
122331
  if (options.noEmit) {
122180
122332
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
122181
- return sourceFile || options.outFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122333
+ return sourceFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122182
122334
  }
122183
122335
  if (!options.noEmitOnError) return void 0;
122184
122336
  let diagnostics = [
@@ -122196,7 +122348,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122196
122348
  }
122197
122349
  if (!diagnostics.length) return void 0;
122198
122350
  let emittedFiles;
122199
- if (!sourceFile && !options.outFile) {
122351
+ if (!sourceFile) {
122200
122352
  const emitResult = program.emitBuildInfo(writeFile2, cancellationToken);
122201
122353
  if (emitResult.diagnostics) diagnostics = [...diagnostics, ...emitResult.diagnostics];
122202
122354
  emittedFiles = emitResult.emittedFiles;
@@ -122643,6 +122795,13 @@ var BuilderState;
122643
122795
  })(BuilderState || (BuilderState = {}));
122644
122796
 
122645
122797
  // src/compiler/builder.ts
122798
+ function isBuilderProgramStateWithDefinedProgram(state) {
122799
+ return state.program !== void 0;
122800
+ }
122801
+ function toBuilderProgramStateWithDefinedProgram(state) {
122802
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
122803
+ return state;
122804
+ }
122646
122805
  function getBuilderFileEmit(options) {
122647
122806
  let result = 1 /* Js */;
122648
122807
  if (options.sourceMap) result = result | 2 /* JsMap */;
@@ -122678,17 +122837,17 @@ function createBuilderProgramState(newProgram, oldState) {
122678
122837
  const compilerOptions = newProgram.getCompilerOptions();
122679
122838
  state.compilerOptions = compilerOptions;
122680
122839
  const outFilePath = compilerOptions.outFile;
122681
- if (!outFilePath) {
122682
- state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122683
- } else if (compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122840
+ state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122841
+ if (outFilePath && compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122684
122842
  state.outSignature = oldState.outSignature && getEmitSignatureFromOldSignature(compilerOptions, oldState.compilerOptions, oldState.outSignature);
122685
122843
  }
122686
122844
  state.changedFilesSet = /* @__PURE__ */ new Set();
122687
122845
  state.latestChangedDtsFile = compilerOptions.composite ? oldState == null ? void 0 : oldState.latestChangedDtsFile : void 0;
122688
122846
  const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState);
122689
122847
  const oldCompilerOptions = useOldState ? oldState.compilerOptions : void 0;
122690
- const canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122848
+ let canCopySemanticDiagnostics = useOldState && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122691
122849
  const canCopyEmitSignatures = compilerOptions.composite && (oldState == null ? void 0 : oldState.emitSignatures) && !outFilePath && !compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122850
+ let canCopyEmitDiagnostics = true;
122692
122851
  if (useOldState) {
122693
122852
  (_a = oldState.changedFilesSet) == null ? void 0 : _a.forEach((value) => state.changedFilesSet.add(value));
122694
122853
  if (!outFilePath && ((_b = oldState.affectedFilesPendingEmit) == null ? void 0 : _b.size)) {
@@ -122696,6 +122855,10 @@ function createBuilderProgramState(newProgram, oldState) {
122696
122855
  state.seenAffectedFiles = /* @__PURE__ */ new Set();
122697
122856
  }
122698
122857
  state.programEmitPending = oldState.programEmitPending;
122858
+ if (outFilePath && state.changedFilesSet.size) {
122859
+ canCopySemanticDiagnostics = false;
122860
+ canCopyEmitDiagnostics = false;
122861
+ }
122699
122862
  } else {
122700
122863
  state.buildInfoEmitPending = true;
122701
122864
  }
@@ -122713,10 +122876,10 @@ function createBuilderProgramState(newProgram, oldState) {
122713
122876
  oldInfo.impliedFormat !== info.impliedFormat || // Referenced files changed
122714
122877
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) || // Referenced file was deleted in the new program
122715
122878
  newReferences && forEachKey(newReferences, (path) => !state.fileInfos.has(path) && oldState.fileInfos.has(path))) {
122716
- addFileToChangeSet(state, sourceFilePath);
122879
+ addFileToChangeSet(sourceFilePath);
122717
122880
  } else {
122718
122881
  const sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
122719
- const emitDiagnostics = (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath);
122882
+ const emitDiagnostics = canCopyEmitDiagnostics ? (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath) : void 0;
122720
122883
  if (emitDiagnostics) {
122721
122884
  (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
122722
122885
  sourceFilePath,
@@ -122745,16 +122908,16 @@ function createBuilderProgramState(newProgram, oldState) {
122745
122908
  });
122746
122909
  if (useOldState && forEachEntry(oldState.fileInfos, (info, sourceFilePath) => {
122747
122910
  if (state.fileInfos.has(sourceFilePath)) return false;
122748
- if (outFilePath || info.affectsGlobalScope) return true;
122911
+ if (info.affectsGlobalScope) return true;
122749
122912
  state.buildInfoEmitPending = true;
122750
- return false;
122913
+ return !!outFilePath;
122751
122914
  })) {
122752
122915
  BuilderState.getAllFilesExcludingDefaultLibraryFile(
122753
122916
  state,
122754
122917
  newProgram,
122755
122918
  /*firstSourceFile*/
122756
122919
  void 0
122757
- ).forEach((file) => addFileToChangeSet(state, file.resolvedPath));
122920
+ ).forEach((file) => addFileToChangeSet(file.resolvedPath));
122758
122921
  } else if (oldCompilerOptions) {
122759
122922
  const pendingEmitKind = compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions) ? getBuilderFileEmit(compilerOptions) : getPendingEmitKind(compilerOptions, oldCompilerOptions);
122760
122923
  if (pendingEmitKind !== 0 /* None */) {
@@ -122770,18 +122933,25 @@ function createBuilderProgramState(newProgram, oldState) {
122770
122933
  });
122771
122934
  Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
122772
122935
  state.seenAffectedFiles = state.seenAffectedFiles || /* @__PURE__ */ new Set();
122773
- state.buildInfoEmitPending = true;
122774
- } else {
122936
+ } else if (!state.changedFilesSet.size) {
122775
122937
  state.programEmitPending = state.programEmitPending ? state.programEmitPending | pendingEmitKind : pendingEmitKind;
122776
122938
  }
122939
+ state.buildInfoEmitPending = true;
122777
122940
  }
122778
122941
  }
122779
122942
  return state;
122780
- }
122781
- function addFileToChangeSet(state, path) {
122782
- state.changedFilesSet.add(path);
122783
- state.buildInfoEmitPending = true;
122784
- state.programEmitPending = void 0;
122943
+ function addFileToChangeSet(path) {
122944
+ state.changedFilesSet.add(path);
122945
+ if (outFilePath) {
122946
+ canCopySemanticDiagnostics = false;
122947
+ canCopyEmitDiagnostics = false;
122948
+ state.semanticDiagnosticsFromOldState = void 0;
122949
+ state.semanticDiagnosticsPerFile.clear();
122950
+ state.emitDiagnosticsPerFile = void 0;
122951
+ }
122952
+ state.buildInfoEmitPending = true;
122953
+ state.programEmitPending = void 0;
122954
+ }
122785
122955
  }
122786
122956
  function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature) {
122787
122957
  return !!options.declarationMap === !!oldOptions.declarationMap ? (
@@ -122854,6 +123024,7 @@ function backupBuilderProgramEmitState(state) {
122854
123024
  return {
122855
123025
  affectedFilesPendingEmit: state.affectedFilesPendingEmit && new Map(state.affectedFilesPendingEmit),
122856
123026
  seenEmittedFiles: state.seenEmittedFiles && new Map(state.seenEmittedFiles),
123027
+ seenProgramEmit: state.seenProgramEmit,
122857
123028
  programEmitPending: state.programEmitPending,
122858
123029
  emitSignatures: state.emitSignatures && new Map(state.emitSignatures),
122859
123030
  outSignature: state.outSignature,
@@ -122867,6 +123038,7 @@ function backupBuilderProgramEmitState(state) {
122867
123038
  function restoreBuilderProgramEmitState(state, savedEmitState) {
122868
123039
  state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
122869
123040
  state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
123041
+ state.seenProgramEmit = savedEmitState.seenProgramEmit;
122870
123042
  state.programEmitPending = savedEmitState.programEmitPending;
122871
123043
  state.emitSignatures = savedEmitState.emitSignatures;
122872
123044
  state.outSignature = savedEmitState.outSignature;
@@ -122875,6 +123047,10 @@ function restoreBuilderProgramEmitState(state, savedEmitState) {
122875
123047
  state.buildInfoEmitPending = savedEmitState.buildInfoEmitPending;
122876
123048
  state.emitDiagnosticsPerFile = savedEmitState.emitDiagnosticsPerFile;
122877
123049
  if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet;
123050
+ if (state.compilerOptions.outFile && state.changedFilesSet.size) {
123051
+ state.semanticDiagnosticsPerFile.clear();
123052
+ state.emitDiagnosticsPerFile = void 0;
123053
+ }
122878
123054
  }
122879
123055
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
122880
123056
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
@@ -122890,7 +123066,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122890
123066
  const affectedFile = affectedFiles[affectedFilesIndex];
122891
123067
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
122892
123068
  state.affectedFilesIndex = affectedFilesIndex;
122893
- addToAffectedFilesPendingEmit(state, affectedFile.resolvedPath, getBuilderFileEmit(state.compilerOptions));
123069
+ addToAffectedFilesPendingEmit(
123070
+ state,
123071
+ affectedFile.resolvedPath,
123072
+ getBuilderFileEmit(state.compilerOptions)
123073
+ );
122894
123074
  handleDtsMayChangeOfAffectedFile(
122895
123075
  state,
122896
123076
  affectedFile,
@@ -122910,15 +123090,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122910
123090
  if (nextKey.done) {
122911
123091
  return void 0;
122912
123092
  }
122913
- const program = Debug.checkDefined(state.program);
122914
- const compilerOptions = program.getCompilerOptions();
122915
- if (compilerOptions.outFile) {
122916
- Debug.assert(!state.semanticDiagnosticsPerFile);
122917
- return program;
122918
- }
123093
+ const compilerOptions = state.program.getCompilerOptions();
123094
+ if (compilerOptions.outFile) return state.program;
122919
123095
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
122920
123096
  state,
122921
- program,
123097
+ state.program,
122922
123098
  nextKey.value,
122923
123099
  cancellationToken,
122924
123100
  host
@@ -122929,14 +123105,22 @@ function getNextAffectedFile(state, cancellationToken, host) {
122929
123105
  }
122930
123106
  }
122931
123107
  function clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles) {
122932
- var _a;
122933
- if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size)) return;
122934
- if (!emitOnlyDtsFiles) return state.affectedFilesPendingEmit = void 0;
122935
- state.affectedFilesPendingEmit.forEach((emitKind, path) => {
123108
+ var _a, _b;
123109
+ if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) && !state.programEmitPending) return;
123110
+ if (!emitOnlyDtsFiles) {
123111
+ state.affectedFilesPendingEmit = void 0;
123112
+ state.programEmitPending = void 0;
123113
+ }
123114
+ (_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.forEach((emitKind, path) => {
122936
123115
  const pending = emitKind & 7 /* AllJs */;
122937
123116
  if (!pending) state.affectedFilesPendingEmit.delete(path);
122938
123117
  else state.affectedFilesPendingEmit.set(path, pending);
122939
123118
  });
123119
+ if (state.programEmitPending) {
123120
+ const pending = state.programEmitPending & 7 /* AllJs */;
123121
+ if (!pending) state.programEmitPending = void 0;
123122
+ else state.programEmitPending = pending;
123123
+ }
122940
123124
  }
122941
123125
  function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles) {
122942
123126
  var _a;
@@ -122971,9 +123155,8 @@ function getNextPendingEmitDiagnosticsFile(state) {
122971
123155
  function removeDiagnosticsOfLibraryFiles(state) {
122972
123156
  if (!state.cleanedDiagnosticsOfLibFiles) {
122973
123157
  state.cleanedDiagnosticsOfLibFiles = true;
122974
- const program = Debug.checkDefined(state.program);
122975
- const options = program.getCompilerOptions();
122976
- forEach(program.getSourceFiles(), (f) => program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
123158
+ const options = state.program.getCompilerOptions();
123159
+ forEach(state.program.getSourceFiles(), (f) => state.program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, state.program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
122977
123160
  }
122978
123161
  }
122979
123162
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
@@ -122982,7 +123165,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
122982
123165
  removeDiagnosticsOfLibraryFiles(state);
122983
123166
  BuilderState.updateShapeSignature(
122984
123167
  state,
122985
- Debug.checkDefined(state.program),
123168
+ state.program,
122986
123169
  affectedFile,
122987
123170
  cancellationToken,
122988
123171
  host
@@ -123000,12 +123183,11 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
123000
123183
  function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
123001
123184
  removeSemanticDiagnosticsOf(state, path);
123002
123185
  if (!state.changedFilesSet.has(path)) {
123003
- const program = Debug.checkDefined(state.program);
123004
- const sourceFile = program.getSourceFileByPath(path);
123186
+ const sourceFile = state.program.getSourceFileByPath(path);
123005
123187
  if (sourceFile) {
123006
123188
  BuilderState.updateShapeSignature(
123007
123189
  state,
123008
- program,
123190
+ state.program,
123009
123191
  sourceFile,
123010
123192
  cancellationToken,
123011
123193
  host,
@@ -123013,9 +123195,17 @@ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken,
123013
123195
  true
123014
123196
  );
123015
123197
  if (invalidateJsFiles) {
123016
- addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
123198
+ addToAffectedFilesPendingEmit(
123199
+ state,
123200
+ path,
123201
+ getBuilderFileEmit(state.compilerOptions)
123202
+ );
123017
123203
  } else if (getEmitDeclarations(state.compilerOptions)) {
123018
- addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
123204
+ addToAffectedFilesPendingEmit(
123205
+ state,
123206
+ path,
123207
+ state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */
123208
+ );
123019
123209
  }
123020
123210
  }
123021
123211
  }
@@ -123082,7 +123272,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
123082
123272
  host
123083
123273
  );
123084
123274
  if (isChangedSignature(state, currentPath)) {
123085
- const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
123275
+ const currentSourceFile = state.program.getSourceFileByPath(currentPath);
123086
123276
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
123087
123277
  }
123088
123278
  }
@@ -123128,33 +123318,33 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
123128
123318
  );
123129
123319
  return void 0;
123130
123320
  }
123131
- function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123321
+ function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123132
123322
  return concatenate(
123133
- getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken),
123134
- Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
123323
+ getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
123324
+ state.program.getProgramDiagnostics(sourceFile)
123135
123325
  );
123136
123326
  }
123137
- function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123327
+ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123328
+ semanticDiagnosticsPerFile ?? (semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile);
123138
123329
  const path = sourceFile.resolvedPath;
123139
- if (state.semanticDiagnosticsPerFile) {
123140
- const cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
123141
- if (cachedDiagnostics) {
123142
- return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123143
- }
123144
- }
123145
- const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123146
- if (state.semanticDiagnosticsPerFile) {
123147
- state.semanticDiagnosticsPerFile.set(path, diagnostics);
123330
+ const cachedDiagnostics = semanticDiagnosticsPerFile.get(path);
123331
+ if (cachedDiagnostics) {
123332
+ return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123148
123333
  }
123334
+ const diagnostics = state.program.getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123335
+ semanticDiagnosticsPerFile.set(path, diagnostics);
123149
123336
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123150
123337
  }
123151
- function isProgramBundleEmitBuildInfo(info) {
123338
+ function isIncrementalBundleEmitBuildInfo(info) {
123152
123339
  var _a;
123153
123340
  return !!((_a = info.options) == null ? void 0 : _a.outFile);
123154
123341
  }
123342
+ function isIncrementalBuildInfo(info) {
123343
+ return !!info.fileNames;
123344
+ }
123155
123345
  function getBuildInfo2(state) {
123156
123346
  var _a, _b;
123157
- const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
123347
+ const currentDirectory = state.program.getCurrentDirectory();
123158
123348
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
123159
123349
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
123160
123350
  const fileNames = [];
@@ -123167,12 +123357,15 @@ function getBuildInfo2(state) {
123167
123357
  tryAddRoot(key, fileId);
123168
123358
  return value.impliedFormat ? { version: value.version, impliedFormat: value.impliedFormat, signature: void 0, affectsGlobalScope: void 0 } : value.version;
123169
123359
  });
123170
- const program2 = {
123360
+ return {
123171
123361
  fileNames,
123172
123362
  fileInfos: fileInfos2,
123173
123363
  root,
123174
123364
  resolvedRoot: toResolvedRoot(),
123175
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123365
+ options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123366
+ semanticDiagnosticsPerFile: toIncrementalBuildInfoDiagnostics(),
123367
+ emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123368
+ changeFileSet: toChangeFileSet(),
123176
123369
  outSignature: state.outSignature,
123177
123370
  latestChangedDtsFile,
123178
123371
  pendingEmit: !state.programEmitPending ? void 0 : (
@@ -123181,10 +123374,10 @@ function getBuildInfo2(state) {
123181
123374
  // Pending emit is same as deteremined by compilerOptions
123182
123375
  state.programEmitPending
123183
123376
  )
123184
- )
123377
+ ),
123185
123378
  // Actual value
123379
+ version
123186
123380
  };
123187
- return createBuildInfo(program2);
123188
123381
  }
123189
123382
  let fileIdsList;
123190
123383
  let fileNamesToFileIdListId;
@@ -123239,7 +123432,7 @@ function getBuildInfo2(state) {
123239
123432
  toFileIdListId(state.referencedMap.getValues(key))
123240
123433
  ]);
123241
123434
  }
123242
- const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics();
123435
+ const semanticDiagnosticsPerFile = toIncrementalBuildInfoDiagnostics();
123243
123436
  let affectedFilesPendingEmit;
123244
123437
  if ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.size) {
123245
123438
  const fullEmitForOptions = getBuilderFileEmit(state.compilerOptions);
@@ -123263,29 +123456,22 @@ function getBuildInfo2(state) {
123263
123456
  }
123264
123457
  }
123265
123458
  }
123266
- let changeFileSet;
123267
- if (state.changedFilesSet.size) {
123268
- for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123269
- changeFileSet = append(changeFileSet, toFileId(path));
123270
- }
123271
- }
123272
- const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
123273
- const program = {
123459
+ return {
123274
123460
  fileNames,
123461
+ fileIdsList,
123275
123462
  fileInfos,
123276
123463
  root,
123277
123464
  resolvedRoot: toResolvedRoot(),
123278
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123279
- fileIdsList,
123465
+ options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123280
123466
  referencedMap,
123281
123467
  semanticDiagnosticsPerFile,
123282
- emitDiagnosticsPerFile,
123468
+ emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123283
123469
  affectedFilesPendingEmit,
123284
- changeFileSet,
123470
+ changeFileSet: toChangeFileSet(),
123285
123471
  emitSignatures,
123286
- latestChangedDtsFile
123472
+ latestChangedDtsFile,
123473
+ version
123287
123474
  };
123288
- return createBuildInfo(program);
123289
123475
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
123290
123476
  return relativeToBuildInfo(getNormalizedAbsolutePath(path, currentDirectory));
123291
123477
  }
@@ -123333,13 +123519,13 @@ function getBuildInfo2(state) {
123333
123519
  });
123334
123520
  return result;
123335
123521
  }
123336
- function convertToProgramBuildInfoCompilerOptions(options) {
123522
+ function toIncrementalBuildInfoCompilerOptions(options) {
123337
123523
  let result;
123338
123524
  const { optionsNameMap } = getOptionsNameMap();
123339
123525
  for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) {
123340
123526
  const optionInfo = optionsNameMap.get(name.toLowerCase());
123341
123527
  if (optionInfo == null ? void 0 : optionInfo.affectsBuildInfo) {
123342
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(
123528
+ (result || (result = {}))[name] = toReusableCompilerOptionValue(
123343
123529
  optionInfo,
123344
123530
  options[name]
123345
123531
  );
@@ -123347,7 +123533,7 @@ function getBuildInfo2(state) {
123347
123533
  }
123348
123534
  return result;
123349
123535
  }
123350
- function convertToReusableCompilerOptionValue(option, value) {
123536
+ function toReusableCompilerOptionValue(option, value) {
123351
123537
  if (option) {
123352
123538
  Debug.assert(option.type !== "listOrElement");
123353
123539
  if (option.type === "list") {
@@ -123361,23 +123547,22 @@ function getBuildInfo2(state) {
123361
123547
  }
123362
123548
  return value;
123363
123549
  }
123364
- function convertToProgramBuildInfoDiagnostics() {
123550
+ function toIncrementalBuildInfoDiagnostics() {
123365
123551
  let result;
123366
123552
  state.fileInfos.forEach((_value, key) => {
123367
- var _a2;
123368
- const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
123553
+ const value = state.semanticDiagnosticsPerFile.get(key);
123369
123554
  if (!value) {
123370
123555
  if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
123371
123556
  } else if (value.length) {
123372
123557
  result = append(result, [
123373
123558
  toFileId(key),
123374
- convertToReusableDiagnostics(value, key)
123559
+ toReusableDiagnostic(value, key)
123375
123560
  ]);
123376
123561
  }
123377
123562
  });
123378
123563
  return result;
123379
123564
  }
123380
- function convertToProgramBuildInfoEmitDiagnostics() {
123565
+ function toIncrementalBuildInfoEmitDiagnostics() {
123381
123566
  var _a2;
123382
123567
  let result;
123383
123568
  if (!((_a2 = state.emitDiagnosticsPerFile) == null ? void 0 : _a2.size)) return result;
@@ -123385,55 +123570,64 @@ function getBuildInfo2(state) {
123385
123570
  const value = state.emitDiagnosticsPerFile.get(key);
123386
123571
  result = append(result, [
123387
123572
  toFileId(key),
123388
- convertToReusableDiagnostics(value, key)
123573
+ toReusableDiagnostic(value, key)
123389
123574
  ]);
123390
123575
  }
123391
123576
  return result;
123392
123577
  }
123393
- function convertToReusableDiagnostics(diagnostics, diagnosticFilePath) {
123578
+ function toReusableDiagnostic(diagnostics, diagnosticFilePath) {
123394
123579
  Debug.assert(!!diagnostics.length);
123395
123580
  return diagnostics.map((diagnostic) => {
123396
- const result = convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
123581
+ const result = toReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
123397
123582
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
123398
123583
  result.reportDeprecated = diagnostic.reportsDeprecated;
123399
123584
  result.source = diagnostic.source;
123400
123585
  result.skippedOn = diagnostic.skippedOn;
123401
123586
  const { relatedInformation } = diagnostic;
123402
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
123587
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => toReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
123403
123588
  return result;
123404
123589
  });
123405
123590
  }
123406
- function convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
123591
+ function toReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
123407
123592
  const { file } = diagnostic;
123408
123593
  return {
123409
123594
  ...diagnostic,
123410
123595
  file: file ? file.resolvedPath === diagnosticFilePath ? void 0 : relativeToBuildInfo(file.resolvedPath) : false,
123411
- messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
123596
+ messageText: isString(diagnostic.messageText) ? diagnostic.messageText : toReusableDiagnosticMessageChain(diagnostic.messageText)
123412
123597
  };
123413
123598
  }
123414
- function convertToReusableDiagnosticMessageChain(chain) {
123599
+ function toReusableDiagnosticMessageChain(chain) {
123415
123600
  if (chain.repopulateInfo) {
123416
123601
  return {
123417
123602
  info: chain.repopulateInfo(),
123418
- next: convertToReusableDiagnosticMessageChainArray(chain.next)
123603
+ next: toReusableDiagnosticMessageChainArray(chain.next)
123419
123604
  };
123420
123605
  }
123421
- const next = convertToReusableDiagnosticMessageChainArray(chain.next);
123606
+ const next = toReusableDiagnosticMessageChainArray(chain.next);
123422
123607
  return next === chain.next ? chain : { ...chain, next };
123423
123608
  }
123424
- function convertToReusableDiagnosticMessageChainArray(array) {
123609
+ function toReusableDiagnosticMessageChainArray(array) {
123425
123610
  if (!array) return array;
123426
123611
  return forEach(array, (chain, index) => {
123427
- const reusable = convertToReusableDiagnosticMessageChain(chain);
123612
+ const reusable = toReusableDiagnosticMessageChain(chain);
123428
123613
  if (chain === reusable) return void 0;
123429
123614
  const result = index > 0 ? array.slice(0, index - 1) : [];
123430
123615
  result.push(reusable);
123431
123616
  for (let i = index + 1; i < array.length; i++) {
123432
- result.push(convertToReusableDiagnosticMessageChain(array[i]));
123617
+ result.push(toReusableDiagnosticMessageChain(array[i]));
123433
123618
  }
123434
123619
  return result;
123435
123620
  }) || array;
123436
123621
  }
123622
+ function toChangeFileSet() {
123623
+ let changeFileSet;
123624
+ if (state.changedFilesSet.size) {
123625
+ for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123626
+ changeFileSet = append(changeFileSet, toFileId(path));
123627
+ }
123628
+ }
123629
+ return changeFileSet;
123630
+ }
123437
123631
  }
123438
123632
  function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123439
123633
  let host;
@@ -123492,24 +123686,27 @@ function computeSignature(text, host, data) {
123492
123686
  return (host.createHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
123493
123687
  }
123494
123688
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
123495
- let oldState = oldProgram && oldProgram.getState();
123689
+ let oldState = oldProgram && oldProgram.state;
123496
123690
  if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
123497
123691
  newProgram = void 0;
123498
123692
  oldState = void 0;
123499
123693
  return oldProgram;
123500
123694
  }
123501
123695
  const state = createBuilderProgramState(newProgram, oldState);
123502
- newProgram.getBuildInfo = () => getBuildInfo2(state);
123696
+ newProgram.getBuildInfo = () => getBuildInfo2(toBuilderProgramStateWithDefinedProgram(state));
123503
123697
  newProgram = void 0;
123504
123698
  oldProgram = void 0;
123505
123699
  oldState = void 0;
123506
- const getState = () => state;
123507
- const builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
123508
- builderProgram.getState = getState;
123700
+ const builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
123701
+ builderProgram.state = state;
123509
123702
  builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
123510
123703
  builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
123511
123704
  builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
123512
- builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(state, Debug.checkDefined(state.program), sourceFile);
123705
+ builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(
123706
+ state,
123707
+ Debug.checkDefined(state.program),
123708
+ sourceFile
123709
+ );
123513
123710
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
123514
123711
  builderProgram.emit = emit;
123515
123712
  builderProgram.releaseProgram = () => releaseCache(state);
@@ -123524,22 +123721,29 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123524
123721
  }
123525
123722
  return builderProgram;
123526
123723
  function emitBuildInfo(writeFile2, cancellationToken) {
123724
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123527
123725
  if (state.buildInfoEmitPending) {
123528
- const result = Debug.checkDefined(state.program).emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123726
+ const result = state.program.emitBuildInfo(
123727
+ writeFile2 || maybeBind(host, host.writeFile),
123728
+ cancellationToken
123729
+ );
123529
123730
  state.buildInfoEmitPending = false;
123530
123731
  return result;
123531
123732
  }
123532
123733
  return emitSkippedWithNoDiagnostics;
123533
123734
  }
123534
123735
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123535
- var _a, _b, _c;
123736
+ var _a, _b, _c, _d;
123737
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123536
123738
  let affected = getNextAffectedFile(state, cancellationToken, host);
123537
123739
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123538
123740
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
123539
123741
  if (!affected) {
123540
123742
  if (!state.compilerOptions.outFile) {
123541
123743
  const pendingAffectedFile = getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles);
123542
- if (!pendingAffectedFile) {
123744
+ if (pendingAffectedFile) {
123745
+ ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123746
+ } else {
123543
123747
  const pendingForDiagnostics = getNextPendingEmitDiagnosticsFile(state);
123544
123748
  if (pendingForDiagnostics) {
123545
123749
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(pendingForDiagnostics.affectedFile.resolvedPath, pendingForDiagnostics.seenKind | 24 /* AllDts */);
@@ -123548,52 +123752,81 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123548
123752
  affected: pendingForDiagnostics.affectedFile
123549
123753
  };
123550
123754
  }
123551
- if (!state.buildInfoEmitPending) return void 0;
123552
- const affected2 = state.program;
123553
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123554
- state.buildInfoEmitPending = false;
123555
- return { result: result2, affected: affected2 };
123556
123755
  }
123557
- ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123558
123756
  } else {
123559
- if (!state.programEmitPending) return void 0;
123560
- emitKind = state.programEmitPending;
123561
- if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123562
- if (!emitKind) return void 0;
123563
- affected = state.program;
123757
+ if (state.programEmitPending) {
123758
+ emitKind = state.programEmitPending;
123759
+ if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123760
+ if (emitKind) affected = state.program;
123761
+ }
123762
+ if (!affected && ((_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.size)) {
123763
+ const seenKind = state.seenProgramEmit || 0 /* None */;
123764
+ if (!(seenKind & 24 /* AllDts */)) {
123765
+ state.seenProgramEmit = 24 /* AllDts */ | seenKind;
123766
+ const diagnostics = [];
123767
+ state.emitDiagnosticsPerFile.forEach((d) => addRange(diagnostics, d));
123768
+ return {
123769
+ result: { emitSkipped: true, diagnostics },
123770
+ affected: state.program
123771
+ };
123772
+ }
123773
+ }
123774
+ }
123775
+ if (!affected) {
123776
+ if (!state.buildInfoEmitPending) return void 0;
123777
+ const affected2 = state.program;
123778
+ const result2 = affected2.emitBuildInfo(
123779
+ writeFile2 || maybeBind(host, host.writeFile),
123780
+ cancellationToken
123781
+ );
123782
+ state.buildInfoEmitPending = false;
123783
+ return { result: result2, affected: affected2 };
123564
123784
  }
123565
123785
  }
123566
123786
  let emitOnly;
123567
123787
  if (emitKind & 7 /* AllJs */) emitOnly = 0 /* Js */;
123568
123788
  if (emitKind & 24 /* AllDts */) emitOnly = emitOnly === void 0 ? 1 /* Dts */ : void 0;
123569
- if (affected === state.program) {
123570
- state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123571
- }
123572
123789
  const result = state.program.emit(
123573
123790
  affected === state.program ? void 0 : affected,
123574
123791
  getWriteFileCallback(writeFile2, customTransformers),
123575
123792
  cancellationToken,
123576
123793
  emitOnly,
123577
- customTransformers
123794
+ customTransformers,
123795
+ /*forceDtsEmit*/
123796
+ void 0,
123797
+ /*skipBuildInfo*/
123798
+ true
123578
123799
  );
123579
123800
  if (affected !== state.program) {
123580
123801
  const affectedSourceFile = affected;
123581
123802
  state.seenAffectedFiles.add(affectedSourceFile.resolvedPath);
123582
123803
  if (state.affectedFilesIndex !== void 0) state.affectedFilesIndex++;
123583
123804
  state.buildInfoEmitPending = true;
123584
- const existing = ((_a = state.seenEmittedFiles) == null ? void 0 : _a.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123805
+ const existing = ((_b = state.seenEmittedFiles) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123585
123806
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, emitKind | existing);
123586
- const existingPending = ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123807
+ const existingPending = ((_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123587
123808
  const pendingKind = getPendingEmitKind(existingPending, emitKind | existing);
123588
123809
  if (pendingKind) (state.affectedFilesPendingEmit ?? (state.affectedFilesPendingEmit = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, pendingKind);
123589
- else (_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.delete(affectedSourceFile.resolvedPath);
123810
+ else (_d = state.affectedFilesPendingEmit) == null ? void 0 : _d.delete(affectedSourceFile.resolvedPath);
123590
123811
  if (result.diagnostics.length) (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, result.diagnostics);
123591
123812
  } else {
123592
123813
  state.changedFilesSet.clear();
123814
+ state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123815
+ state.seenProgramEmit = emitKind | (state.seenProgramEmit || 0 /* None */);
123816
+ let emitDiagnosticsPerFile;
123817
+ result.diagnostics.forEach((d) => {
123818
+ if (!d.file) return;
123819
+ let diagnostics = emitDiagnosticsPerFile == null ? void 0 : emitDiagnosticsPerFile.get(d.file.resolvedPath);
123820
+ if (!diagnostics) (emitDiagnosticsPerFile ?? (emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(d.file.resolvedPath, diagnostics = []);
123821
+ diagnostics.push(d);
123822
+ });
123823
+ if (emitDiagnosticsPerFile) state.emitDiagnosticsPerFile = emitDiagnosticsPerFile;
123824
+ state.buildInfoEmitPending = true;
123593
123825
  }
123594
123826
  return { result, affected };
123595
123827
  }
123596
123828
  function getWriteFileCallback(writeFile2, customTransformers) {
123829
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123597
123830
  if (!getEmitDeclarations(state.compilerOptions)) return writeFile2 || maybeBind(host, host.writeFile);
123598
123831
  return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
123599
123832
  var _a, _b, _c;
@@ -123660,6 +123893,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123660
123893
  };
123661
123894
  }
123662
123895
  function emit(targetSourceFile, writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123896
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123663
123897
  if (kind === 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
123664
123898
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
123665
123899
  }
@@ -123672,7 +123906,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123672
123906
  let diagnostics;
123673
123907
  let emittedFiles = [];
123674
123908
  let affectedEmitResult;
123675
- while (affectedEmitResult = emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
123909
+ while (affectedEmitResult = emitNextAffectedFile(
123910
+ writeFile2,
123911
+ cancellationToken,
123912
+ emitOnlyDtsFiles,
123913
+ customTransformers
123914
+ )) {
123676
123915
  emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
123677
123916
  diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics);
123678
123917
  emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
@@ -123688,7 +123927,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123688
123927
  clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles);
123689
123928
  }
123690
123929
  }
123691
- return Debug.checkDefined(state.program).emit(
123930
+ return state.program.emit(
123692
123931
  targetSourceFile,
123693
123932
  getWriteFileCallback(writeFile2, customTransformers),
123694
123933
  cancellationToken,
@@ -123697,6 +123936,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123697
123936
  );
123698
123937
  }
123699
123938
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
123939
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123700
123940
  while (true) {
123701
123941
  const affected = getNextAffectedFile(state, cancellationToken, host);
123702
123942
  let result;
@@ -123711,31 +123951,41 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123711
123951
  state.buildInfoEmitPending = true;
123712
123952
  if (!result) continue;
123713
123953
  } else {
123714
- result = state.program.getSemanticDiagnostics(
123715
- /*sourceFile*/
123716
- void 0,
123717
- cancellationToken
123954
+ let diagnostics;
123955
+ const semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
123956
+ state.program.getSourceFiles().forEach(
123957
+ (sourceFile) => diagnostics = addRange(
123958
+ diagnostics,
123959
+ getSemanticDiagnosticsOfFile(
123960
+ state,
123961
+ sourceFile,
123962
+ cancellationToken,
123963
+ semanticDiagnosticsPerFile
123964
+ )
123965
+ )
123718
123966
  );
123967
+ state.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
123968
+ result = diagnostics || emptyArray;
123719
123969
  state.changedFilesSet.clear();
123720
123970
  state.programEmitPending = getBuilderFileEmit(state.compilerOptions);
123971
+ state.buildInfoEmitPending = true;
123721
123972
  }
123722
123973
  return { result, affected };
123723
123974
  }
123724
123975
  }
123725
123976
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
123977
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123726
123978
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
123727
- const compilerOptions = Debug.checkDefined(state.program).getCompilerOptions();
123728
- if (compilerOptions.outFile) {
123729
- Debug.assert(!state.semanticDiagnosticsPerFile);
123730
- return Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
123731
- }
123732
123979
  if (sourceFile) {
123733
123980
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
123734
123981
  }
123735
- while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
123982
+ while (true) {
123983
+ const affectedResult = getSemanticDiagnosticsOfNextAffectedFile(cancellationToken);
123984
+ if (!affectedResult) break;
123985
+ if (affectedResult.affected === state.program) return affectedResult.result;
123736
123986
  }
123737
123987
  let diagnostics;
123738
- for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
123988
+ for (const sourceFile2 of state.program.getSourceFiles()) {
123739
123989
  diagnostics = addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile2, cancellationToken));
123740
123990
  }
123741
123991
  return diagnostics || emptyArray;
@@ -123756,39 +124006,42 @@ function toBuilderFileEmit(value, fullEmitForOptions) {
123756
124006
  function toProgramEmitPending(value, options) {
123757
124007
  return !value ? getBuilderFileEmit(options || {}) : value;
123758
124008
  }
123759
- function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host) {
124009
+ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath, host) {
123760
124010
  var _a, _b, _c, _d;
123761
- const program = buildInfo.program;
123762
124011
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
123763
124012
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
123764
124013
  let state;
123765
- const filePaths = (_a = program.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
124014
+ const filePaths = (_a = buildInfo.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
123766
124015
  let filePathsSetList;
123767
- const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : void 0;
123768
- if (isProgramBundleEmitBuildInfo(program)) {
123769
- const fileInfos = /* @__PURE__ */ new Map();
123770
- program.fileInfos.forEach((fileInfo, index) => {
124016
+ const latestChangedDtsFile = buildInfo.latestChangedDtsFile ? toAbsolutePath(buildInfo.latestChangedDtsFile) : void 0;
124017
+ const fileInfos = /* @__PURE__ */ new Map();
124018
+ const changedFilesSet = new Set(map(buildInfo.changeFileSet, toFilePath));
124019
+ if (isIncrementalBundleEmitBuildInfo(buildInfo)) {
124020
+ buildInfo.fileInfos.forEach((fileInfo, index) => {
123771
124021
  const path = toFilePath(index + 1);
123772
124022
  fileInfos.set(path, isString(fileInfo) ? { version: fileInfo, signature: void 0, affectsGlobalScope: void 0, impliedFormat: void 0 } : fileInfo);
123773
124023
  });
123774
124024
  state = {
123775
124025
  fileInfos,
123776
- compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
124026
+ compilerOptions: buildInfo.options ? convertToOptionsWithAbsolutePaths(buildInfo.options, toAbsolutePath) : {},
124027
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124028
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
124029
+ hasReusableDiagnostic: true,
124030
+ changedFilesSet,
123777
124031
  latestChangedDtsFile,
123778
- outSignature: program.outSignature,
123779
- programEmitPending: program.pendingEmit === void 0 ? void 0 : toProgramEmitPending(program.pendingEmit, program.options)
124032
+ outSignature: buildInfo.outSignature,
124033
+ programEmitPending: buildInfo.pendingEmit === void 0 ? void 0 : toProgramEmitPending(buildInfo.pendingEmit, buildInfo.options)
123780
124034
  };
123781
124035
  } else {
123782
- filePathsSetList = (_b = program.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
123783
- const fileInfos = /* @__PURE__ */ new Map();
123784
- const emitSignatures = ((_c = program.options) == null ? void 0 : _c.composite) && !program.options.outFile ? /* @__PURE__ */ new Map() : void 0;
123785
- program.fileInfos.forEach((fileInfo, index) => {
124036
+ filePathsSetList = (_b = buildInfo.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
124037
+ const emitSignatures = ((_c = buildInfo.options) == null ? void 0 : _c.composite) && !buildInfo.options.outFile ? /* @__PURE__ */ new Map() : void 0;
124038
+ buildInfo.fileInfos.forEach((fileInfo, index) => {
123786
124039
  const path = toFilePath(index + 1);
123787
124040
  const stateFileInfo = toBuilderStateFileInfoForMultiEmit(fileInfo);
123788
124041
  fileInfos.set(path, stateFileInfo);
123789
124042
  if (emitSignatures && stateFileInfo.signature) emitSignatures.set(path, stateFileInfo.signature);
123790
124043
  });
123791
- (_d = program.emitSignatures) == null ? void 0 : _d.forEach((value) => {
124044
+ (_d = buildInfo.emitSignatures) == null ? void 0 : _d.forEach((value) => {
123792
124045
  if (isNumber(value)) emitSignatures.delete(toFilePath(value));
123793
124046
  else {
123794
124047
  const key = toFilePath(value[0]);
@@ -123801,23 +124054,22 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123801
124054
  );
123802
124055
  }
123803
124056
  });
123804
- const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123805
- const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
124057
+ const fullEmitForOptions = buildInfo.affectedFilesPendingEmit ? getBuilderFileEmit(buildInfo.options || {}) : void 0;
123806
124058
  state = {
123807
124059
  fileInfos,
123808
- compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123809
- referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
123810
- semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
123811
- emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
124060
+ compilerOptions: buildInfo.options ? convertToOptionsWithAbsolutePaths(buildInfo.options, toAbsolutePath) : {},
124061
+ referencedMap: toManyToManyPathMap(buildInfo.referencedMap, buildInfo.options ?? {}),
124062
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124063
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
123812
124064
  hasReusableDiagnostic: true,
123813
- affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
124065
+ affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
123814
124066
  changedFilesSet,
123815
124067
  latestChangedDtsFile,
123816
124068
  emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
123817
124069
  };
123818
124070
  }
123819
124071
  return {
123820
- getState: () => state,
124072
+ state,
123821
124073
  saveEmitState: noop,
123822
124074
  restoreEmitState: noop,
123823
124075
  getProgram: notImplemented,
@@ -123859,7 +124111,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123859
124111
  referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
123860
124112
  return map2;
123861
124113
  }
123862
- function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
124114
+ function toPerFileSemanticDiagnostics(diagnostics) {
123863
124115
  const semanticDiagnostics = new Map(
123864
124116
  mapDefinedIterator(
123865
124117
  fileInfos.keys(),
@@ -123870,7 +124122,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123870
124122
  if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
123871
124123
  else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
123872
124124
  });
123873
- return semanticDiagnostics.size ? semanticDiagnostics : void 0;
124125
+ return semanticDiagnostics;
123874
124126
  }
123875
124127
  function toPerFileEmitDiagnostics(diagnostics) {
123876
124128
  return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
@@ -123911,15 +124163,15 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
123911
124163
  }
123912
124164
  }
123913
124165
  }
123914
- function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
124166
+ function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
123915
124167
  return {
123916
- getState: notImplemented,
124168
+ state: void 0,
123917
124169
  saveEmitState: noop,
123918
124170
  restoreEmitState: noop,
123919
124171
  getProgram,
123920
- getProgramOrUndefined: () => getState().program,
123921
- releaseProgram: () => getState().program = void 0,
123922
- getCompilerOptions: () => getState().compilerOptions,
124172
+ getProgramOrUndefined: () => state.program,
124173
+ releaseProgram: () => state.program = void 0,
124174
+ getCompilerOptions: () => state.compilerOptions,
123923
124175
  getSourceFile: (fileName) => getProgram().getSourceFile(fileName),
123924
124176
  getSourceFiles: () => getProgram().getSourceFiles(),
123925
124177
  getOptionsDiagnostics: (cancellationToken) => getProgram().getOptionsDiagnostics(cancellationToken),
@@ -123935,13 +124187,23 @@ function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics)
123935
124187
  close: noop
123936
124188
  };
123937
124189
  function getProgram() {
123938
- return Debug.checkDefined(getState().program);
124190
+ return Debug.checkDefined(state.program);
123939
124191
  }
123940
124192
  }
123941
124193
 
123942
124194
  // src/compiler/builderPublic.ts
123943
124195
  function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123944
- return createBuilderProgram(1 /* EmitAndSemanticDiagnosticsBuilderProgram */, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
124196
+ return createBuilderProgram(
124197
+ 1 /* EmitAndSemanticDiagnosticsBuilderProgram */,
124198
+ getBuilderCreationParameters(
124199
+ newProgramOrRootNames,
124200
+ hostOrOptions,
124201
+ oldProgramOrHost,
124202
+ configFileParsingDiagnosticsOrOldProgram,
124203
+ configFileParsingDiagnostics,
124204
+ projectReferences
124205
+ )
124206
+ );
123945
124207
  }
123946
124208
 
123947
124209
  // src/compiler/resolutionCache.ts
@@ -125213,13 +125475,13 @@ function createTabularErrorsDisplay(filesInError, host) {
125213
125475
  });
125214
125476
  return tabularData;
125215
125477
  }
125216
- function isBuilderProgram2(program) {
125217
- return !!program.getState;
125478
+ function isBuilderProgram(program) {
125479
+ return !!program.state;
125218
125480
  }
125219
125481
  function listFiles(program, write) {
125220
125482
  const options = program.getCompilerOptions();
125221
125483
  if (options.explainFiles) {
125222
- explainFiles(isBuilderProgram2(program) ? program.getProgram() : program, write);
125484
+ explainFiles(isBuilderProgram(program) ? program.getProgram() : program, write);
125223
125485
  } else if (options.listFiles || options.listFilesOnly) {
125224
125486
  forEach(program.getSourceFiles(), (file) => {
125225
125487
  write(file.fileName);
@@ -125719,8 +125981,8 @@ function readBuilderProgram(compilerOptions, host) {
125719
125981
  if (!content) return void 0;
125720
125982
  buildInfo = getBuildInfo(buildInfoPath, content);
125721
125983
  }
125722
- if (!buildInfo || buildInfo.version !== version || !buildInfo.program) return void 0;
125723
- return createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host);
125984
+ if (!buildInfo || buildInfo.version !== version || !isIncrementalBuildInfo(buildInfo)) return void 0;
125985
+ return createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath, host);
125724
125986
  }
125725
125987
  function createIncrementalCompilerHost(options, system = sys) {
125726
125988
  const host = createCompilerHostWorker(
@@ -126986,8 +127248,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
126986
127248
  ({ buildResult, step } = buildErrors(
126987
127249
  state,
126988
127250
  projectPath,
126989
- program,
126990
- config,
126991
127251
  diagnostics,
126992
127252
  errorFlags,
126993
127253
  errorType
@@ -127050,8 +127310,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127050
127310
  ({ buildResult, step } = buildErrors(
127051
127311
  state,
127052
127312
  projectPath,
127053
- program,
127054
- config,
127055
127313
  declDiagnostics,
127056
127314
  32 /* DeclarationEmitErrors */,
127057
127315
  "Declaration file"
@@ -127114,8 +127372,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127114
127372
  ({ buildResult, step } = buildErrors(
127115
127373
  state,
127116
127374
  projectPath,
127117
- program,
127118
- config,
127119
127375
  emitDiagnostics,
127120
127376
  64 /* EmitErrors */,
127121
127377
  "Emit"
@@ -127295,13 +127551,10 @@ function afterProgramDone(state, program) {
127295
127551
  }
127296
127552
  state.projectCompilerOptions = state.baseCompilerOptions;
127297
127553
  }
127298
- function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
127299
- const canEmitBuildInfo = program && !program.getCompilerOptions().outFile;
127554
+ function buildErrors(state, resolvedPath, diagnostics, buildResult, errorType) {
127300
127555
  reportAndStoreErrors(state, resolvedPath, diagnostics);
127301
127556
  state.projectStatus.set(resolvedPath, { type: 0 /* Unbuildable */, reason: `${errorType} errors` });
127302
- if (canEmitBuildInfo) return { buildResult, step: 4 /* EmitBuildInfo */ };
127303
- afterProgramDone(state, program);
127304
- return { buildResult, step: 5 /* QueueReferencingProjects */ };
127557
+ return { buildResult, step: 4 /* EmitBuildInfo */ };
127305
127558
  }
127306
127559
  function isFileWatcherWithModifiedTime(value) {
127307
127560
  return !!value.watcher;
@@ -127444,7 +127697,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127444
127697
  let oldestOutputFileName;
127445
127698
  let oldestOutputFileTime = maximumDate;
127446
127699
  let buildInfoTime;
127447
- let buildInfoProgram;
127700
+ let incrementalBuildInfo;
127448
127701
  let buildInfoVersionMap;
127449
127702
  if (buildInfoPath) {
127450
127703
  const buildInfoCacheEntry2 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
@@ -127469,26 +127722,26 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127469
127722
  fileName: buildInfoPath
127470
127723
  };
127471
127724
  }
127472
- if (buildInfo.program && buildInfo.version !== version) {
127725
+ if (isIncrementalBuildInfo(buildInfo) && buildInfo.version !== version) {
127473
127726
  return {
127474
127727
  type: 13 /* TsVersionOutputOfDate */,
127475
127728
  version: buildInfo.version
127476
127729
  };
127477
127730
  }
127478
- if (buildInfo.program) {
127479
- 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) : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127731
+ if (isIncrementalBuildInfo(buildInfo)) {
127732
+ 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)) {
127480
127733
  return {
127481
127734
  type: 7 /* OutOfDateBuildInfo */,
127482
127735
  buildInfoFile: buildInfoPath
127483
127736
  };
127484
127737
  }
127485
- if (!project.options.noEmit && getPendingEmitKind(project.options, buildInfo.program.options || {})) {
127738
+ if (!project.options.noEmit && getPendingEmitKind(project.options, buildInfo.options || {})) {
127486
127739
  return {
127487
127740
  type: 8 /* OutOfDateOptions */,
127488
127741
  buildInfoFile: buildInfoPath
127489
127742
  };
127490
127743
  }
127491
- buildInfoProgram = buildInfo.program;
127744
+ incrementalBuildInfo = buildInfo;
127492
127745
  }
127493
127746
  oldestOutputFileTime = buildInfoTime;
127494
127747
  oldestOutputFileName = buildInfoPath;
@@ -127505,12 +127758,12 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127505
127758
  reason: `${inputFile} does not exist`
127506
127759
  };
127507
127760
  }
127508
- const inputPath = buildInfoProgram ? toPath2(state, inputFile) : void 0;
127761
+ const inputPath = incrementalBuildInfo ? toPath2(state, inputFile) : void 0;
127509
127762
  if (buildInfoTime && buildInfoTime < inputTime) {
127510
127763
  let version2;
127511
127764
  let currentVersion;
127512
- if (buildInfoProgram) {
127513
- if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
127765
+ if (incrementalBuildInfo) {
127766
+ if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host);
127514
127767
  const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath);
127515
127768
  version2 = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath);
127516
127769
  const text = version2 ? state.readFileWithCache(resolvedInputPath ?? inputFile) : void 0;
@@ -127529,10 +127782,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127529
127782
  newestInputFileName = inputFile;
127530
127783
  newestInputFileTime = inputTime;
127531
127784
  }
127532
- if (buildInfoProgram) seenRoots.add(inputPath);
127785
+ if (incrementalBuildInfo) seenRoots.add(inputPath);
127533
127786
  }
127534
- if (buildInfoProgram) {
127535
- if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
127787
+ if (incrementalBuildInfo) {
127788
+ if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host);
127536
127789
  const existingRoot = forEachEntry(
127537
127790
  buildInfoVersionMap.roots,
127538
127791
  // File was root file when project was built but its not any more
@@ -127679,7 +127932,7 @@ function getLatestChangedDtsTime(state, options, resolvedConfigPath) {
127679
127932
  if (!options.composite) return void 0;
127680
127933
  const entry = Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
127681
127934
  if (entry.latestChangedDtsTime !== void 0) return entry.latestChangedDtsTime || void 0;
127682
- const latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? state.host.getModifiedTime(getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, getDirectoryPath(entry.path))) : void 0;
127935
+ const latestChangedDtsTime = entry.buildInfo && isIncrementalBuildInfo(entry.buildInfo) && entry.buildInfo.latestChangedDtsFile ? state.host.getModifiedTime(getNormalizedAbsolutePath(entry.buildInfo.latestChangedDtsFile, getDirectoryPath(entry.path))) : void 0;
127683
127936
  entry.latestChangedDtsTime = latestChangedDtsTime || false;
127684
127937
  return latestChangedDtsTime;
127685
127938
  }
@@ -129643,7 +129896,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
129643
129896
  expression,
129644
129897
  /*includeBigInt*/
129645
129898
  false
129646
- )) {
129899
+ ) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
129647
129900
  context.tracker.reportInferenceFallback(prop.name);
129648
129901
  result = false;
129649
129902
  }