typescript 5.6.0-dev.20240604 → 5.6.0-dev.20240606

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-dev.20240604`;
21
+ var version = `${versionMajorMinor}.0-dev.20240606`;
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
  }
@@ -47134,7 +47195,7 @@ function createTypeChecker(host) {
47134
47195
  const isExport = typeOnlyDeclaration.kind === 281 /* ExportSpecifier */ || typeOnlyDeclaration.kind === 278 /* ExportDeclaration */;
47135
47196
  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
47197
  const relatedMessage = isExport ? Diagnostics._0_was_exported_here : Diagnostics._0_was_imported_here;
47137
- const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
47198
+ const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : moduleExportNameTextUnescaped(typeOnlyDeclaration.name);
47138
47199
  addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
47139
47200
  }
47140
47201
  }
@@ -47378,12 +47439,12 @@ function createTypeChecker(host) {
47378
47439
  if (valueSymbol.exports) result.exports = new Map(valueSymbol.exports);
47379
47440
  return result;
47380
47441
  }
47381
- function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
47442
+ function getExportOfModule(symbol, nameText, specifier, dontResolveAlias) {
47382
47443
  var _a;
47383
47444
  if (symbol.flags & 1536 /* Module */) {
47384
- const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
47445
+ const exportSymbol = getExportsOfSymbol(symbol).get(nameText);
47385
47446
  const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
47386
- const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(name.escapedText);
47447
+ const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(nameText);
47387
47448
  markSymbolOfAliasDeclarationIfTypeOnly(
47388
47449
  specifier,
47389
47450
  exportSymbol,
@@ -47391,7 +47452,7 @@ function createTypeChecker(host) {
47391
47452
  /*overwriteEmpty*/
47392
47453
  false,
47393
47454
  exportStarDeclaration,
47394
- name.escapedText
47455
+ nameText
47395
47456
  );
47396
47457
  return resolved;
47397
47458
  }
@@ -47409,10 +47470,11 @@ function createTypeChecker(host) {
47409
47470
  const moduleSpecifier = getExternalModuleRequireArgument(node) || node.moduleSpecifier;
47410
47471
  const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
47411
47472
  const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
47412
- if (!isIdentifier(name)) {
47473
+ if (!isIdentifier(name) && name.kind !== 11 /* StringLiteral */) {
47413
47474
  return void 0;
47414
47475
  }
47415
- const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
47476
+ const nameText = moduleExportNameTextEscaped(name);
47477
+ const suppressInteropError = nameText === "default" /* Default */ && allowSyntheticDefaultImports;
47416
47478
  const targetSymbol = resolveESModuleSymbol(
47417
47479
  moduleSymbol,
47418
47480
  moduleSpecifier,
@@ -47421,7 +47483,7 @@ function createTypeChecker(host) {
47421
47483
  suppressInteropError
47422
47484
  );
47423
47485
  if (targetSymbol) {
47424
- if (name.escapedText) {
47486
+ if (nameText || name.kind === 11 /* StringLiteral */) {
47425
47487
  if (isShorthandAmbientModuleSymbol(moduleSymbol)) {
47426
47488
  return moduleSymbol;
47427
47489
  }
@@ -47429,16 +47491,16 @@ function createTypeChecker(host) {
47429
47491
  if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) {
47430
47492
  symbolFromVariable = getPropertyOfType(
47431
47493
  getTypeOfSymbol(targetSymbol),
47432
- name.escapedText,
47494
+ nameText,
47433
47495
  /*skipObjectFunctionPropertyAugment*/
47434
47496
  true
47435
47497
  );
47436
47498
  } else {
47437
- symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
47499
+ symbolFromVariable = getPropertyOfVariable(targetSymbol, nameText);
47438
47500
  }
47439
47501
  symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
47440
- let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
47441
- if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
47502
+ let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
47503
+ if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
47442
47504
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
47443
47505
  if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47444
47506
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
@@ -47456,7 +47518,7 @@ function createTypeChecker(host) {
47456
47518
  var _a;
47457
47519
  const moduleName = getFullyQualifiedName(moduleSymbol, node);
47458
47520
  const declarationName = declarationNameToString(name);
47459
- const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
47521
+ const suggestion = isIdentifier(name) ? getSuggestedSymbolForNonexistentModule(name, targetSymbol) : void 0;
47460
47522
  if (suggestion !== void 0) {
47461
47523
  const suggestionName = symbolToString(suggestion);
47462
47524
  const diagnostic = error(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
@@ -47478,7 +47540,7 @@ function createTypeChecker(host) {
47478
47540
  }
47479
47541
  function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
47480
47542
  var _a, _b;
47481
- const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(name.escapedText);
47543
+ const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(moduleExportNameTextEscaped(name));
47482
47544
  const exports2 = moduleSymbol.exports;
47483
47545
  if (localSymbol) {
47484
47546
  const exportedEqualsSymbol = exports2 == null ? void 0 : exports2.get("export=" /* ExportEquals */);
@@ -47510,7 +47572,7 @@ function createTypeChecker(host) {
47510
47572
  }
47511
47573
  }
47512
47574
  function getTargetOfImportSpecifier(node, dontResolveAlias) {
47513
- if (isImportSpecifier(node) && idText(node.propertyName || node.name) === "default" /* Default */) {
47575
+ if (isImportSpecifier(node) && moduleExportNameIsDefault(node.propertyName || node.name)) {
47514
47576
  const specifier = getModuleSpecifierForImportOrExport(node);
47515
47577
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47516
47578
  if (moduleSymbol) {
@@ -47554,19 +47616,23 @@ function createTypeChecker(host) {
47554
47616
  }
47555
47617
  }
47556
47618
  function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
47557
- if (idText(node.propertyName || node.name) === "default" /* Default */) {
47619
+ const name = node.propertyName || node.name;
47620
+ if (moduleExportNameIsDefault(name)) {
47558
47621
  const specifier = getModuleSpecifierForImportOrExport(node);
47559
47622
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
47560
47623
  if (moduleSymbol) {
47561
47624
  return getTargetofModuleDefault(moduleSymbol, node, !!dontResolveAlias);
47562
47625
  }
47563
47626
  }
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
47627
+ const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : name.kind === 11 /* StringLiteral */ ? void 0 : (
47628
+ // Skip for invalid syntax like this: export { "x" }
47629
+ resolveEntityName(
47630
+ name,
47631
+ meaning,
47632
+ /*ignoreErrors*/
47633
+ false,
47634
+ dontResolveAlias
47635
+ )
47570
47636
  );
47571
47637
  markSymbolOfAliasDeclarationIfTypeOnly(
47572
47638
  node,
@@ -52163,9 +52229,10 @@ function createTypeChecker(host) {
52163
52229
  if (index >= 0) {
52164
52230
  const exportDecl = statements[index];
52165
52231
  const replacements = mapDefined(exportDecl.exportClause.elements, (e) => {
52166
- if (!e.propertyName) {
52232
+ if (!e.propertyName && e.name.kind !== 11 /* StringLiteral */) {
52233
+ const name = e.name;
52167
52234
  const indices = indicesOf(statements);
52168
- const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], e.name));
52235
+ const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], name));
52169
52236
  if (length(associatedIndices) && every(associatedIndices, (i) => canHaveExportModifier(statements[i]))) {
52170
52237
  for (const index2 of associatedIndices) {
52171
52238
  statements[index2] = addExportModifier(statements[index2]);
@@ -52799,7 +52866,7 @@ function createTypeChecker(host) {
52799
52866
  function getSomeTargetNameFromDeclarations(declarations) {
52800
52867
  return firstDefined(declarations, (d) => {
52801
52868
  if (isImportSpecifier(d) || isExportSpecifier(d)) {
52802
- return idText(d.propertyName || d.name);
52869
+ return moduleExportNameTextUnescaped(d.propertyName || d.name);
52803
52870
  }
52804
52871
  if (isBinaryExpression(d) || isExportAssignment(d)) {
52805
52872
  const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -52817,7 +52884,7 @@ function createTypeChecker(host) {
52817
52884
  });
52818
52885
  }
52819
52886
  function serializeAsAlias(symbol, localName, modifierFlags) {
52820
- var _a2, _b, _c, _d, _e, _f;
52887
+ var _a2, _b, _c, _d, _e;
52821
52888
  const node = getDeclarationOfAliasSymbol(symbol);
52822
52889
  if (!node) return Debug.fail();
52823
52890
  const target = getMergedSymbol(getTargetOfAliasDeclaration(
@@ -53015,8 +53082,11 @@ function createTypeChecker(host) {
53015
53082
  }
53016
53083
  case 281 /* ExportSpecifier */:
53017
53084
  const specifier = node.parent.parent.moduleSpecifier;
53018
- if (specifier && ((_f = node.propertyName) == null ? void 0 : _f.escapedText) === "default" /* Default */) {
53019
- verbatimTargetName = "default" /* Default */;
53085
+ if (specifier) {
53086
+ const propertyName = node.propertyName;
53087
+ if (propertyName && moduleExportNameIsDefault(propertyName)) {
53088
+ verbatimTargetName = "default" /* Default */;
53089
+ }
53020
53090
  }
53021
53091
  serializeExportSpecifier(
53022
53092
  unescapeLeadingUnderscores(symbol.escapedName),
@@ -53729,7 +53799,7 @@ function createTypeChecker(host) {
53729
53799
  }
53730
53800
  function collectLinkedAliases(node, setVisibility) {
53731
53801
  let exportSymbol;
53732
- if (node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53802
+ if (node.kind !== 11 /* StringLiteral */ && node.parent && node.parent.kind === 277 /* ExportAssignment */) {
53733
53803
  exportSymbol = resolveName(
53734
53804
  node,
53735
53805
  node,
@@ -69302,9 +69372,10 @@ function createTypeChecker(host) {
69302
69372
  return;
69303
69373
  case 281 /* ExportSpecifier */:
69304
69374
  const exportDeclaration = node.parent.parent;
69305
- if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
69375
+ const name = node.propertyName || node.name;
69376
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier && name.kind !== 11 /* StringLiteral */) {
69306
69377
  const symbol = resolveEntityName(
69307
- node.propertyName || node.name,
69378
+ name,
69308
69379
  111551 /* Value */,
69309
69380
  /*ignoreErrors*/
69310
69381
  true,
@@ -69598,6 +69669,9 @@ function createTypeChecker(host) {
69598
69669
  function markExportSpecifierAliasReferenced(location) {
69599
69670
  if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) {
69600
69671
  const exportedName = location.propertyName || location.name;
69672
+ if (exportedName.kind === 11 /* StringLiteral */) {
69673
+ return;
69674
+ }
69601
69675
  const symbol = resolveName(
69602
69676
  exportedName,
69603
69677
  exportedName.escapedText,
@@ -69612,7 +69686,7 @@ function createTypeChecker(host) {
69612
69686
  const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
69613
69687
  if (!target || getSymbolFlags(target) & 111551 /* Value */) {
69614
69688
  markExportAsReferenced(location);
69615
- markIdentifierAliasReferenced(location.propertyName || location.name);
69689
+ markIdentifierAliasReferenced(exportedName);
69616
69690
  }
69617
69691
  }
69618
69692
  return;
@@ -83208,6 +83282,16 @@ function createTypeChecker(host) {
83208
83282
  }
83209
83283
  return true;
83210
83284
  }
83285
+ function checkModuleExportName(name, allowStringLiteral = true) {
83286
+ if (name === void 0 || name.kind !== 11 /* StringLiteral */) {
83287
+ return;
83288
+ }
83289
+ if (!allowStringLiteral) {
83290
+ grammarErrorOnNode(name, Diagnostics.Identifier_expected);
83291
+ } else if (moduleKind === 5 /* ES2015 */ || moduleKind === 6 /* ES2020 */) {
83292
+ grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020);
83293
+ }
83294
+ }
83211
83295
  function checkAliasSymbol(node) {
83212
83296
  var _a, _b, _c, _d;
83213
83297
  let symbol = getSymbolOfDeclaration(node);
@@ -83219,7 +83303,7 @@ function createTypeChecker(host) {
83219
83303
  Debug.assert(node.kind !== 280 /* NamespaceExport */);
83220
83304
  if (node.kind === 281 /* ExportSpecifier */) {
83221
83305
  const diag2 = error(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
83222
- const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get((node.propertyName || node.name).escapedText);
83306
+ const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get(moduleExportNameTextEscaped(node.propertyName || node.name));
83223
83307
  if (alreadyExportedSymbol === target) {
83224
83308
  const exportingDeclaration = (_c = alreadyExportedSymbol.declarations) == null ? void 0 : _c.find(isJSDocNode);
83225
83309
  if (exportingDeclaration) {
@@ -83274,7 +83358,7 @@ function createTypeChecker(host) {
83274
83358
  if (compilerOptions.verbatimModuleSyntax) {
83275
83359
  Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name");
83276
83360
  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;
83277
- const name = idText(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83361
+ const name = moduleExportNameTextUnescaped(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83278
83362
  addTypeOnlyDeclarationRelatedInfo(
83279
83363
  error(node, message, name),
83280
83364
  isType ? void 0 : typeOnlyAlias,
@@ -83288,7 +83372,7 @@ function createTypeChecker(host) {
83288
83372
  }
83289
83373
  case 281 /* ExportSpecifier */: {
83290
83374
  if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) {
83291
- const name = idText(node.propertyName || node.name);
83375
+ const name = moduleExportNameTextUnescaped(node.propertyName || node.name);
83292
83376
  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);
83293
83377
  addTypeOnlyDeclarationRelatedInfo(diagnostic, isType ? void 0 : typeOnlyAlias, name);
83294
83378
  break;
@@ -83338,8 +83422,11 @@ function createTypeChecker(host) {
83338
83422
  function checkImportBinding(node) {
83339
83423
  checkCollisionsForDeclarationName(node, node.name);
83340
83424
  checkAliasSymbol(node);
83341
- if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83342
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83425
+ if (node.kind === 276 /* ImportSpecifier */) {
83426
+ checkModuleExportName(node.propertyName);
83427
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83428
+ checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83429
+ }
83343
83430
  }
83344
83431
  }
83345
83432
  function checkImportAttributes(declaration) {
@@ -83460,6 +83547,7 @@ function createTypeChecker(host) {
83460
83547
  error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
83461
83548
  } else if (node.exportClause) {
83462
83549
  checkAliasSymbol(node.exportClause);
83550
+ checkModuleExportName(node.exportClause.name);
83463
83551
  }
83464
83552
  if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83465
83553
  if (node.exportClause) {
@@ -83490,6 +83578,9 @@ function createTypeChecker(host) {
83490
83578
  }
83491
83579
  function checkExportSpecifier(node) {
83492
83580
  checkAliasSymbol(node);
83581
+ const hasModuleSpecifier = node.parent.parent.moduleSpecifier !== void 0;
83582
+ checkModuleExportName(node.propertyName, hasModuleSpecifier);
83583
+ checkModuleExportName(node.name);
83493
83584
  if (getEmitDeclarations(compilerOptions)) {
83494
83585
  collectLinkedAliases(
83495
83586
  node.propertyName || node.name,
@@ -83497,8 +83588,11 @@ function createTypeChecker(host) {
83497
83588
  true
83498
83589
  );
83499
83590
  }
83500
- if (!node.parent.parent.moduleSpecifier) {
83591
+ if (!hasModuleSpecifier) {
83501
83592
  const exportedName = node.propertyName || node.name;
83593
+ if (exportedName.kind === 11 /* StringLiteral */) {
83594
+ return;
83595
+ }
83502
83596
  const symbol = resolveName(
83503
83597
  exportedName,
83504
83598
  exportedName.escapedText,
@@ -83514,7 +83608,7 @@ function createTypeChecker(host) {
83514
83608
  markLinkedReferences(node, 7 /* ExportSpecifier */);
83515
83609
  }
83516
83610
  } else {
83517
- if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
83611
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
83518
83612
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83519
83613
  }
83520
83614
  }
@@ -84669,7 +84763,11 @@ function createTypeChecker(host) {
84669
84763
  }
84670
84764
  function getExportSpecifierLocalTargetSymbol(node) {
84671
84765
  if (isExportSpecifier(node)) {
84672
- return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84766
+ const name = node.propertyName || node.name;
84767
+ return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : name.kind === 11 /* StringLiteral */ ? void 0 : (
84768
+ // Skip for invalid syntax like this: export { "x" }
84769
+ resolveEntityName(name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)
84770
+ );
84673
84771
  } else {
84674
84772
  return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
84675
84773
  }
@@ -85640,7 +85738,8 @@ function createTypeChecker(host) {
85640
85738
  resolveExternalModuleSymbol(sym);
85641
85739
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
85642
85740
  },
85643
- isImportRequiredByAugmentation
85741
+ isImportRequiredByAugmentation,
85742
+ isDefinitelyReferenceToGlobalSymbolObject
85644
85743
  };
85645
85744
  function isImportRequiredByAugmentation(node) {
85646
85745
  const file = getSourceFileOfNode(node);
@@ -87479,7 +87578,7 @@ function isDeclarationNameOrImportPropertyName(name) {
87479
87578
  switch (name.parent.kind) {
87480
87579
  case 276 /* ImportSpecifier */:
87481
87580
  case 281 /* ExportSpecifier */:
87482
- return isIdentifier(name);
87581
+ return isIdentifier(name) || name.kind === 11 /* StringLiteral */;
87483
87582
  default:
87484
87583
  return isDeclarationName(name);
87485
87584
  }
@@ -88724,7 +88823,7 @@ var visitEachChildTable = {
88724
88823
  return context.factory.updateImportSpecifier(
88725
88824
  node,
88726
88825
  node.isTypeOnly,
88727
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88826
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88728
88827
  Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88729
88828
  );
88730
88829
  },
@@ -88755,8 +88854,8 @@ var visitEachChildTable = {
88755
88854
  return context.factory.updateExportSpecifier(
88756
88855
  node,
88757
88856
  node.isTypeOnly,
88758
- nodeVisitor(node.propertyName, visitor, isIdentifier),
88759
- Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
88857
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
88858
+ Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName))
88760
88859
  );
88761
88860
  },
88762
88861
  // Module references
@@ -89300,7 +89399,7 @@ function containsDefaultReference(node) {
89300
89399
  return some(node.elements, isNamedDefaultReference);
89301
89400
  }
89302
89401
  function isNamedDefaultReference(e) {
89303
- return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
89402
+ return moduleExportNameIsDefault(e.propertyName || e.name);
89304
89403
  }
89305
89404
  function chainBundle(context, transformSourceFile) {
89306
89405
  return transformSourceFileOrBundle;
@@ -89376,9 +89475,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89376
89475
  hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
89377
89476
  } else {
89378
89477
  const name = node.exportClause.name;
89379
- if (!uniqueExports.get(idText(name))) {
89478
+ const nameText = moduleExportNameTextUnescaped(name);
89479
+ if (!uniqueExports.get(nameText)) {
89380
89480
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89381
- uniqueExports.set(idText(name), true);
89481
+ uniqueExports.set(nameText, true);
89382
89482
  exportedNames = append(exportedNames, name);
89383
89483
  }
89384
89484
  hasImportStar = true;
@@ -89436,20 +89536,23 @@ function collectExternalModuleInfo(context, sourceFile) {
89436
89536
  return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, exportedFunctions, externalHelpersImportDeclaration };
89437
89537
  function addExportedNamesForExportDeclaration(node) {
89438
89538
  for (const specifier of cast(node.exportClause, isNamedExports).elements) {
89439
- if (!uniqueExports.get(idText(specifier.name))) {
89539
+ const specifierNameText = moduleExportNameTextUnescaped(specifier.name);
89540
+ if (!uniqueExports.get(specifierNameText)) {
89440
89541
  const name = specifier.propertyName || specifier.name;
89441
- if (!node.moduleSpecifier) {
89442
- exportSpecifiers.add(name, specifier);
89443
- }
89444
- const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89445
- if (decl) {
89446
- if (decl.kind === 262 /* FunctionDeclaration */) {
89447
- addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
89448
- continue;
89542
+ if (name.kind !== 11 /* StringLiteral */) {
89543
+ if (!node.moduleSpecifier) {
89544
+ exportSpecifiers.add(name, specifier);
89545
+ }
89546
+ const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89547
+ if (decl) {
89548
+ if (decl.kind === 262 /* FunctionDeclaration */) {
89549
+ addExportedFunctionDeclaration(decl, specifier.name, moduleExportNameIsDefault(specifier.name));
89550
+ continue;
89551
+ }
89552
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89449
89553
  }
89450
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89451
89554
  }
89452
- uniqueExports.set(idText(specifier.name), true);
89555
+ uniqueExports.set(specifierNameText, true);
89453
89556
  exportedNames = append(exportedNames, specifier.name);
89454
89557
  }
89455
89558
  }
@@ -89463,9 +89566,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89463
89566
  }
89464
89567
  } else {
89465
89568
  name ?? (name = node.name);
89466
- if (!uniqueExports.get(idText(name))) {
89569
+ const nameText = moduleExportNameTextUnescaped(name);
89570
+ if (!uniqueExports.get(nameText)) {
89467
89571
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89468
- uniqueExports.set(idText(name), true);
89572
+ uniqueExports.set(nameText, true);
89469
89573
  }
89470
89574
  }
89471
89575
  }
@@ -106742,7 +106846,7 @@ function transformModule(context) {
106742
106846
  factory2.createExpressionStatement(
106743
106847
  reduceLeft(
106744
106848
  currentModuleInfo.exportedNames.slice(i, i + chunkSize),
106745
- (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev),
106849
+ (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),
106746
106850
  factory2.createVoidZero()
106747
106851
  )
106748
106852
  )
@@ -107065,7 +107169,10 @@ function transformModule(context) {
107065
107169
  append(statements, createUnderscoreUnderscoreESModule());
107066
107170
  }
107067
107171
  if (some(currentModuleInfo.exportedNames)) {
107068
- append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
107172
+ append(
107173
+ statements,
107174
+ 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()))
107175
+ );
107069
107176
  }
107070
107177
  for (const f of currentModuleInfo.exportedFunctions) {
107071
107178
  appendExportsOfHoistedDeclaration(statements, f);
@@ -107936,17 +108043,16 @@ function transformModule(context) {
107936
108043
  );
107937
108044
  }
107938
108045
  for (const specifier of node.exportClause.elements) {
107939
- const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && idText(specifier.propertyName || specifier.name) === "default";
107940
- const exportedValue = factory2.createPropertyAccessExpression(
107941
- exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName,
107942
- specifier.propertyName || specifier.name
107943
- );
108046
+ const specifierName = specifier.propertyName || specifier.name;
108047
+ const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && moduleExportNameIsDefault(specifierName);
108048
+ const target = exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName;
108049
+ const exportedValue = specifierName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, specifierName) : factory2.createPropertyAccessExpression(target, specifierName);
107944
108050
  statements.push(
107945
108051
  setOriginalNode(
107946
108052
  setTextRange(
107947
108053
  factory2.createExpressionStatement(
107948
108054
  createExportExpression(
107949
- factory2.getExportName(specifier),
108055
+ specifier.name.kind === 11 /* StringLiteral */ ? factory2.cloneNode(specifier.name) : factory2.getExportName(specifier),
107950
108056
  exportedValue,
107951
108057
  /*location*/
107952
108058
  void 0,
@@ -107971,7 +108077,7 @@ function transformModule(context) {
107971
108077
  factory2.cloneNode(node.exportClause.name),
107972
108078
  getHelperExpressionForExport(
107973
108079
  node,
107974
- moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
108080
+ moduleKind !== 2 /* AMD */ ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : node.exportClause.name.kind === 11 /* StringLiteral */ ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
107975
108081
  )
107976
108082
  )
107977
108083
  ),
@@ -108301,10 +108407,13 @@ function transformModule(context) {
108301
108407
  return statements;
108302
108408
  }
108303
108409
  function appendExportStatement(statements, seen, exportName, expression, location, allowComments, liveBinding) {
108304
- if (!seen.has(exportName)) {
108410
+ if (exportName.kind !== 11 /* StringLiteral */) {
108411
+ if (seen.has(exportName)) {
108412
+ return statements;
108413
+ }
108305
108414
  seen.set(exportName, true);
108306
- statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108307
108415
  }
108416
+ statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
108308
108417
  return statements;
108309
108418
  }
108310
108419
  function createUnderscoreUnderscoreESModule() {
@@ -108374,7 +108483,10 @@ function transformModule(context) {
108374
108483
  ])
108375
108484
  ]
108376
108485
  ) : factory2.createAssignment(
108377
- factory2.createPropertyAccessExpression(
108486
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(
108487
+ factory2.createIdentifier("exports"),
108488
+ factory2.cloneNode(name)
108489
+ ) : factory2.createPropertyAccessExpression(
108378
108490
  factory2.createIdentifier("exports"),
108379
108491
  factory2.cloneNode(name)
108380
108492
  ),
@@ -108510,11 +108622,9 @@ function transformModule(context) {
108510
108622
  );
108511
108623
  } else if (isImportSpecifier(importDeclaration)) {
108512
108624
  const name = importDeclaration.propertyName || importDeclaration.name;
108625
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
108513
108626
  return setTextRange(
108514
- factory2.createPropertyAccessExpression(
108515
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
108516
- factory2.cloneNode(name)
108517
- ),
108627
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(name)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(name)),
108518
108628
  /*location*/
108519
108629
  node
108520
108630
  );
@@ -108802,7 +108912,7 @@ function transformSystemModule(context) {
108802
108912
  const exportedNames = [];
108803
108913
  if (moduleInfo.exportedNames) {
108804
108914
  for (const exportedLocalName of moduleInfo.exportedNames) {
108805
- if (exportedLocalName.escapedText === "default") {
108915
+ if (moduleExportNameIsDefault(exportedLocalName)) {
108806
108916
  continue;
108807
108917
  }
108808
108918
  exportedNames.push(
@@ -108980,10 +109090,10 @@ function transformSystemModule(context) {
108980
109090
  for (const e of entry.exportClause.elements) {
108981
109091
  properties.push(
108982
109092
  factory2.createPropertyAssignment(
108983
- factory2.createStringLiteral(idText(e.name)),
109093
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.name)),
108984
109094
  factory2.createElementAccessExpression(
108985
109095
  parameterName,
108986
- factory2.createStringLiteral(idText(e.propertyName || e.name))
109096
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.propertyName || e.name))
108987
109097
  )
108988
109098
  )
108989
109099
  );
@@ -109010,7 +109120,7 @@ function transformSystemModule(context) {
109010
109120
  /*typeArguments*/
109011
109121
  void 0,
109012
109122
  [
109013
- factory2.createStringLiteral(idText(entry.exportClause.name)),
109123
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(entry.exportClause.name)),
109014
109124
  parameterName
109015
109125
  ]
109016
109126
  )
@@ -109350,7 +109460,7 @@ function transformSystemModule(context) {
109350
109460
  const exportSpecifiers = moduleInfo.exportSpecifiers.get(name);
109351
109461
  if (exportSpecifiers) {
109352
109462
  for (const exportSpecifier of exportSpecifiers) {
109353
- if (exportSpecifier.name.escapedText !== excludeName) {
109463
+ if (moduleExportNameTextUnescaped(exportSpecifier.name) !== excludeName) {
109354
109464
  statements = appendExportStatement(statements, exportSpecifier.name, name);
109355
109465
  }
109356
109466
  }
@@ -109771,13 +109881,12 @@ function transformSystemModule(context) {
109771
109881
  node
109772
109882
  );
109773
109883
  } else if (isImportSpecifier(importDeclaration)) {
109884
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109885
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109774
109886
  return setTextRange(
109775
109887
  factory2.createPropertyAssignment(
109776
109888
  factory2.cloneNode(name),
109777
- factory2.createPropertyAccessExpression(
109778
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109779
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109780
- )
109889
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName))
109781
109890
  ),
109782
109891
  /*location*/
109783
109892
  node
@@ -109820,11 +109929,10 @@ function transformSystemModule(context) {
109820
109929
  node
109821
109930
  );
109822
109931
  } else if (isImportSpecifier(importDeclaration)) {
109932
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
109933
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
109823
109934
  return setTextRange(
109824
- factory2.createPropertyAccessExpression(
109825
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
109826
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
109827
- ),
109935
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName)),
109828
109936
  /*location*/
109829
109937
  node
109830
109938
  );
@@ -111415,15 +111523,17 @@ function transformDeclarations(context) {
111415
111523
  if (isDeclarationAndNotVisible(input)) return;
111416
111524
  if (hasDynamicName(input)) {
111417
111525
  if (isolatedDeclarations) {
111418
- if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111419
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111420
- return;
111421
- } else if (
111422
- // Type declarations just need to double-check that the input computed name is an entity name expression
111423
- (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111424
- ) {
111425
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111426
- return;
111526
+ if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
111527
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
111528
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
111529
+ return;
111530
+ } else if (
111531
+ // Type declarations just need to double-check that the input computed name is an entity name expression
111532
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
111533
+ ) {
111534
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111535
+ return;
111536
+ }
111427
111537
  }
111428
111538
  } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
111429
111539
  return;
@@ -113372,7 +113482,8 @@ var notImplementedResolver = {
113372
113482
  getJsxFragmentFactoryEntity: notImplemented,
113373
113483
  isBindingCapturedByNode: notImplemented,
113374
113484
  getDeclarationStatementsForSourceFile: notImplemented,
113375
- isImportRequiredByAugmentation: notImplemented
113485
+ isImportRequiredByAugmentation: notImplemented,
113486
+ isDefinitelyReferenceToGlobalSymbolObject: notImplemented
113376
113487
  };
113377
113488
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
113378
113489
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -118107,7 +118218,7 @@ function isIgnoredFileFromWildCardWatching({
118107
118218
  }
118108
118219
  return false;
118109
118220
  function hasSourceFile(file) {
118110
- return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.getState().fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118221
+ return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.state.fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
118111
118222
  }
118112
118223
  function isSupportedScriptKind() {
118113
118224
  if (!getScriptKind) return false;
@@ -118128,9 +118239,6 @@ function isIgnoredFileFromWildCardWatching({
118128
118239
  }
118129
118240
  }
118130
118241
  }
118131
- function isBuilderProgram(program) {
118132
- return !!program.getState;
118133
- }
118134
118242
  function isEmittedFileOfProgram(program, file) {
118135
118243
  if (!program) {
118136
118244
  return false;
@@ -122688,6 +122796,13 @@ var BuilderState;
122688
122796
  })(BuilderState || (BuilderState = {}));
122689
122797
 
122690
122798
  // src/compiler/builder.ts
122799
+ function isBuilderProgramStateWithDefinedProgram(state) {
122800
+ return state.program !== void 0;
122801
+ }
122802
+ function toBuilderProgramStateWithDefinedProgram(state) {
122803
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
122804
+ return state;
122805
+ }
122691
122806
  function getBuilderFileEmit(options) {
122692
122807
  let result = 1 /* Js */;
122693
122808
  if (options.sourceMap) result = result | 2 /* JsMap */;
@@ -122952,7 +123067,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122952
123067
  const affectedFile = affectedFiles[affectedFilesIndex];
122953
123068
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
122954
123069
  state.affectedFilesIndex = affectedFilesIndex;
122955
- addToAffectedFilesPendingEmit(state, affectedFile.resolvedPath, getBuilderFileEmit(state.compilerOptions));
123070
+ addToAffectedFilesPendingEmit(
123071
+ state,
123072
+ affectedFile.resolvedPath,
123073
+ getBuilderFileEmit(state.compilerOptions)
123074
+ );
122956
123075
  handleDtsMayChangeOfAffectedFile(
122957
123076
  state,
122958
123077
  affectedFile,
@@ -122972,12 +123091,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
122972
123091
  if (nextKey.done) {
122973
123092
  return void 0;
122974
123093
  }
122975
- const program = Debug.checkDefined(state.program);
122976
- const compilerOptions = program.getCompilerOptions();
122977
- if (compilerOptions.outFile) return program;
123094
+ const compilerOptions = state.program.getCompilerOptions();
123095
+ if (compilerOptions.outFile) return state.program;
122978
123096
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
122979
123097
  state,
122980
- program,
123098
+ state.program,
122981
123099
  nextKey.value,
122982
123100
  cancellationToken,
122983
123101
  host
@@ -123038,9 +123156,8 @@ function getNextPendingEmitDiagnosticsFile(state) {
123038
123156
  function removeDiagnosticsOfLibraryFiles(state) {
123039
123157
  if (!state.cleanedDiagnosticsOfLibFiles) {
123040
123158
  state.cleanedDiagnosticsOfLibFiles = true;
123041
- const program = Debug.checkDefined(state.program);
123042
- const options = program.getCompilerOptions();
123043
- forEach(program.getSourceFiles(), (f) => program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
123159
+ const options = state.program.getCompilerOptions();
123160
+ forEach(state.program.getSourceFiles(), (f) => state.program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, state.program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
123044
123161
  }
123045
123162
  }
123046
123163
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
@@ -123049,7 +123166,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
123049
123166
  removeDiagnosticsOfLibraryFiles(state);
123050
123167
  BuilderState.updateShapeSignature(
123051
123168
  state,
123052
- Debug.checkDefined(state.program),
123169
+ state.program,
123053
123170
  affectedFile,
123054
123171
  cancellationToken,
123055
123172
  host
@@ -123067,12 +123184,11 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
123067
123184
  function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
123068
123185
  removeSemanticDiagnosticsOf(state, path);
123069
123186
  if (!state.changedFilesSet.has(path)) {
123070
- const program = Debug.checkDefined(state.program);
123071
- const sourceFile = program.getSourceFileByPath(path);
123187
+ const sourceFile = state.program.getSourceFileByPath(path);
123072
123188
  if (sourceFile) {
123073
123189
  BuilderState.updateShapeSignature(
123074
123190
  state,
123075
- program,
123191
+ state.program,
123076
123192
  sourceFile,
123077
123193
  cancellationToken,
123078
123194
  host,
@@ -123080,9 +123196,17 @@ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken,
123080
123196
  true
123081
123197
  );
123082
123198
  if (invalidateJsFiles) {
123083
- addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
123199
+ addToAffectedFilesPendingEmit(
123200
+ state,
123201
+ path,
123202
+ getBuilderFileEmit(state.compilerOptions)
123203
+ );
123084
123204
  } else if (getEmitDeclarations(state.compilerOptions)) {
123085
- addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
123205
+ addToAffectedFilesPendingEmit(
123206
+ state,
123207
+ path,
123208
+ state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */
123209
+ );
123086
123210
  }
123087
123211
  }
123088
123212
  }
@@ -123149,7 +123273,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
123149
123273
  host
123150
123274
  );
123151
123275
  if (isChangedSignature(state, currentPath)) {
123152
- const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
123276
+ const currentSourceFile = state.program.getSourceFileByPath(currentPath);
123153
123277
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
123154
123278
  }
123155
123279
  }
@@ -123198,7 +123322,7 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
123198
123322
  function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123199
123323
  return concatenate(
123200
123324
  getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
123201
- Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
123325
+ state.program.getProgramDiagnostics(sourceFile)
123202
123326
  );
123203
123327
  }
123204
123328
  function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
@@ -123208,7 +123332,7 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
123208
123332
  if (cachedDiagnostics) {
123209
123333
  return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123210
123334
  }
123211
- const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123335
+ const diagnostics = state.program.getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123212
123336
  semanticDiagnosticsPerFile.set(path, diagnostics);
123213
123337
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123214
123338
  }
@@ -123218,7 +123342,7 @@ function isProgramBundleEmitBuildInfo(info) {
123218
123342
  }
123219
123343
  function getBuildInfo2(state) {
123220
123344
  var _a, _b;
123221
- const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
123345
+ const currentDirectory = state.program.getCurrentDirectory();
123222
123346
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
123223
123347
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
123224
123348
  const fileNames = [];
@@ -123560,24 +123684,27 @@ function computeSignature(text, host, data) {
123560
123684
  return (host.createHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
123561
123685
  }
123562
123686
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
123563
- let oldState = oldProgram && oldProgram.getState();
123687
+ let oldState = oldProgram && oldProgram.state;
123564
123688
  if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
123565
123689
  newProgram = void 0;
123566
123690
  oldState = void 0;
123567
123691
  return oldProgram;
123568
123692
  }
123569
123693
  const state = createBuilderProgramState(newProgram, oldState);
123570
- newProgram.getBuildInfo = () => getBuildInfo2(state);
123694
+ newProgram.getBuildInfo = () => getBuildInfo2(toBuilderProgramStateWithDefinedProgram(state));
123571
123695
  newProgram = void 0;
123572
123696
  oldProgram = void 0;
123573
123697
  oldState = void 0;
123574
- const getState = () => state;
123575
- const builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
123576
- builderProgram.getState = getState;
123698
+ const builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
123699
+ builderProgram.state = state;
123577
123700
  builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
123578
123701
  builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
123579
123702
  builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
123580
- builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(state, Debug.checkDefined(state.program), sourceFile);
123703
+ builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(
123704
+ state,
123705
+ Debug.checkDefined(state.program),
123706
+ sourceFile
123707
+ );
123581
123708
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
123582
123709
  builderProgram.emit = emit;
123583
123710
  builderProgram.releaseProgram = () => releaseCache(state);
@@ -123592,8 +123719,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123592
123719
  }
123593
123720
  return builderProgram;
123594
123721
  function emitBuildInfo(writeFile2, cancellationToken) {
123722
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123595
123723
  if (state.buildInfoEmitPending) {
123596
- const result = Debug.checkDefined(state.program).emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123724
+ const result = state.program.emitBuildInfo(
123725
+ writeFile2 || maybeBind(host, host.writeFile),
123726
+ cancellationToken
123727
+ );
123597
123728
  state.buildInfoEmitPending = false;
123598
123729
  return result;
123599
123730
  }
@@ -123601,6 +123732,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123601
123732
  }
123602
123733
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123603
123734
  var _a, _b, _c, _d;
123735
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123604
123736
  let affected = getNextAffectedFile(state, cancellationToken, host);
123605
123737
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123606
123738
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
@@ -123641,7 +123773,10 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123641
123773
  if (!affected) {
123642
123774
  if (!state.buildInfoEmitPending) return void 0;
123643
123775
  const affected2 = state.program;
123644
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123776
+ const result2 = affected2.emitBuildInfo(
123777
+ writeFile2 || maybeBind(host, host.writeFile),
123778
+ cancellationToken
123779
+ );
123645
123780
  state.buildInfoEmitPending = false;
123646
123781
  return { result: result2, affected: affected2 };
123647
123782
  }
@@ -123689,6 +123824,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123689
123824
  return { result, affected };
123690
123825
  }
123691
123826
  function getWriteFileCallback(writeFile2, customTransformers) {
123827
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123692
123828
  if (!getEmitDeclarations(state.compilerOptions)) return writeFile2 || maybeBind(host, host.writeFile);
123693
123829
  return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
123694
123830
  var _a, _b, _c;
@@ -123755,6 +123891,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123755
123891
  };
123756
123892
  }
123757
123893
  function emit(targetSourceFile, writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123894
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123758
123895
  if (kind === 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
123759
123896
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
123760
123897
  }
@@ -123767,7 +123904,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123767
123904
  let diagnostics;
123768
123905
  let emittedFiles = [];
123769
123906
  let affectedEmitResult;
123770
- while (affectedEmitResult = emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
123907
+ while (affectedEmitResult = emitNextAffectedFile(
123908
+ writeFile2,
123909
+ cancellationToken,
123910
+ emitOnlyDtsFiles,
123911
+ customTransformers
123912
+ )) {
123771
123913
  emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
123772
123914
  diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics);
123773
123915
  emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
@@ -123783,7 +123925,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123783
123925
  clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles);
123784
123926
  }
123785
123927
  }
123786
- return Debug.checkDefined(state.program).emit(
123928
+ return state.program.emit(
123787
123929
  targetSourceFile,
123788
123930
  getWriteFileCallback(writeFile2, customTransformers),
123789
123931
  cancellationToken,
@@ -123792,6 +123934,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123792
123934
  );
123793
123935
  }
123794
123936
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
123937
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123795
123938
  while (true) {
123796
123939
  const affected = getNextAffectedFile(state, cancellationToken, host);
123797
123940
  let result;
@@ -123829,6 +123972,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123829
123972
  }
123830
123973
  }
123831
123974
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
123975
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123832
123976
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
123833
123977
  if (sourceFile) {
123834
123978
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
@@ -123839,7 +123983,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123839
123983
  if (affectedResult.affected === state.program) return affectedResult.result;
123840
123984
  }
123841
123985
  let diagnostics;
123842
- for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
123986
+ for (const sourceFile2 of state.program.getSourceFiles()) {
123843
123987
  diagnostics = addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile2, cancellationToken));
123844
123988
  }
123845
123989
  return diagnostics || emptyArray;
@@ -123924,7 +124068,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123924
124068
  };
123925
124069
  }
123926
124070
  return {
123927
- getState: () => state,
124071
+ state,
123928
124072
  saveEmitState: noop,
123929
124073
  restoreEmitState: noop,
123930
124074
  getProgram: notImplemented,
@@ -124018,15 +124162,15 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
124018
124162
  }
124019
124163
  }
124020
124164
  }
124021
- function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
124165
+ function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
124022
124166
  return {
124023
- getState: notImplemented,
124167
+ state: void 0,
124024
124168
  saveEmitState: noop,
124025
124169
  restoreEmitState: noop,
124026
124170
  getProgram,
124027
- getProgramOrUndefined: () => getState().program,
124028
- releaseProgram: () => getState().program = void 0,
124029
- getCompilerOptions: () => getState().compilerOptions,
124171
+ getProgramOrUndefined: () => state.program,
124172
+ releaseProgram: () => state.program = void 0,
124173
+ getCompilerOptions: () => state.compilerOptions,
124030
124174
  getSourceFile: (fileName) => getProgram().getSourceFile(fileName),
124031
124175
  getSourceFiles: () => getProgram().getSourceFiles(),
124032
124176
  getOptionsDiagnostics: (cancellationToken) => getProgram().getOptionsDiagnostics(cancellationToken),
@@ -124042,13 +124186,23 @@ function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics)
124042
124186
  close: noop
124043
124187
  };
124044
124188
  function getProgram() {
124045
- return Debug.checkDefined(getState().program);
124189
+ return Debug.checkDefined(state.program);
124046
124190
  }
124047
124191
  }
124048
124192
 
124049
124193
  // src/compiler/builderPublic.ts
124050
124194
  function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
124051
- return createBuilderProgram(1 /* EmitAndSemanticDiagnosticsBuilderProgram */, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
124195
+ return createBuilderProgram(
124196
+ 1 /* EmitAndSemanticDiagnosticsBuilderProgram */,
124197
+ getBuilderCreationParameters(
124198
+ newProgramOrRootNames,
124199
+ hostOrOptions,
124200
+ oldProgramOrHost,
124201
+ configFileParsingDiagnosticsOrOldProgram,
124202
+ configFileParsingDiagnostics,
124203
+ projectReferences
124204
+ )
124205
+ );
124052
124206
  }
124053
124207
 
124054
124208
  // src/compiler/resolutionCache.ts
@@ -125320,13 +125474,13 @@ function createTabularErrorsDisplay(filesInError, host) {
125320
125474
  });
125321
125475
  return tabularData;
125322
125476
  }
125323
- function isBuilderProgram2(program) {
125324
- return !!program.getState;
125477
+ function isBuilderProgram(program) {
125478
+ return !!program.state;
125325
125479
  }
125326
125480
  function listFiles(program, write) {
125327
125481
  const options = program.getCompilerOptions();
125328
125482
  if (options.explainFiles) {
125329
- explainFiles(isBuilderProgram2(program) ? program.getProgram() : program, write);
125483
+ explainFiles(isBuilderProgram(program) ? program.getProgram() : program, write);
125330
125484
  } else if (options.listFiles || options.listFilesOnly) {
125331
125485
  forEach(program.getSourceFiles(), (file) => {
125332
125486
  write(file.fileName);
@@ -129741,7 +129895,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
129741
129895
  expression,
129742
129896
  /*includeBigInt*/
129743
129897
  false
129744
- )) {
129898
+ ) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
129745
129899
  context.tracker.reportInferenceFallback(prop.name);
129746
129900
  result = false;
129747
129901
  }