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/typescript.js CHANGED
@@ -277,7 +277,7 @@ __export(typescript_exports, {
277
277
  changeFullExtension: () => changeFullExtension,
278
278
  changesAffectModuleResolution: () => changesAffectModuleResolution,
279
279
  changesAffectingProgramStructure: () => changesAffectingProgramStructure,
280
- characterToRegularExpressionFlag: () => characterToRegularExpressionFlag,
280
+ characterCodeToRegularExpressionFlag: () => characterCodeToRegularExpressionFlag,
281
281
  childIsDecorated: () => childIsDecorated,
282
282
  classElementOrClassElementParameterIsDecorated: () => classElementOrClassElementParameterIsDecorated,
283
283
  classHasClassThisAssignment: () => classHasClassThisAssignment,
@@ -1263,7 +1263,7 @@ __export(typescript_exports, {
1263
1263
  isBreakStatement: () => isBreakStatement,
1264
1264
  isBuild: () => isBuild,
1265
1265
  isBuildInfoFile: () => isBuildInfoFile,
1266
- isBuilderProgram: () => isBuilderProgram2,
1266
+ isBuilderProgram: () => isBuilderProgram,
1267
1267
  isBundle: () => isBundle,
1268
1268
  isCallChain: () => isCallChain,
1269
1269
  isCallExpression: () => isCallExpression,
@@ -1612,6 +1612,7 @@ __export(typescript_exports, {
1612
1612
  isModuleBlock: () => isModuleBlock,
1613
1613
  isModuleBody: () => isModuleBody,
1614
1614
  isModuleDeclaration: () => isModuleDeclaration,
1615
+ isModuleExportName: () => isModuleExportName,
1615
1616
  isModuleExportsAccessExpression: () => isModuleExportsAccessExpression,
1616
1617
  isModuleIdentifier: () => isModuleIdentifier,
1617
1618
  isModuleName: () => isModuleName,
@@ -1929,6 +1930,9 @@ __export(typescript_exports, {
1929
1930
  missingFileModifiedTime: () => missingFileModifiedTime,
1930
1931
  modifierToFlag: () => modifierToFlag,
1931
1932
  modifiersToFlags: () => modifiersToFlags,
1933
+ moduleExportNameIsDefault: () => moduleExportNameIsDefault,
1934
+ moduleExportNameTextEscaped: () => moduleExportNameTextEscaped,
1935
+ moduleExportNameTextUnescaped: () => moduleExportNameTextUnescaped,
1932
1936
  moduleOptionDeclaration: () => moduleOptionDeclaration,
1933
1937
  moduleResolutionIsEqualTo: () => moduleResolutionIsEqualTo,
1934
1938
  moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
@@ -2074,7 +2078,7 @@ __export(typescript_exports, {
2074
2078
  reducePathComponents: () => reducePathComponents,
2075
2079
  refactor: () => ts_refactor_exports,
2076
2080
  regExpEscape: () => regExpEscape,
2077
- regularExpressionFlagToCharacter: () => regularExpressionFlagToCharacter,
2081
+ regularExpressionFlagToCharacterCode: () => regularExpressionFlagToCharacterCode,
2078
2082
  relativeComplement: () => relativeComplement,
2079
2083
  removeAllComments: () => removeAllComments,
2080
2084
  removeEmitHelper: () => removeEmitHelper,
@@ -2371,7 +2375,7 @@ module.exports = __toCommonJS(typescript_exports);
2371
2375
 
2372
2376
  // src/compiler/corePublic.ts
2373
2377
  var versionMajorMinor = "5.6";
2374
- var version = `${versionMajorMinor}.0-dev.20240604`;
2378
+ var version = `${versionMajorMinor}.0-dev.20240606`;
2375
2379
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2376
2380
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2377
2381
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -11456,7 +11460,8 @@ var Diagnostics = {
11456
11460
  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."),
11457
11461
  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."),
11458
11462
  _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."),
11459
- 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.")
11463
+ 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."),
11464
+ 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'.")
11460
11465
  };
11461
11466
 
11462
11467
  // src/compiler/scanner.ts
@@ -11616,16 +11621,16 @@ var textToToken = new Map(Object.entries({
11616
11621
  "#": 63 /* HashToken */,
11617
11622
  "`": 62 /* BacktickToken */
11618
11623
  }));
11619
- var charToRegExpFlag = new Map(Object.entries({
11620
- d: 1 /* HasIndices */,
11621
- g: 2 /* Global */,
11622
- i: 4 /* IgnoreCase */,
11623
- m: 8 /* Multiline */,
11624
- s: 16 /* DotAll */,
11625
- u: 32 /* Unicode */,
11626
- v: 64 /* UnicodeSets */,
11627
- y: 128 /* Sticky */
11628
- }));
11624
+ var charCodeToRegExpFlag = /* @__PURE__ */ new Map([
11625
+ [100 /* d */, 1 /* HasIndices */],
11626
+ [103 /* g */, 2 /* Global */],
11627
+ [105 /* i */, 4 /* IgnoreCase */],
11628
+ [109 /* m */, 8 /* Multiline */],
11629
+ [115 /* s */, 16 /* DotAll */],
11630
+ [117 /* u */, 32 /* Unicode */],
11631
+ [118 /* v */, 64 /* UnicodeSets */],
11632
+ [121 /* y */, 128 /* Sticky */]
11633
+ ]);
11629
11634
  var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
11630
11635
  [1 /* HasIndices */, 9 /* RegularExpressionFlagsHasIndices */],
11631
11636
  [16 /* DotAll */, 5 /* RegularExpressionFlagsDotAll */],
@@ -11681,12 +11686,12 @@ function tokenToString(t) {
11681
11686
  function stringToToken(s) {
11682
11687
  return textToToken.get(s);
11683
11688
  }
11684
- var regExpFlagChars = makeReverseMap(charToRegExpFlag);
11685
- function regularExpressionFlagToCharacter(f) {
11686
- return regExpFlagChars[f];
11689
+ var regExpFlagCharCodes = makeReverseMap(charCodeToRegExpFlag);
11690
+ function regularExpressionFlagToCharacterCode(f) {
11691
+ return regExpFlagCharCodes[f];
11687
11692
  }
11688
- function characterToRegularExpressionFlag(c) {
11689
- return charToRegExpFlag.get(c);
11693
+ function characterCodeToRegularExpressionFlag(ch) {
11694
+ return charCodeToRegExpFlag.get(ch);
11690
11695
  }
11691
11696
  function computeLineStarts(text) {
11692
11697
  const result = [];
@@ -13402,24 +13407,25 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13402
13407
  pos++;
13403
13408
  let regExpFlags = 0 /* None */;
13404
13409
  while (true) {
13405
- const ch = charCodeChecked(pos);
13410
+ const ch = codePointChecked(pos);
13406
13411
  if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
13407
13412
  break;
13408
13413
  }
13414
+ const size = charSize(ch);
13409
13415
  if (reportErrors2) {
13410
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13416
+ const flag = characterCodeToRegularExpressionFlag(ch);
13411
13417
  if (flag === void 0) {
13412
- error2(Diagnostics.Unknown_regular_expression_flag, pos, 1);
13418
+ error2(Diagnostics.Unknown_regular_expression_flag, pos, size);
13413
13419
  } else if (regExpFlags & flag) {
13414
- error2(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
13420
+ error2(Diagnostics.Duplicate_regular_expression_flag, pos, size);
13415
13421
  } else if (((regExpFlags | flag) & 96 /* AnyUnicodeMode */) === 96 /* AnyUnicodeMode */) {
13416
- error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, 1);
13422
+ error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, size);
13417
13423
  } else {
13418
13424
  regExpFlags |= flag;
13419
- checkRegularExpressionFlagAvailable(flag, pos);
13425
+ checkRegularExpressionFlagAvailability(flag, size);
13420
13426
  }
13421
13427
  }
13422
- pos++;
13428
+ pos += size;
13423
13429
  }
13424
13430
  if (reportErrors2) {
13425
13431
  scanRange(startOfRegExpBody, endOfRegExpBody - startOfRegExpBody, () => {
@@ -13634,22 +13640,23 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13634
13640
  }
13635
13641
  function scanPatternModifiers(currFlags) {
13636
13642
  while (true) {
13637
- const ch = charCodeChecked(pos);
13643
+ const ch = codePointChecked(pos);
13638
13644
  if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
13639
13645
  break;
13640
13646
  }
13641
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13647
+ const size = charSize(ch);
13648
+ const flag = characterCodeToRegularExpressionFlag(ch);
13642
13649
  if (flag === void 0) {
13643
- error2(Diagnostics.Unknown_regular_expression_flag, pos, 1);
13650
+ error2(Diagnostics.Unknown_regular_expression_flag, pos, size);
13644
13651
  } else if (currFlags & flag) {
13645
- error2(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
13652
+ error2(Diagnostics.Duplicate_regular_expression_flag, pos, size);
13646
13653
  } else if (!(flag & 28 /* Modifiers */)) {
13647
- error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
13654
+ error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, size);
13648
13655
  } else {
13649
13656
  currFlags |= flag;
13650
- checkRegularExpressionFlagAvailable(flag, pos);
13657
+ checkRegularExpressionFlagAvailability(flag, size);
13651
13658
  }
13652
- pos++;
13659
+ pos += size;
13653
13660
  }
13654
13661
  return currFlags;
13655
13662
  }
@@ -14253,6 +14260,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14253
14260
  forEach(groupNameReferences, (reference) => {
14254
14261
  if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
14255
14262
  error2(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
14263
+ if (groupSpecifiers) {
14264
+ const suggestion = getSpellingSuggestion(reference.name, groupSpecifiers, identity);
14265
+ if (suggestion) {
14266
+ error2(Diagnostics.Did_you_mean_0, reference.pos, reference.end - reference.pos, suggestion);
14267
+ }
14268
+ }
14256
14269
  }
14257
14270
  });
14258
14271
  forEach(decimalEscapes, (escape) => {
@@ -14265,10 +14278,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14265
14278
  }
14266
14279
  });
14267
14280
  }
14268
- function checkRegularExpressionFlagAvailable(flag, pos2) {
14281
+ function checkRegularExpressionFlagAvailability(flag, size) {
14269
14282
  const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
14270
14283
  if (availableFrom && languageVersion < availableFrom) {
14271
- error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
14284
+ error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, getNameOfScriptTarget(availableFrom));
14272
14285
  }
14273
14286
  }
14274
14287
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
@@ -16596,7 +16609,16 @@ function isJSDocTypeExpressionOrChild(node) {
16596
16609
  return !!findAncestor(node, isJSDocTypeExpression);
16597
16610
  }
16598
16611
  function isExportNamespaceAsDefaultDeclaration(node) {
16599
- return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default");
16612
+ return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && moduleExportNameIsDefault(node.exportClause.name));
16613
+ }
16614
+ function moduleExportNameTextUnescaped(node) {
16615
+ return node.kind === 11 /* StringLiteral */ ? node.text : unescapeLeadingUnderscores(node.escapedText);
16616
+ }
16617
+ function moduleExportNameTextEscaped(node) {
16618
+ return node.kind === 11 /* StringLiteral */ ? escapeLeadingUnderscores(node.text) : node.escapedText;
16619
+ }
16620
+ function moduleExportNameIsDefault(node) {
16621
+ return (node.kind === 11 /* StringLiteral */ ? node.text : node.escapedText) === "default" /* Default */;
16600
16622
  }
16601
16623
  function getTextOfNodeFromSourceText(sourceText, node, includeTrivia = false) {
16602
16624
  if (nodeIsMissing(node)) {
@@ -30391,6 +30413,9 @@ function isNamedExports(node) {
30391
30413
  function isExportSpecifier(node) {
30392
30414
  return node.kind === 281 /* ExportSpecifier */;
30393
30415
  }
30416
+ function isModuleExportName(node) {
30417
+ return node.kind === 80 /* Identifier */ || node.kind === 11 /* StringLiteral */;
30418
+ }
30394
30419
  function isMissingDeclaration(node) {
30395
30420
  return node.kind === 282 /* MissingDeclaration */;
30396
30421
  }
@@ -31136,6 +31161,9 @@ function getLocalNameForExternalImport(factory2, node, sourceFile) {
31136
31161
  const namespaceDeclaration = getNamespaceDeclarationNode(node);
31137
31162
  if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) {
31138
31163
  const name = namespaceDeclaration.name;
31164
+ if (name.kind === 11 /* StringLiteral */) {
31165
+ return factory2.getGeneratedNameForNode(node);
31166
+ }
31139
31167
  return isGeneratedIdentifier(name) ? name : factory2.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name));
31140
31168
  }
31141
31169
  if (node.kind === 272 /* ImportDeclaration */ && node.importClause) {
@@ -33498,6 +33526,9 @@ var Parser;
33498
33526
  if (token() === 161 /* FromKeyword */ && lookAhead(nextTokenIsStringLiteral)) {
33499
33527
  return false;
33500
33528
  }
33529
+ if (token() === 11 /* StringLiteral */) {
33530
+ return true;
33531
+ }
33501
33532
  return tokenIsIdentifierOrKeyword(token());
33502
33533
  case 13 /* JsxAttributes */:
33503
33534
  return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
@@ -37946,6 +37977,12 @@ var Parser;
37946
37977
  const name = parseIdentifier();
37947
37978
  return finishNode(factory2.createNamespaceImport(name), pos);
37948
37979
  }
37980
+ function canParseModuleExportName() {
37981
+ return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
37982
+ }
37983
+ function parseModuleExportName(parseName) {
37984
+ return token() === 11 /* StringLiteral */ ? parseLiteralNode() : parseName();
37985
+ }
37949
37986
  function parseNamedImportsOrExports(kind) {
37950
37987
  const pos = getNodePos();
37951
37988
  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 */));
@@ -37966,42 +38003,51 @@ var Parser;
37966
38003
  let isTypeOnly = false;
37967
38004
  let propertyName;
37968
38005
  let canParseAsKeyword = true;
37969
- let name = parseIdentifierName();
37970
- if (name.escapedText === "type") {
38006
+ let name = parseModuleExportName(parseIdentifierName);
38007
+ if (name.kind === 80 /* Identifier */ && name.escapedText === "type") {
37971
38008
  if (token() === 130 /* AsKeyword */) {
37972
38009
  const firstAs = parseIdentifierName();
37973
38010
  if (token() === 130 /* AsKeyword */) {
37974
38011
  const secondAs = parseIdentifierName();
37975
- if (tokenIsIdentifierOrKeyword(token())) {
38012
+ if (canParseModuleExportName()) {
37976
38013
  isTypeOnly = true;
37977
38014
  propertyName = firstAs;
37978
- name = parseNameWithKeywordCheck();
38015
+ name = parseModuleExportName(parseNameWithKeywordCheck);
37979
38016
  canParseAsKeyword = false;
37980
38017
  } else {
37981
38018
  propertyName = name;
37982
38019
  name = secondAs;
37983
38020
  canParseAsKeyword = false;
37984
38021
  }
37985
- } else if (tokenIsIdentifierOrKeyword(token())) {
38022
+ } else if (canParseModuleExportName()) {
37986
38023
  propertyName = name;
37987
38024
  canParseAsKeyword = false;
37988
- name = parseNameWithKeywordCheck();
38025
+ name = parseModuleExportName(parseNameWithKeywordCheck);
37989
38026
  } else {
37990
38027
  isTypeOnly = true;
37991
38028
  name = firstAs;
37992
38029
  }
37993
- } else if (tokenIsIdentifierOrKeyword(token())) {
38030
+ } else if (canParseModuleExportName()) {
37994
38031
  isTypeOnly = true;
37995
- name = parseNameWithKeywordCheck();
38032
+ name = parseModuleExportName(parseNameWithKeywordCheck);
37996
38033
  }
37997
38034
  }
37998
38035
  if (canParseAsKeyword && token() === 130 /* AsKeyword */) {
37999
38036
  propertyName = name;
38000
38037
  parseExpected(130 /* AsKeyword */);
38001
- name = parseNameWithKeywordCheck();
38038
+ name = parseModuleExportName(parseNameWithKeywordCheck);
38002
38039
  }
38003
- if (kind === 276 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
38004
- parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
38040
+ if (kind === 276 /* ImportSpecifier */) {
38041
+ if (name.kind !== 80 /* Identifier */) {
38042
+ parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected);
38043
+ name = setTextRangePosEnd(createMissingNode(
38044
+ 80 /* Identifier */,
38045
+ /*reportAtCurrentPosition*/
38046
+ false
38047
+ ), name.pos, name.pos);
38048
+ } else if (checkIdentifierIsKeyword) {
38049
+ parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
38050
+ }
38005
38051
  }
38006
38052
  const node = kind === 276 /* ImportSpecifier */ ? factory2.createImportSpecifier(isTypeOnly, propertyName, name) : factory2.createExportSpecifier(isTypeOnly, propertyName, name);
38007
38053
  return finishNode(node, pos);
@@ -38013,7 +38059,7 @@ var Parser;
38013
38059
  }
38014
38060
  }
38015
38061
  function parseNamespaceExport(pos) {
38016
- return finishNode(factory2.createNamespaceExport(parseIdentifierName()), pos);
38062
+ return finishNode(factory2.createNamespaceExport(parseModuleExportName(parseIdentifierName)), pos);
38017
38063
  }
38018
38064
  function parseExportDeclaration(pos, hasJSDoc, modifiers) {
38019
38065
  const savedAwaitContext = inAwaitContext();
@@ -45774,6 +45820,9 @@ function getModuleInstanceStateWorker(node, visited) {
45774
45820
  }
45775
45821
  function getModuleInstanceStateForAliasTarget(specifier, visited) {
45776
45822
  const name = specifier.propertyName || specifier.name;
45823
+ if (name.kind !== 80 /* Identifier */) {
45824
+ return 1 /* Instantiated */;
45825
+ }
45777
45826
  let p = specifier.parent;
45778
45827
  while (p) {
45779
45828
  if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) {
@@ -46030,7 +46079,7 @@ function createBinder() {
46030
46079
  }
46031
46080
  function declareSymbol(symbolTable, parent3, node, includes, excludes, isReplaceableByMethod, isComputedName) {
46032
46081
  Debug.assert(isComputedName || !hasDynamicName(node));
46033
- const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default";
46082
+ const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && moduleExportNameIsDefault(node.name);
46034
46083
  const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent3 ? "default" /* Default */ : getDeclarationName(node);
46035
46084
  let symbol;
46036
46085
  if (name === void 0) {
@@ -49918,7 +49967,8 @@ function createTypeChecker(host) {
49918
49967
  isUndefinedIdentifierExpression(node) {
49919
49968
  Debug.assert(isExpressionNode(node));
49920
49969
  return getSymbolAtLocation(node) === undefinedSymbol;
49921
- }
49970
+ },
49971
+ isDefinitelyReferenceToGlobalSymbolObject
49922
49972
  });
49923
49973
  var evaluate = createEvaluator({
49924
49974
  evaluateElementAccessExpression,
@@ -50875,6 +50925,21 @@ function createTypeChecker(host) {
50875
50925
  ];
50876
50926
  initializeTypeChecker();
50877
50927
  return checker;
50928
+ function isDefinitelyReferenceToGlobalSymbolObject(node) {
50929
+ if (!isPropertyAccessExpression(node)) return false;
50930
+ if (!isIdentifier(node.name)) return false;
50931
+ if (!isPropertyAccessExpression(node.expression) && !isIdentifier(node.expression)) return false;
50932
+ if (isIdentifier(node.expression)) {
50933
+ return idText(node.expression) === "Symbol" && getResolvedSymbol(node.expression) === (getGlobalSymbol(
50934
+ "Symbol",
50935
+ 111551 /* Value */ | 1048576 /* ExportValue */,
50936
+ /*diagnostic*/
50937
+ void 0
50938
+ ) || unknownSymbol);
50939
+ }
50940
+ if (!isIdentifier(node.expression.expression)) return false;
50941
+ return idText(node.expression.name) === "Symbol" && idText(node.expression.expression) === "globalThis" && getResolvedSymbol(node.expression.expression) === globalThisSymbol;
50942
+ }
50878
50943
  function getCachedType(key) {
50879
50944
  return key ? cachedTypes.get(key) : void 0;
50880
50945
  }
@@ -51903,7 +51968,7 @@ function createTypeChecker(host) {
51903
51968
  const isExport = typeOnlyDeclaration.kind === 281 /* ExportSpecifier */ || typeOnlyDeclaration.kind === 278 /* ExportDeclaration */;
51904
51969
  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;
51905
51970
  const relatedMessage = isExport ? Diagnostics._0_was_exported_here : Diagnostics._0_was_imported_here;
51906
- const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
51971
+ const name = typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? "*" : moduleExportNameTextUnescaped(typeOnlyDeclaration.name);
51907
51972
  addRelatedInfo(error2(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
51908
51973
  }
51909
51974
  }
@@ -52147,12 +52212,12 @@ function createTypeChecker(host) {
52147
52212
  if (valueSymbol.exports) result.exports = new Map(valueSymbol.exports);
52148
52213
  return result;
52149
52214
  }
52150
- function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
52215
+ function getExportOfModule(symbol, nameText, specifier, dontResolveAlias) {
52151
52216
  var _a;
52152
52217
  if (symbol.flags & 1536 /* Module */) {
52153
- const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
52218
+ const exportSymbol = getExportsOfSymbol(symbol).get(nameText);
52154
52219
  const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
52155
- const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(name.escapedText);
52220
+ const exportStarDeclaration = (_a = getSymbolLinks(symbol).typeOnlyExportStarMap) == null ? void 0 : _a.get(nameText);
52156
52221
  markSymbolOfAliasDeclarationIfTypeOnly(
52157
52222
  specifier,
52158
52223
  exportSymbol,
@@ -52160,7 +52225,7 @@ function createTypeChecker(host) {
52160
52225
  /*overwriteEmpty*/
52161
52226
  false,
52162
52227
  exportStarDeclaration,
52163
- name.escapedText
52228
+ nameText
52164
52229
  );
52165
52230
  return resolved;
52166
52231
  }
@@ -52178,10 +52243,11 @@ function createTypeChecker(host) {
52178
52243
  const moduleSpecifier = getExternalModuleRequireArgument(node) || node.moduleSpecifier;
52179
52244
  const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
52180
52245
  const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
52181
- if (!isIdentifier(name)) {
52246
+ if (!isIdentifier(name) && name.kind !== 11 /* StringLiteral */) {
52182
52247
  return void 0;
52183
52248
  }
52184
- const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
52249
+ const nameText = moduleExportNameTextEscaped(name);
52250
+ const suppressInteropError = nameText === "default" /* Default */ && allowSyntheticDefaultImports;
52185
52251
  const targetSymbol = resolveESModuleSymbol(
52186
52252
  moduleSymbol,
52187
52253
  moduleSpecifier,
@@ -52190,7 +52256,7 @@ function createTypeChecker(host) {
52190
52256
  suppressInteropError
52191
52257
  );
52192
52258
  if (targetSymbol) {
52193
- if (name.escapedText) {
52259
+ if (nameText || name.kind === 11 /* StringLiteral */) {
52194
52260
  if (isShorthandAmbientModuleSymbol(moduleSymbol)) {
52195
52261
  return moduleSymbol;
52196
52262
  }
@@ -52198,16 +52264,16 @@ function createTypeChecker(host) {
52198
52264
  if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) {
52199
52265
  symbolFromVariable = getPropertyOfType(
52200
52266
  getTypeOfSymbol(targetSymbol),
52201
- name.escapedText,
52267
+ nameText,
52202
52268
  /*skipObjectFunctionPropertyAugment*/
52203
52269
  true
52204
52270
  );
52205
52271
  } else {
52206
- symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
52272
+ symbolFromVariable = getPropertyOfVariable(targetSymbol, nameText);
52207
52273
  }
52208
52274
  symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
52209
- let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
52210
- if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
52275
+ let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
52276
+ if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
52211
52277
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
52212
52278
  if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
52213
52279
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
@@ -52225,7 +52291,7 @@ function createTypeChecker(host) {
52225
52291
  var _a;
52226
52292
  const moduleName = getFullyQualifiedName(moduleSymbol, node);
52227
52293
  const declarationName = declarationNameToString(name);
52228
- const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
52294
+ const suggestion = isIdentifier(name) ? getSuggestedSymbolForNonexistentModule(name, targetSymbol) : void 0;
52229
52295
  if (suggestion !== void 0) {
52230
52296
  const suggestionName = symbolToString(suggestion);
52231
52297
  const diagnostic = error2(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
@@ -52247,7 +52313,7 @@ function createTypeChecker(host) {
52247
52313
  }
52248
52314
  function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
52249
52315
  var _a, _b;
52250
- const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(name.escapedText);
52316
+ const localSymbol = (_b = (_a = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _a.locals) == null ? void 0 : _b.get(moduleExportNameTextEscaped(name));
52251
52317
  const exports2 = moduleSymbol.exports;
52252
52318
  if (localSymbol) {
52253
52319
  const exportedEqualsSymbol = exports2 == null ? void 0 : exports2.get("export=" /* ExportEquals */);
@@ -52279,7 +52345,7 @@ function createTypeChecker(host) {
52279
52345
  }
52280
52346
  }
52281
52347
  function getTargetOfImportSpecifier(node, dontResolveAlias) {
52282
- if (isImportSpecifier(node) && idText(node.propertyName || node.name) === "default" /* Default */) {
52348
+ if (isImportSpecifier(node) && moduleExportNameIsDefault(node.propertyName || node.name)) {
52283
52349
  const specifier = getModuleSpecifierForImportOrExport(node);
52284
52350
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
52285
52351
  if (moduleSymbol) {
@@ -52323,19 +52389,23 @@ function createTypeChecker(host) {
52323
52389
  }
52324
52390
  }
52325
52391
  function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
52326
- if (idText(node.propertyName || node.name) === "default" /* Default */) {
52392
+ const name = node.propertyName || node.name;
52393
+ if (moduleExportNameIsDefault(name)) {
52327
52394
  const specifier = getModuleSpecifierForImportOrExport(node);
52328
52395
  const moduleSymbol = specifier && resolveExternalModuleName(node, specifier);
52329
52396
  if (moduleSymbol) {
52330
52397
  return getTargetofModuleDefault(moduleSymbol, node, !!dontResolveAlias);
52331
52398
  }
52332
52399
  }
52333
- const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : resolveEntityName(
52334
- node.propertyName || node.name,
52335
- meaning,
52336
- /*ignoreErrors*/
52337
- false,
52338
- dontResolveAlias
52400
+ const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : name.kind === 11 /* StringLiteral */ ? void 0 : (
52401
+ // Skip for invalid syntax like this: export { "x" }
52402
+ resolveEntityName(
52403
+ name,
52404
+ meaning,
52405
+ /*ignoreErrors*/
52406
+ false,
52407
+ dontResolveAlias
52408
+ )
52339
52409
  );
52340
52410
  markSymbolOfAliasDeclarationIfTypeOnly(
52341
52411
  node,
@@ -56932,9 +57002,10 @@ function createTypeChecker(host) {
56932
57002
  if (index >= 0) {
56933
57003
  const exportDecl = statements[index];
56934
57004
  const replacements = mapDefined(exportDecl.exportClause.elements, (e) => {
56935
- if (!e.propertyName) {
57005
+ if (!e.propertyName && e.name.kind !== 11 /* StringLiteral */) {
57006
+ const name = e.name;
56936
57007
  const indices = indicesOf(statements);
56937
- const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], e.name));
57008
+ const associatedIndices = filter(indices, (i) => nodeHasName(statements[i], name));
56938
57009
  if (length(associatedIndices) && every(associatedIndices, (i) => canHaveExportModifier(statements[i]))) {
56939
57010
  for (const index2 of associatedIndices) {
56940
57011
  statements[index2] = addExportModifier(statements[index2]);
@@ -57568,7 +57639,7 @@ function createTypeChecker(host) {
57568
57639
  function getSomeTargetNameFromDeclarations(declarations) {
57569
57640
  return firstDefined(declarations, (d) => {
57570
57641
  if (isImportSpecifier(d) || isExportSpecifier(d)) {
57571
- return idText(d.propertyName || d.name);
57642
+ return moduleExportNameTextUnescaped(d.propertyName || d.name);
57572
57643
  }
57573
57644
  if (isBinaryExpression(d) || isExportAssignment(d)) {
57574
57645
  const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -57586,7 +57657,7 @@ function createTypeChecker(host) {
57586
57657
  });
57587
57658
  }
57588
57659
  function serializeAsAlias(symbol, localName, modifierFlags) {
57589
- var _a2, _b, _c, _d, _e, _f;
57660
+ var _a2, _b, _c, _d, _e;
57590
57661
  const node = getDeclarationOfAliasSymbol(symbol);
57591
57662
  if (!node) return Debug.fail();
57592
57663
  const target = getMergedSymbol(getTargetOfAliasDeclaration(
@@ -57784,8 +57855,11 @@ function createTypeChecker(host) {
57784
57855
  }
57785
57856
  case 281 /* ExportSpecifier */:
57786
57857
  const specifier = node.parent.parent.moduleSpecifier;
57787
- if (specifier && ((_f = node.propertyName) == null ? void 0 : _f.escapedText) === "default" /* Default */) {
57788
- verbatimTargetName = "default" /* Default */;
57858
+ if (specifier) {
57859
+ const propertyName = node.propertyName;
57860
+ if (propertyName && moduleExportNameIsDefault(propertyName)) {
57861
+ verbatimTargetName = "default" /* Default */;
57862
+ }
57789
57863
  }
57790
57864
  serializeExportSpecifier(
57791
57865
  unescapeLeadingUnderscores(symbol.escapedName),
@@ -58498,7 +58572,7 @@ function createTypeChecker(host) {
58498
58572
  }
58499
58573
  function collectLinkedAliases(node, setVisibility) {
58500
58574
  let exportSymbol;
58501
- if (node.parent && node.parent.kind === 277 /* ExportAssignment */) {
58575
+ if (node.kind !== 11 /* StringLiteral */ && node.parent && node.parent.kind === 277 /* ExportAssignment */) {
58502
58576
  exportSymbol = resolveName(
58503
58577
  node,
58504
58578
  node,
@@ -74071,9 +74145,10 @@ function createTypeChecker(host) {
74071
74145
  return;
74072
74146
  case 281 /* ExportSpecifier */:
74073
74147
  const exportDeclaration = node.parent.parent;
74074
- if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
74148
+ const name = node.propertyName || node.name;
74149
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier && name.kind !== 11 /* StringLiteral */) {
74075
74150
  const symbol = resolveEntityName(
74076
- node.propertyName || node.name,
74151
+ name,
74077
74152
  111551 /* Value */,
74078
74153
  /*ignoreErrors*/
74079
74154
  true,
@@ -74367,6 +74442,9 @@ function createTypeChecker(host) {
74367
74442
  function markExportSpecifierAliasReferenced(location) {
74368
74443
  if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) {
74369
74444
  const exportedName = location.propertyName || location.name;
74445
+ if (exportedName.kind === 11 /* StringLiteral */) {
74446
+ return;
74447
+ }
74370
74448
  const symbol = resolveName(
74371
74449
  exportedName,
74372
74450
  exportedName.escapedText,
@@ -74381,7 +74459,7 @@ function createTypeChecker(host) {
74381
74459
  const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
74382
74460
  if (!target || getSymbolFlags(target) & 111551 /* Value */) {
74383
74461
  markExportAsReferenced(location);
74384
- markIdentifierAliasReferenced(location.propertyName || location.name);
74462
+ markIdentifierAliasReferenced(exportedName);
74385
74463
  }
74386
74464
  }
74387
74465
  return;
@@ -87977,6 +88055,16 @@ function createTypeChecker(host) {
87977
88055
  }
87978
88056
  return true;
87979
88057
  }
88058
+ function checkModuleExportName(name, allowStringLiteral = true) {
88059
+ if (name === void 0 || name.kind !== 11 /* StringLiteral */) {
88060
+ return;
88061
+ }
88062
+ if (!allowStringLiteral) {
88063
+ grammarErrorOnNode(name, Diagnostics.Identifier_expected);
88064
+ } else if (moduleKind === 5 /* ES2015 */ || moduleKind === 6 /* ES2020 */) {
88065
+ grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020);
88066
+ }
88067
+ }
87980
88068
  function checkAliasSymbol(node) {
87981
88069
  var _a, _b, _c, _d;
87982
88070
  let symbol = getSymbolOfDeclaration(node);
@@ -87988,7 +88076,7 @@ function createTypeChecker(host) {
87988
88076
  Debug.assert(node.kind !== 280 /* NamespaceExport */);
87989
88077
  if (node.kind === 281 /* ExportSpecifier */) {
87990
88078
  const diag2 = error2(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
87991
- const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get((node.propertyName || node.name).escapedText);
88079
+ const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get(moduleExportNameTextEscaped(node.propertyName || node.name));
87992
88080
  if (alreadyExportedSymbol === target) {
87993
88081
  const exportingDeclaration = (_c = alreadyExportedSymbol.declarations) == null ? void 0 : _c.find(isJSDocNode);
87994
88082
  if (exportingDeclaration) {
@@ -88043,7 +88131,7 @@ function createTypeChecker(host) {
88043
88131
  if (compilerOptions.verbatimModuleSyntax) {
88044
88132
  Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name");
88045
88133
  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;
88046
- const name = idText(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
88134
+ const name = moduleExportNameTextUnescaped(node.kind === 276 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
88047
88135
  addTypeOnlyDeclarationRelatedInfo(
88048
88136
  error2(node, message, name),
88049
88137
  isType ? void 0 : typeOnlyAlias,
@@ -88057,7 +88145,7 @@ function createTypeChecker(host) {
88057
88145
  }
88058
88146
  case 281 /* ExportSpecifier */: {
88059
88147
  if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) {
88060
- const name = idText(node.propertyName || node.name);
88148
+ const name = moduleExportNameTextUnescaped(node.propertyName || node.name);
88061
88149
  const diagnostic = isType ? error2(node, Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type, isolatedModulesLikeFlagName) : error2(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);
88062
88150
  addTypeOnlyDeclarationRelatedInfo(diagnostic, isType ? void 0 : typeOnlyAlias, name);
88063
88151
  break;
@@ -88107,8 +88195,11 @@ function createTypeChecker(host) {
88107
88195
  function checkImportBinding(node) {
88108
88196
  checkCollisionsForDeclarationName(node, node.name);
88109
88197
  checkAliasSymbol(node);
88110
- if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
88111
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
88198
+ if (node.kind === 276 /* ImportSpecifier */) {
88199
+ checkModuleExportName(node.propertyName);
88200
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
88201
+ checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
88202
+ }
88112
88203
  }
88113
88204
  }
88114
88205
  function checkImportAttributes(declaration) {
@@ -88229,6 +88320,7 @@ function createTypeChecker(host) {
88229
88320
  error2(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
88230
88321
  } else if (node.exportClause) {
88231
88322
  checkAliasSymbol(node.exportClause);
88323
+ checkModuleExportName(node.exportClause.name);
88232
88324
  }
88233
88325
  if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
88234
88326
  if (node.exportClause) {
@@ -88259,6 +88351,9 @@ function createTypeChecker(host) {
88259
88351
  }
88260
88352
  function checkExportSpecifier(node) {
88261
88353
  checkAliasSymbol(node);
88354
+ const hasModuleSpecifier = node.parent.parent.moduleSpecifier !== void 0;
88355
+ checkModuleExportName(node.propertyName, hasModuleSpecifier);
88356
+ checkModuleExportName(node.name);
88262
88357
  if (getEmitDeclarations(compilerOptions)) {
88263
88358
  collectLinkedAliases(
88264
88359
  node.propertyName || node.name,
@@ -88266,8 +88361,11 @@ function createTypeChecker(host) {
88266
88361
  true
88267
88362
  );
88268
88363
  }
88269
- if (!node.parent.parent.moduleSpecifier) {
88364
+ if (!hasModuleSpecifier) {
88270
88365
  const exportedName = node.propertyName || node.name;
88366
+ if (exportedName.kind === 11 /* StringLiteral */) {
88367
+ return;
88368
+ }
88271
88369
  const symbol = resolveName(
88272
88370
  exportedName,
88273
88371
  exportedName.escapedText,
@@ -88283,7 +88381,7 @@ function createTypeChecker(host) {
88283
88381
  markLinkedReferences(node, 7 /* ExportSpecifier */);
88284
88382
  }
88285
88383
  } else {
88286
- if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
88384
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
88287
88385
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
88288
88386
  }
88289
88387
  }
@@ -89438,7 +89536,11 @@ function createTypeChecker(host) {
89438
89536
  }
89439
89537
  function getExportSpecifierLocalTargetSymbol(node) {
89440
89538
  if (isExportSpecifier(node)) {
89441
- return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
89539
+ const name = node.propertyName || node.name;
89540
+ return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : name.kind === 11 /* StringLiteral */ ? void 0 : (
89541
+ // Skip for invalid syntax like this: export { "x" }
89542
+ resolveEntityName(name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)
89543
+ );
89442
89544
  } else {
89443
89545
  return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
89444
89546
  }
@@ -90409,7 +90511,8 @@ function createTypeChecker(host) {
90409
90511
  resolveExternalModuleSymbol(sym);
90410
90512
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
90411
90513
  },
90412
- isImportRequiredByAugmentation
90514
+ isImportRequiredByAugmentation,
90515
+ isDefinitelyReferenceToGlobalSymbolObject
90413
90516
  };
90414
90517
  function isImportRequiredByAugmentation(node) {
90415
90518
  const file = getSourceFileOfNode(node);
@@ -92248,7 +92351,7 @@ function isDeclarationNameOrImportPropertyName(name) {
92248
92351
  switch (name.parent.kind) {
92249
92352
  case 276 /* ImportSpecifier */:
92250
92353
  case 281 /* ExportSpecifier */:
92251
- return isIdentifier(name);
92354
+ return isIdentifier(name) || name.kind === 11 /* StringLiteral */;
92252
92355
  default:
92253
92356
  return isDeclarationName(name);
92254
92357
  }
@@ -93493,7 +93596,7 @@ var visitEachChildTable = {
93493
93596
  return context.factory.updateImportSpecifier(
93494
93597
  node,
93495
93598
  node.isTypeOnly,
93496
- nodeVisitor(node.propertyName, visitor, isIdentifier),
93599
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
93497
93600
  Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
93498
93601
  );
93499
93602
  },
@@ -93524,8 +93627,8 @@ var visitEachChildTable = {
93524
93627
  return context.factory.updateExportSpecifier(
93525
93628
  node,
93526
93629
  node.isTypeOnly,
93527
- nodeVisitor(node.propertyName, visitor, isIdentifier),
93528
- Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))
93630
+ nodeVisitor(node.propertyName, visitor, isModuleExportName),
93631
+ Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName))
93529
93632
  );
93530
93633
  },
93531
93634
  // Module references
@@ -94241,7 +94344,7 @@ function containsDefaultReference(node) {
94241
94344
  return some(node.elements, isNamedDefaultReference);
94242
94345
  }
94243
94346
  function isNamedDefaultReference(e) {
94244
- return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
94347
+ return moduleExportNameIsDefault(e.propertyName || e.name);
94245
94348
  }
94246
94349
  function chainBundle(context, transformSourceFile) {
94247
94350
  return transformSourceFileOrBundle;
@@ -94317,9 +94420,10 @@ function collectExternalModuleInfo(context, sourceFile) {
94317
94420
  hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
94318
94421
  } else {
94319
94422
  const name = node.exportClause.name;
94320
- if (!uniqueExports.get(idText(name))) {
94423
+ const nameText = moduleExportNameTextUnescaped(name);
94424
+ if (!uniqueExports.get(nameText)) {
94321
94425
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
94322
- uniqueExports.set(idText(name), true);
94426
+ uniqueExports.set(nameText, true);
94323
94427
  exportedNames = append(exportedNames, name);
94324
94428
  }
94325
94429
  hasImportStar = true;
@@ -94377,20 +94481,23 @@ function collectExternalModuleInfo(context, sourceFile) {
94377
94481
  return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, exportedFunctions, externalHelpersImportDeclaration };
94378
94482
  function addExportedNamesForExportDeclaration(node) {
94379
94483
  for (const specifier of cast(node.exportClause, isNamedExports).elements) {
94380
- if (!uniqueExports.get(idText(specifier.name))) {
94484
+ const specifierNameText = moduleExportNameTextUnescaped(specifier.name);
94485
+ if (!uniqueExports.get(specifierNameText)) {
94381
94486
  const name = specifier.propertyName || specifier.name;
94382
- if (!node.moduleSpecifier) {
94383
- exportSpecifiers.add(name, specifier);
94384
- }
94385
- const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
94386
- if (decl) {
94387
- if (decl.kind === 262 /* FunctionDeclaration */) {
94388
- addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
94389
- continue;
94487
+ if (name.kind !== 11 /* StringLiteral */) {
94488
+ if (!node.moduleSpecifier) {
94489
+ exportSpecifiers.add(name, specifier);
94490
+ }
94491
+ const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
94492
+ if (decl) {
94493
+ if (decl.kind === 262 /* FunctionDeclaration */) {
94494
+ addExportedFunctionDeclaration(decl, specifier.name, moduleExportNameIsDefault(specifier.name));
94495
+ continue;
94496
+ }
94497
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
94390
94498
  }
94391
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
94392
94499
  }
94393
- uniqueExports.set(idText(specifier.name), true);
94500
+ uniqueExports.set(specifierNameText, true);
94394
94501
  exportedNames = append(exportedNames, specifier.name);
94395
94502
  }
94396
94503
  }
@@ -94404,9 +94511,10 @@ function collectExternalModuleInfo(context, sourceFile) {
94404
94511
  }
94405
94512
  } else {
94406
94513
  name ?? (name = node.name);
94407
- if (!uniqueExports.get(idText(name))) {
94514
+ const nameText = moduleExportNameTextUnescaped(name);
94515
+ if (!uniqueExports.get(nameText)) {
94408
94516
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
94409
- uniqueExports.set(idText(name), true);
94517
+ uniqueExports.set(nameText, true);
94410
94518
  }
94411
94519
  }
94412
94520
  }
@@ -111693,7 +111801,7 @@ function transformModule(context) {
111693
111801
  factory2.createExpressionStatement(
111694
111802
  reduceLeft(
111695
111803
  currentModuleInfo.exportedNames.slice(i, i + chunkSize),
111696
- (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev),
111804
+ (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),
111697
111805
  factory2.createVoidZero()
111698
111806
  )
111699
111807
  )
@@ -112016,7 +112124,10 @@ function transformModule(context) {
112016
112124
  append(statements, createUnderscoreUnderscoreESModule());
112017
112125
  }
112018
112126
  if (some(currentModuleInfo.exportedNames)) {
112019
- append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
112127
+ append(
112128
+ statements,
112129
+ 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()))
112130
+ );
112020
112131
  }
112021
112132
  for (const f of currentModuleInfo.exportedFunctions) {
112022
112133
  appendExportsOfHoistedDeclaration(statements, f);
@@ -112887,17 +112998,16 @@ function transformModule(context) {
112887
112998
  );
112888
112999
  }
112889
113000
  for (const specifier of node.exportClause.elements) {
112890
- const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && idText(specifier.propertyName || specifier.name) === "default";
112891
- const exportedValue = factory2.createPropertyAccessExpression(
112892
- exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName,
112893
- specifier.propertyName || specifier.name
112894
- );
113001
+ const specifierName = specifier.propertyName || specifier.name;
113002
+ const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & 2 /* NeverApplyImportHelper */) && moduleExportNameIsDefault(specifierName);
113003
+ const target = exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName;
113004
+ const exportedValue = specifierName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, specifierName) : factory2.createPropertyAccessExpression(target, specifierName);
112895
113005
  statements.push(
112896
113006
  setOriginalNode(
112897
113007
  setTextRange(
112898
113008
  factory2.createExpressionStatement(
112899
113009
  createExportExpression(
112900
- factory2.getExportName(specifier),
113010
+ specifier.name.kind === 11 /* StringLiteral */ ? factory2.cloneNode(specifier.name) : factory2.getExportName(specifier),
112901
113011
  exportedValue,
112902
113012
  /*location*/
112903
113013
  void 0,
@@ -112922,7 +113032,7 @@ function transformModule(context) {
112922
113032
  factory2.cloneNode(node.exportClause.name),
112923
113033
  getHelperExpressionForExport(
112924
113034
  node,
112925
- moduleKind !== 2 /* AMD */ ? createRequireCall2(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
113035
+ moduleKind !== 2 /* AMD */ ? createRequireCall2(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : node.exportClause.name.kind === 11 /* StringLiteral */ ? generatedName : factory2.createIdentifier(idText(node.exportClause.name))
112926
113036
  )
112927
113037
  )
112928
113038
  ),
@@ -113252,10 +113362,13 @@ function transformModule(context) {
113252
113362
  return statements;
113253
113363
  }
113254
113364
  function appendExportStatement(statements, seen, exportName, expression, location, allowComments, liveBinding) {
113255
- if (!seen.has(exportName)) {
113365
+ if (exportName.kind !== 11 /* StringLiteral */) {
113366
+ if (seen.has(exportName)) {
113367
+ return statements;
113368
+ }
113256
113369
  seen.set(exportName, true);
113257
- statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
113258
113370
  }
113371
+ statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
113259
113372
  return statements;
113260
113373
  }
113261
113374
  function createUnderscoreUnderscoreESModule() {
@@ -113325,7 +113438,10 @@ function transformModule(context) {
113325
113438
  ])
113326
113439
  ]
113327
113440
  ) : factory2.createAssignment(
113328
- factory2.createPropertyAccessExpression(
113441
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(
113442
+ factory2.createIdentifier("exports"),
113443
+ factory2.cloneNode(name)
113444
+ ) : factory2.createPropertyAccessExpression(
113329
113445
  factory2.createIdentifier("exports"),
113330
113446
  factory2.cloneNode(name)
113331
113447
  ),
@@ -113461,11 +113577,9 @@ function transformModule(context) {
113461
113577
  );
113462
113578
  } else if (isImportSpecifier(importDeclaration)) {
113463
113579
  const name = importDeclaration.propertyName || importDeclaration.name;
113580
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
113464
113581
  return setTextRange(
113465
- factory2.createPropertyAccessExpression(
113466
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
113467
- factory2.cloneNode(name)
113468
- ),
113582
+ name.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(name)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(name)),
113469
113583
  /*location*/
113470
113584
  node
113471
113585
  );
@@ -113753,7 +113867,7 @@ function transformSystemModule(context) {
113753
113867
  const exportedNames = [];
113754
113868
  if (moduleInfo.exportedNames) {
113755
113869
  for (const exportedLocalName of moduleInfo.exportedNames) {
113756
- if (exportedLocalName.escapedText === "default") {
113870
+ if (moduleExportNameIsDefault(exportedLocalName)) {
113757
113871
  continue;
113758
113872
  }
113759
113873
  exportedNames.push(
@@ -113931,10 +114045,10 @@ function transformSystemModule(context) {
113931
114045
  for (const e of entry.exportClause.elements) {
113932
114046
  properties.push(
113933
114047
  factory2.createPropertyAssignment(
113934
- factory2.createStringLiteral(idText(e.name)),
114048
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.name)),
113935
114049
  factory2.createElementAccessExpression(
113936
114050
  parameterName,
113937
- factory2.createStringLiteral(idText(e.propertyName || e.name))
114051
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(e.propertyName || e.name))
113938
114052
  )
113939
114053
  )
113940
114054
  );
@@ -113961,7 +114075,7 @@ function transformSystemModule(context) {
113961
114075
  /*typeArguments*/
113962
114076
  void 0,
113963
114077
  [
113964
- factory2.createStringLiteral(idText(entry.exportClause.name)),
114078
+ factory2.createStringLiteral(moduleExportNameTextUnescaped(entry.exportClause.name)),
113965
114079
  parameterName
113966
114080
  ]
113967
114081
  )
@@ -114301,7 +114415,7 @@ function transformSystemModule(context) {
114301
114415
  const exportSpecifiers = moduleInfo.exportSpecifiers.get(name);
114302
114416
  if (exportSpecifiers) {
114303
114417
  for (const exportSpecifier of exportSpecifiers) {
114304
- if (exportSpecifier.name.escapedText !== excludeName) {
114418
+ if (moduleExportNameTextUnescaped(exportSpecifier.name) !== excludeName) {
114305
114419
  statements = appendExportStatement(statements, exportSpecifier.name, name);
114306
114420
  }
114307
114421
  }
@@ -114722,13 +114836,12 @@ function transformSystemModule(context) {
114722
114836
  node
114723
114837
  );
114724
114838
  } else if (isImportSpecifier(importDeclaration)) {
114839
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
114840
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
114725
114841
  return setTextRange(
114726
114842
  factory2.createPropertyAssignment(
114727
114843
  factory2.cloneNode(name),
114728
- factory2.createPropertyAccessExpression(
114729
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
114730
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
114731
- )
114844
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName))
114732
114845
  ),
114733
114846
  /*location*/
114734
114847
  node
@@ -114771,11 +114884,10 @@ function transformSystemModule(context) {
114771
114884
  node
114772
114885
  );
114773
114886
  } else if (isImportSpecifier(importDeclaration)) {
114887
+ const importedName = importDeclaration.propertyName || importDeclaration.name;
114888
+ const target = factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration);
114774
114889
  return setTextRange(
114775
- factory2.createPropertyAccessExpression(
114776
- factory2.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) == null ? void 0 : _a.parent) == null ? void 0 : _b.parent) || importDeclaration),
114777
- factory2.cloneNode(importDeclaration.propertyName || importDeclaration.name)
114778
- ),
114890
+ importedName.kind === 11 /* StringLiteral */ ? factory2.createElementAccessExpression(target, factory2.cloneNode(importedName)) : factory2.createPropertyAccessExpression(target, factory2.cloneNode(importedName)),
114779
114891
  /*location*/
114780
114892
  node
114781
114893
  );
@@ -116366,15 +116478,17 @@ function transformDeclarations(context) {
116366
116478
  if (isDeclarationAndNotVisible(input)) return;
116367
116479
  if (hasDynamicName(input)) {
116368
116480
  if (isolatedDeclarations) {
116369
- if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
116370
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
116371
- return;
116372
- } else if (
116373
- // Type declarations just need to double-check that the input computed name is an entity name expression
116374
- (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
116375
- ) {
116376
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
116377
- return;
116481
+ if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
116482
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
116483
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
116484
+ return;
116485
+ } else if (
116486
+ // Type declarations just need to double-check that the input computed name is an entity name expression
116487
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
116488
+ ) {
116489
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
116490
+ return;
116491
+ }
116378
116492
  }
116379
116493
  } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
116380
116494
  return;
@@ -118334,7 +118448,8 @@ var notImplementedResolver = {
118334
118448
  getJsxFragmentFactoryEntity: notImplemented,
118335
118449
  isBindingCapturedByNode: notImplemented,
118336
118450
  getDeclarationStatementsForSourceFile: notImplemented,
118337
- isImportRequiredByAugmentation: notImplemented
118451
+ isImportRequiredByAugmentation: notImplemented,
118452
+ isDefinitelyReferenceToGlobalSymbolObject: notImplemented
118338
118453
  };
118339
118454
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
118340
118455
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -123075,7 +123190,7 @@ function isIgnoredFileFromWildCardWatching({
123075
123190
  }
123076
123191
  return false;
123077
123192
  function hasSourceFile(file) {
123078
- return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.getState().fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
123193
+ return realProgram ? !!realProgram.getSourceFileByPath(file) : builderProgram ? builderProgram.state.fileInfos.has(file) : !!find(program, (rootFile) => toPath3(rootFile) === file);
123079
123194
  }
123080
123195
  function isSupportedScriptKind() {
123081
123196
  if (!getScriptKind2) return false;
@@ -123096,9 +123211,6 @@ function isIgnoredFileFromWildCardWatching({
123096
123211
  }
123097
123212
  }
123098
123213
  }
123099
- function isBuilderProgram(program) {
123100
- return !!program.getState;
123101
- }
123102
123214
  function isEmittedFileOfProgram(program, file) {
123103
123215
  if (!program) {
123104
123216
  return false;
@@ -127722,6 +127834,13 @@ var BuilderFileEmit = /* @__PURE__ */ ((BuilderFileEmit2) => {
127722
127834
  BuilderFileEmit2[BuilderFileEmit2["All"] = 31] = "All";
127723
127835
  return BuilderFileEmit2;
127724
127836
  })(BuilderFileEmit || {});
127837
+ function isBuilderProgramStateWithDefinedProgram(state) {
127838
+ return state.program !== void 0;
127839
+ }
127840
+ function toBuilderProgramStateWithDefinedProgram(state) {
127841
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
127842
+ return state;
127843
+ }
127725
127844
  function getBuilderFileEmit(options) {
127726
127845
  let result = 1 /* Js */;
127727
127846
  if (options.sourceMap) result = result | 2 /* JsMap */;
@@ -127986,7 +128105,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
127986
128105
  const affectedFile = affectedFiles[affectedFilesIndex];
127987
128106
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
127988
128107
  state.affectedFilesIndex = affectedFilesIndex;
127989
- addToAffectedFilesPendingEmit(state, affectedFile.resolvedPath, getBuilderFileEmit(state.compilerOptions));
128108
+ addToAffectedFilesPendingEmit(
128109
+ state,
128110
+ affectedFile.resolvedPath,
128111
+ getBuilderFileEmit(state.compilerOptions)
128112
+ );
127990
128113
  handleDtsMayChangeOfAffectedFile(
127991
128114
  state,
127992
128115
  affectedFile,
@@ -128006,12 +128129,11 @@ function getNextAffectedFile(state, cancellationToken, host) {
128006
128129
  if (nextKey.done) {
128007
128130
  return void 0;
128008
128131
  }
128009
- const program = Debug.checkDefined(state.program);
128010
- const compilerOptions = program.getCompilerOptions();
128011
- if (compilerOptions.outFile) return program;
128132
+ const compilerOptions = state.program.getCompilerOptions();
128133
+ if (compilerOptions.outFile) return state.program;
128012
128134
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
128013
128135
  state,
128014
- program,
128136
+ state.program,
128015
128137
  nextKey.value,
128016
128138
  cancellationToken,
128017
128139
  host
@@ -128072,9 +128194,8 @@ function getNextPendingEmitDiagnosticsFile(state) {
128072
128194
  function removeDiagnosticsOfLibraryFiles(state) {
128073
128195
  if (!state.cleanedDiagnosticsOfLibFiles) {
128074
128196
  state.cleanedDiagnosticsOfLibFiles = true;
128075
- const program = Debug.checkDefined(state.program);
128076
- const options = program.getCompilerOptions();
128077
- forEach(program.getSourceFiles(), (f) => program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
128197
+ const options = state.program.getCompilerOptions();
128198
+ forEach(state.program.getSourceFiles(), (f) => state.program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options, state.program) && removeSemanticDiagnosticsOf(state, f.resolvedPath));
128078
128199
  }
128079
128200
  }
128080
128201
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
@@ -128083,7 +128204,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
128083
128204
  removeDiagnosticsOfLibraryFiles(state);
128084
128205
  BuilderState.updateShapeSignature(
128085
128206
  state,
128086
- Debug.checkDefined(state.program),
128207
+ state.program,
128087
128208
  affectedFile,
128088
128209
  cancellationToken,
128089
128210
  host
@@ -128101,12 +128222,11 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
128101
128222
  function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
128102
128223
  removeSemanticDiagnosticsOf(state, path);
128103
128224
  if (!state.changedFilesSet.has(path)) {
128104
- const program = Debug.checkDefined(state.program);
128105
- const sourceFile = program.getSourceFileByPath(path);
128225
+ const sourceFile = state.program.getSourceFileByPath(path);
128106
128226
  if (sourceFile) {
128107
128227
  BuilderState.updateShapeSignature(
128108
128228
  state,
128109
- program,
128229
+ state.program,
128110
128230
  sourceFile,
128111
128231
  cancellationToken,
128112
128232
  host,
@@ -128114,9 +128234,17 @@ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken,
128114
128234
  true
128115
128235
  );
128116
128236
  if (invalidateJsFiles) {
128117
- addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
128237
+ addToAffectedFilesPendingEmit(
128238
+ state,
128239
+ path,
128240
+ getBuilderFileEmit(state.compilerOptions)
128241
+ );
128118
128242
  } else if (getEmitDeclarations(state.compilerOptions)) {
128119
- addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
128243
+ addToAffectedFilesPendingEmit(
128244
+ state,
128245
+ path,
128246
+ state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */
128247
+ );
128120
128248
  }
128121
128249
  }
128122
128250
  }
@@ -128183,7 +128311,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
128183
128311
  host
128184
128312
  );
128185
128313
  if (isChangedSignature(state, currentPath)) {
128186
- const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
128314
+ const currentSourceFile = state.program.getSourceFileByPath(currentPath);
128187
128315
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
128188
128316
  }
128189
128317
  }
@@ -128232,7 +128360,7 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
128232
128360
  function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
128233
128361
  return concatenate(
128234
128362
  getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
128235
- Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
128363
+ state.program.getProgramDiagnostics(sourceFile)
128236
128364
  );
128237
128365
  }
128238
128366
  function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
@@ -128242,7 +128370,7 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
128242
128370
  if (cachedDiagnostics) {
128243
128371
  return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
128244
128372
  }
128245
- const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
128373
+ const diagnostics = state.program.getBindAndCheckDiagnostics(sourceFile, cancellationToken);
128246
128374
  semanticDiagnosticsPerFile.set(path, diagnostics);
128247
128375
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
128248
128376
  }
@@ -128252,7 +128380,7 @@ function isProgramBundleEmitBuildInfo(info) {
128252
128380
  }
128253
128381
  function getBuildInfo2(state) {
128254
128382
  var _a, _b;
128255
- const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
128383
+ const currentDirectory = state.program.getCurrentDirectory();
128256
128384
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
128257
128385
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
128258
128386
  const fileNames = [];
@@ -128599,24 +128727,27 @@ function computeSignature(text, host, data) {
128599
128727
  return (host.createHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
128600
128728
  }
128601
128729
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
128602
- let oldState = oldProgram && oldProgram.getState();
128730
+ let oldState = oldProgram && oldProgram.state;
128603
128731
  if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
128604
128732
  newProgram = void 0;
128605
128733
  oldState = void 0;
128606
128734
  return oldProgram;
128607
128735
  }
128608
128736
  const state = createBuilderProgramState(newProgram, oldState);
128609
- newProgram.getBuildInfo = () => getBuildInfo2(state);
128737
+ newProgram.getBuildInfo = () => getBuildInfo2(toBuilderProgramStateWithDefinedProgram(state));
128610
128738
  newProgram = void 0;
128611
128739
  oldProgram = void 0;
128612
128740
  oldState = void 0;
128613
- const getState = () => state;
128614
- const builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
128615
- builderProgram.getState = getState;
128741
+ const builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
128742
+ builderProgram.state = state;
128616
128743
  builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
128617
128744
  builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
128618
128745
  builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
128619
- builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(state, Debug.checkDefined(state.program), sourceFile);
128746
+ builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(
128747
+ state,
128748
+ Debug.checkDefined(state.program),
128749
+ sourceFile
128750
+ );
128620
128751
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
128621
128752
  builderProgram.emit = emit;
128622
128753
  builderProgram.releaseProgram = () => releaseCache(state);
@@ -128631,8 +128762,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128631
128762
  }
128632
128763
  return builderProgram;
128633
128764
  function emitBuildInfo(writeFile2, cancellationToken) {
128765
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128634
128766
  if (state.buildInfoEmitPending) {
128635
- const result = Debug.checkDefined(state.program).emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
128767
+ const result = state.program.emitBuildInfo(
128768
+ writeFile2 || maybeBind(host, host.writeFile),
128769
+ cancellationToken
128770
+ );
128636
128771
  state.buildInfoEmitPending = false;
128637
128772
  return result;
128638
128773
  }
@@ -128640,6 +128775,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128640
128775
  }
128641
128776
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
128642
128777
  var _a, _b, _c, _d;
128778
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128643
128779
  let affected = getNextAffectedFile(state, cancellationToken, host);
128644
128780
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
128645
128781
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
@@ -128680,7 +128816,10 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128680
128816
  if (!affected) {
128681
128817
  if (!state.buildInfoEmitPending) return void 0;
128682
128818
  const affected2 = state.program;
128683
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
128819
+ const result2 = affected2.emitBuildInfo(
128820
+ writeFile2 || maybeBind(host, host.writeFile),
128821
+ cancellationToken
128822
+ );
128684
128823
  state.buildInfoEmitPending = false;
128685
128824
  return { result: result2, affected: affected2 };
128686
128825
  }
@@ -128728,6 +128867,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128728
128867
  return { result, affected };
128729
128868
  }
128730
128869
  function getWriteFileCallback(writeFile2, customTransformers) {
128870
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128731
128871
  if (!getEmitDeclarations(state.compilerOptions)) return writeFile2 || maybeBind(host, host.writeFile);
128732
128872
  return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
128733
128873
  var _a, _b, _c;
@@ -128794,6 +128934,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128794
128934
  };
128795
128935
  }
128796
128936
  function emit(targetSourceFile, writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
128937
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128797
128938
  if (kind === 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
128798
128939
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
128799
128940
  }
@@ -128806,7 +128947,12 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128806
128947
  let diagnostics;
128807
128948
  let emittedFiles = [];
128808
128949
  let affectedEmitResult;
128809
- while (affectedEmitResult = emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
128950
+ while (affectedEmitResult = emitNextAffectedFile(
128951
+ writeFile2,
128952
+ cancellationToken,
128953
+ emitOnlyDtsFiles,
128954
+ customTransformers
128955
+ )) {
128810
128956
  emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
128811
128957
  diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics);
128812
128958
  emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
@@ -128822,7 +128968,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128822
128968
  clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles);
128823
128969
  }
128824
128970
  }
128825
- return Debug.checkDefined(state.program).emit(
128971
+ return state.program.emit(
128826
128972
  targetSourceFile,
128827
128973
  getWriteFileCallback(writeFile2, customTransformers),
128828
128974
  cancellationToken,
@@ -128831,6 +128977,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128831
128977
  );
128832
128978
  }
128833
128979
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
128980
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128834
128981
  while (true) {
128835
128982
  const affected = getNextAffectedFile(state, cancellationToken, host);
128836
128983
  let result;
@@ -128868,6 +129015,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128868
129015
  }
128869
129016
  }
128870
129017
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
129018
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
128871
129019
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
128872
129020
  if (sourceFile) {
128873
129021
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
@@ -128878,7 +129026,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
128878
129026
  if (affectedResult.affected === state.program) return affectedResult.result;
128879
129027
  }
128880
129028
  let diagnostics;
128881
- for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
129029
+ for (const sourceFile2 of state.program.getSourceFiles()) {
128882
129030
  diagnostics = addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile2, cancellationToken));
128883
129031
  }
128884
129032
  return diagnostics || emptyArray;
@@ -128963,7 +129111,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
128963
129111
  };
128964
129112
  }
128965
129113
  return {
128966
- getState: () => state,
129114
+ state,
128967
129115
  saveEmitState: noop,
128968
129116
  restoreEmitState: noop,
128969
129117
  getProgram: notImplemented,
@@ -129057,15 +129205,15 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
129057
129205
  }
129058
129206
  }
129059
129207
  }
129060
- function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
129208
+ function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
129061
129209
  return {
129062
- getState: notImplemented,
129210
+ state: void 0,
129063
129211
  saveEmitState: noop,
129064
129212
  restoreEmitState: noop,
129065
129213
  getProgram,
129066
- getProgramOrUndefined: () => getState().program,
129067
- releaseProgram: () => getState().program = void 0,
129068
- getCompilerOptions: () => getState().compilerOptions,
129214
+ getProgramOrUndefined: () => state.program,
129215
+ releaseProgram: () => state.program = void 0,
129216
+ getCompilerOptions: () => state.compilerOptions,
129069
129217
  getSourceFile: (fileName) => getProgram().getSourceFile(fileName),
129070
129218
  getSourceFiles: () => getProgram().getSourceFiles(),
129071
129219
  getOptionsDiagnostics: (cancellationToken) => getProgram().getOptionsDiagnostics(cancellationToken),
@@ -129081,20 +129229,50 @@ function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics)
129081
129229
  close: noop
129082
129230
  };
129083
129231
  function getProgram() {
129084
- return Debug.checkDefined(getState().program);
129232
+ return Debug.checkDefined(state.program);
129085
129233
  }
129086
129234
  }
129087
129235
 
129088
129236
  // src/compiler/builderPublic.ts
129089
129237
  function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
129090
- return createBuilderProgram(0 /* SemanticDiagnosticsBuilderProgram */, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
129238
+ return createBuilderProgram(
129239
+ 0 /* SemanticDiagnosticsBuilderProgram */,
129240
+ getBuilderCreationParameters(
129241
+ newProgramOrRootNames,
129242
+ hostOrOptions,
129243
+ oldProgramOrHost,
129244
+ configFileParsingDiagnosticsOrOldProgram,
129245
+ configFileParsingDiagnostics,
129246
+ projectReferences
129247
+ )
129248
+ );
129091
129249
  }
129092
129250
  function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
129093
- return createBuilderProgram(1 /* EmitAndSemanticDiagnosticsBuilderProgram */, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
129251
+ return createBuilderProgram(
129252
+ 1 /* EmitAndSemanticDiagnosticsBuilderProgram */,
129253
+ getBuilderCreationParameters(
129254
+ newProgramOrRootNames,
129255
+ hostOrOptions,
129256
+ oldProgramOrHost,
129257
+ configFileParsingDiagnosticsOrOldProgram,
129258
+ configFileParsingDiagnostics,
129259
+ projectReferences
129260
+ )
129261
+ );
129094
129262
  }
129095
129263
  function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
129096
- const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences);
129097
- return createRedirectedBuilderProgram(() => ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }), newConfigFileParsingDiagnostics);
129264
+ const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(
129265
+ newProgramOrRootNames,
129266
+ hostOrOptions,
129267
+ oldProgramOrHost,
129268
+ configFileParsingDiagnosticsOrOldProgram,
129269
+ configFileParsingDiagnostics,
129270
+ projectReferences
129271
+ );
129272
+ return createRedirectedBuilderProgram(
129273
+ { program: newProgram, compilerOptions: newProgram.getCompilerOptions() },
129274
+ newConfigFileParsingDiagnostics
129275
+ );
129098
129276
  }
129099
129277
 
129100
129278
  // src/compiler/resolutionCache.ts
@@ -130369,13 +130547,13 @@ function createTabularErrorsDisplay(filesInError, host) {
130369
130547
  });
130370
130548
  return tabularData;
130371
130549
  }
130372
- function isBuilderProgram2(program) {
130373
- return !!program.getState;
130550
+ function isBuilderProgram(program) {
130551
+ return !!program.state;
130374
130552
  }
130375
130553
  function listFiles(program, write) {
130376
130554
  const options = program.getCompilerOptions();
130377
130555
  if (options.explainFiles) {
130378
- explainFiles(isBuilderProgram2(program) ? program.getProgram() : program, write);
130556
+ explainFiles(isBuilderProgram(program) ? program.getProgram() : program, write);
130379
130557
  } else if (options.listFiles || options.listFilesOnly) {
130380
130558
  forEach(program.getSourceFiles(), (file) => {
130381
130559
  write(file.fileName);
@@ -134846,7 +135024,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134846
135024
  expression,
134847
135025
  /*includeBigInt*/
134848
135026
  false
134849
- )) {
135027
+ ) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
134850
135028
  context.tracker.reportInferenceFallback(prop.name);
134851
135029
  result = false;
134852
135030
  }
@@ -143084,9 +143262,9 @@ function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConve
143084
143262
  const namespaceImportName = namespaceNameConflicts ? getUniqueName(preferredName, sourceFile) : preferredName;
143085
143263
  const neededNamedImports = /* @__PURE__ */ new Set();
143086
143264
  for (const element of toConvert.elements) {
143087
- const propertyName = (element.propertyName || element.name).text;
143265
+ const propertyName = element.propertyName || element.name;
143088
143266
  ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, (id) => {
143089
- const access = factory.createPropertyAccessExpression(factory.createIdentifier(namespaceImportName), propertyName);
143267
+ const access = propertyName.kind === 11 /* StringLiteral */ ? factory.createElementAccessExpression(factory.createIdentifier(namespaceImportName), factory.cloneNode(propertyName)) : factory.createPropertyAccessExpression(factory.createIdentifier(namespaceImportName), factory.cloneNode(propertyName));
143090
143268
  if (isShorthandPropertyAssignment(id.parent)) {
143091
143269
  changes.replaceNode(sourceFile, id.parent, factory.createPropertyAssignment(id.text, access));
143092
143270
  } else if (isExportSpecifier(id.parent)) {
@@ -143102,7 +143280,7 @@ function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConve
143102
143280
  shouldUseDefault ? factory.createIdentifier(namespaceImportName) : factory.createNamespaceImport(factory.createIdentifier(namespaceImportName))
143103
143281
  );
143104
143282
  if (neededNamedImports.size && isImportDeclaration(importDecl)) {
143105
- const newNamedImports = arrayFrom(neededNamedImports.values(), (element) => factory.createImportSpecifier(element.isTypeOnly, element.propertyName && factory.createIdentifier(element.propertyName.text), factory.createIdentifier(element.name.text)));
143283
+ const newNamedImports = arrayFrom(neededNamedImports.values(), (element) => factory.createImportSpecifier(element.isTypeOnly, element.propertyName && factory.cloneNode(element.propertyName), factory.cloneNode(element.name)));
143106
143284
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, createImport(
143107
143285
  importDecl,
143108
143286
  /*defaultImportName*/
@@ -163518,10 +163696,18 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
163518
163696
  hasAction = !importStatementCompletion;
163519
163697
  }
163520
163698
  const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports);
163521
- if ((parentNamedImportOrExport == null ? void 0 : parentNamedImportOrExport.kind) === 275 /* NamedImports */) {
163522
- const possibleToken = stringToToken(name);
163523
- if (parentNamedImportOrExport && possibleToken && (possibleToken === 135 /* AwaitKeyword */ || isNonContextualKeyword(possibleToken))) {
163524
- insertText = `${name} as ${name}_`;
163699
+ if (parentNamedImportOrExport) {
163700
+ const languageVersion = getEmitScriptTarget(host.getCompilationSettings());
163701
+ if (!isIdentifierText(name, languageVersion)) {
163702
+ insertText = JSON.stringify(name);
163703
+ if (parentNamedImportOrExport.kind === 275 /* NamedImports */) {
163704
+ insertText += " as " + generateIdentifierForArbitraryString(name, languageVersion);
163705
+ }
163706
+ } else if (parentNamedImportOrExport.kind === 275 /* NamedImports */) {
163707
+ const possibleToken = stringToToken(name);
163708
+ if (possibleToken && (possibleToken === 135 /* AwaitKeyword */ || isNonContextualKeyword(possibleToken))) {
163709
+ insertText = `${name} as ${name}_`;
163710
+ }
163525
163711
  }
163526
163712
  }
163527
163713
  return {
@@ -163544,6 +163730,23 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
163544
163730
  ...includeSymbol ? { symbol } : void 0
163545
163731
  };
163546
163732
  }
163733
+ function generateIdentifierForArbitraryString(text, languageVersion) {
163734
+ let needsUnderscore = false;
163735
+ let identifier = "";
163736
+ let ch;
163737
+ for (let i = 0; i < text.length; i += ch !== void 0 && ch >= 65536 ? 2 : 1) {
163738
+ ch = text.codePointAt(i);
163739
+ if (ch !== void 0 && (i === 0 ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) {
163740
+ if (needsUnderscore) identifier += "_";
163741
+ identifier += String.fromCodePoint(ch);
163742
+ needsUnderscore = false;
163743
+ } else {
163744
+ needsUnderscore = true;
163745
+ }
163746
+ }
163747
+ if (needsUnderscore) identifier += "_";
163748
+ return identifier || "_";
163749
+ }
163547
163750
  function isClassLikeMemberCompletion(symbol, location, sourceFile) {
163548
163751
  if (isInJSFile(location)) {
163549
163752
  return false;
@@ -165375,7 +165578,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165375
165578
  completionKind = 3 /* MemberLike */;
165376
165579
  isNewIdentifierLocation = false;
165377
165580
  const exports2 = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol);
165378
- const existing = new Set(namedImportsOrExports.elements.filter((n) => !isCurrentlyEditingNode(n)).map((n) => (n.propertyName || n.name).escapedText));
165581
+ const existing = new Set(namedImportsOrExports.elements.filter((n) => !isCurrentlyEditingNode(n)).map((n) => moduleExportNameTextEscaped(n.propertyName || n.name)));
165379
165582
  const uniques = exports2.filter((e) => e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName));
165380
165583
  symbols = concatenate(symbols, uniques);
165381
165584
  if (!uniques.length) {
@@ -165866,6 +166069,9 @@ function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, js
165866
166069
  if (isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) {
165867
166070
  return validNameResult;
165868
166071
  }
166072
+ if (symbol.flags & 2097152 /* Alias */) {
166073
+ return { name, needsConvertPropertyAccess: true };
166074
+ }
165869
166075
  switch (kind) {
165870
166076
  case 3 /* MemberLike */:
165871
166077
  return originIsComputedPropertyName(origin) ? { name: origin.symbolName, needsConvertPropertyAccess: false } : void 0;
@@ -166561,6 +166767,21 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, program,
166561
166767
  }
166562
166768
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
166563
166769
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
166770
+ case 276 /* ImportSpecifier */:
166771
+ case 281 /* ExportSpecifier */:
166772
+ const specifier = parent2;
166773
+ if (specifier.propertyName && node !== specifier.propertyName) {
166774
+ return;
166775
+ }
166776
+ const namedImportsOrExports = specifier.parent;
166777
+ const { moduleSpecifier } = namedImportsOrExports.kind === 275 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent;
166778
+ if (!moduleSpecifier) return;
166779
+ const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier);
166780
+ if (!moduleSpecifierSymbol) return;
166781
+ const exports2 = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol);
166782
+ const existing = new Set(namedImportsOrExports.elements.map((n) => moduleExportNameTextEscaped(n.propertyName || n.name)));
166783
+ const uniques = exports2.filter((e) => e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName));
166784
+ return { kind: 1 /* Properties */, symbols: uniques, hasIndexSignature: false };
166564
166785
  default:
166565
166786
  return fromContextualType() || fromContextualType(0 /* None */);
166566
166787
  }
@@ -167531,12 +167752,12 @@ function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, c
167531
167752
  }
167532
167753
  for (const element of namedBindings.elements) {
167533
167754
  const { name, propertyName } = element;
167534
- if (!isNameMatch((propertyName || name).escapedText)) {
167755
+ if (!isNameMatch(moduleExportNameTextEscaped(propertyName || name))) {
167535
167756
  continue;
167536
167757
  }
167537
167758
  if (propertyName) {
167538
167759
  singleReferences.push(propertyName);
167539
- if (!isForRename || name.escapedText === exportSymbol.escapedName) {
167760
+ if (!isForRename || moduleExportNameTextEscaped(name) === exportSymbol.escapedName) {
167540
167761
  addSearch(name, checker.getSymbolAtLocation(name));
167541
167762
  }
167542
167763
  } else {
@@ -168794,8 +169015,8 @@ var Core;
168794
169015
  function shouldAddSingleReference(singleRef, state) {
168795
169016
  if (!hasMatchingMeaning(singleRef, state)) return false;
168796
169017
  if (state.options.use !== 2 /* Rename */) return true;
168797
- if (!isIdentifier(singleRef)) return false;
168798
- return !(isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */);
169018
+ if (!isIdentifier(singleRef) && !isImportOrExportSpecifier(singleRef.parent)) return false;
169019
+ return !(isImportOrExportSpecifier(singleRef.parent) && moduleExportNameIsDefault(singleRef));
168799
169020
  }
168800
169021
  function searchForImportedSymbol(symbol, state) {
168801
169022
  if (!symbol.declarations) return;
@@ -168957,7 +169178,7 @@ var Core;
168957
169178
  case 15 /* NoSubstitutionTemplateLiteral */:
168958
169179
  case 11 /* StringLiteral */: {
168959
169180
  const str = node;
168960
- return (isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isCallExpression(node.parent) && isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node) && str.text.length === searchSymbolName.length;
169181
+ return str.text.length === searchSymbolName.length && (isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isCallExpression(node.parent) && isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node || isImportOrExportSpecifier(node.parent));
168961
169182
  }
168962
169183
  case 9 /* NumericLiteral */:
168963
169184
  return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length;
@@ -169023,7 +169244,7 @@ var Core;
169023
169244
  return;
169024
169245
  }
169025
169246
  if (isExportSpecifier(parent2)) {
169026
- Debug.assert(referenceLocation.kind === 80 /* Identifier */);
169247
+ Debug.assert(referenceLocation.kind === 80 /* Identifier */ || referenceLocation.kind === 11 /* StringLiteral */);
169027
169248
  getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent2, search, state, addReferencesHere);
169028
169249
  return;
169029
169250
  }
@@ -169073,7 +169294,7 @@ var Core;
169073
169294
  return;
169074
169295
  }
169075
169296
  if (!propertyName) {
169076
- if (!(state.options.use === 2 /* Rename */ && name.escapedText === "default" /* Default */)) {
169297
+ if (!(state.options.use === 2 /* Rename */ && moduleExportNameIsDefault(name))) {
169077
169298
  addRef();
169078
169299
  }
169079
169300
  } else if (referenceLocation === propertyName) {
@@ -169089,7 +169310,7 @@ var Core;
169089
169310
  }
169090
169311
  }
169091
169312
  if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) {
169092
- const isDefaultExport = referenceLocation.escapedText === "default" || exportSpecifier.name.escapedText === "default";
169313
+ const isDefaultExport = moduleExportNameIsDefault(referenceLocation) || moduleExportNameIsDefault(exportSpecifier.name);
169093
169314
  const exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */;
169094
169315
  const exportSymbol = Debug.checkDefined(exportSpecifier.symbol);
169095
169316
  const exportInfo = getExportInfo(exportSymbol, exportKind, state.checker);
@@ -170046,7 +170267,7 @@ function getSymbol(node, checker, stopAtAlias) {
170046
170267
  return { symbol, failedAliasResolution };
170047
170268
  }
170048
170269
  function shouldSkipAlias(node, declaration) {
170049
- if (node.kind !== 80 /* Identifier */) {
170270
+ if (node.kind !== 80 /* Identifier */ && (node.kind !== 11 /* StringLiteral */ || !isImportOrExportSpecifier(node.parent))) {
170050
170271
  return false;
170051
170272
  }
170052
170273
  if (node.parent === declaration) {
@@ -172059,7 +172280,7 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
172059
172280
  return isString(moduleSpecifierText) && some(sourceFile.moduleAugmentations, (moduleName) => isStringLiteral(moduleName) && moduleName.text === moduleSpecifierText);
172060
172281
  }
172061
172282
  function getNewImportSpecifiers(namedImports) {
172062
- return flatMap(namedImports, (namedImport) => map(tryGetNamedBindingElements(namedImport), (importSpecifier) => importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText ? factory.updateImportSpecifier(
172283
+ return flatMap(namedImports, (namedImport) => map(tryGetNamedBindingElements(namedImport), (importSpecifier) => importSpecifier.name && importSpecifier.propertyName && moduleExportNameTextEscaped(importSpecifier.name) === moduleExportNameTextEscaped(importSpecifier.propertyName) ? factory.updateImportSpecifier(
172063
172284
  importSpecifier,
172064
172285
  importSpecifier.isTypeOnly,
172065
172286
  /*propertyName*/
@@ -178560,7 +178781,7 @@ __export(ts_exports2, {
178560
178781
  changeFullExtension: () => changeFullExtension,
178561
178782
  changesAffectModuleResolution: () => changesAffectModuleResolution,
178562
178783
  changesAffectingProgramStructure: () => changesAffectingProgramStructure,
178563
- characterToRegularExpressionFlag: () => characterToRegularExpressionFlag,
178784
+ characterCodeToRegularExpressionFlag: () => characterCodeToRegularExpressionFlag,
178564
178785
  childIsDecorated: () => childIsDecorated,
178565
178786
  classElementOrClassElementParameterIsDecorated: () => classElementOrClassElementParameterIsDecorated,
178566
178787
  classHasClassThisAssignment: () => classHasClassThisAssignment,
@@ -179546,7 +179767,7 @@ __export(ts_exports2, {
179546
179767
  isBreakStatement: () => isBreakStatement,
179547
179768
  isBuild: () => isBuild,
179548
179769
  isBuildInfoFile: () => isBuildInfoFile,
179549
- isBuilderProgram: () => isBuilderProgram2,
179770
+ isBuilderProgram: () => isBuilderProgram,
179550
179771
  isBundle: () => isBundle,
179551
179772
  isCallChain: () => isCallChain,
179552
179773
  isCallExpression: () => isCallExpression,
@@ -179895,6 +180116,7 @@ __export(ts_exports2, {
179895
180116
  isModuleBlock: () => isModuleBlock,
179896
180117
  isModuleBody: () => isModuleBody,
179897
180118
  isModuleDeclaration: () => isModuleDeclaration,
180119
+ isModuleExportName: () => isModuleExportName,
179898
180120
  isModuleExportsAccessExpression: () => isModuleExportsAccessExpression,
179899
180121
  isModuleIdentifier: () => isModuleIdentifier,
179900
180122
  isModuleName: () => isModuleName,
@@ -180212,6 +180434,9 @@ __export(ts_exports2, {
180212
180434
  missingFileModifiedTime: () => missingFileModifiedTime,
180213
180435
  modifierToFlag: () => modifierToFlag,
180214
180436
  modifiersToFlags: () => modifiersToFlags,
180437
+ moduleExportNameIsDefault: () => moduleExportNameIsDefault,
180438
+ moduleExportNameTextEscaped: () => moduleExportNameTextEscaped,
180439
+ moduleExportNameTextUnescaped: () => moduleExportNameTextUnescaped,
180215
180440
  moduleOptionDeclaration: () => moduleOptionDeclaration,
180216
180441
  moduleResolutionIsEqualTo: () => moduleResolutionIsEqualTo,
180217
180442
  moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
@@ -180357,7 +180582,7 @@ __export(ts_exports2, {
180357
180582
  reducePathComponents: () => reducePathComponents,
180358
180583
  refactor: () => ts_refactor_exports,
180359
180584
  regExpEscape: () => regExpEscape,
180360
- regularExpressionFlagToCharacter: () => regularExpressionFlagToCharacter,
180585
+ regularExpressionFlagToCharacterCode: () => regularExpressionFlagToCharacterCode,
180361
180586
  relativeComplement: () => relativeComplement,
180362
180587
  removeAllComments: () => removeAllComments,
180363
180588
  removeEmitHelper: () => removeEmitHelper,
@@ -192992,7 +193217,7 @@ if (typeof console !== "undefined") {
192992
193217
  changeFullExtension,
192993
193218
  changesAffectModuleResolution,
192994
193219
  changesAffectingProgramStructure,
192995
- characterToRegularExpressionFlag,
193220
+ characterCodeToRegularExpressionFlag,
192996
193221
  childIsDecorated,
192997
193222
  classElementOrClassElementParameterIsDecorated,
192998
193223
  classHasClassThisAssignment,
@@ -194327,6 +194552,7 @@ if (typeof console !== "undefined") {
194327
194552
  isModuleBlock,
194328
194553
  isModuleBody,
194329
194554
  isModuleDeclaration,
194555
+ isModuleExportName,
194330
194556
  isModuleExportsAccessExpression,
194331
194557
  isModuleIdentifier,
194332
194558
  isModuleName,
@@ -194644,6 +194870,9 @@ if (typeof console !== "undefined") {
194644
194870
  missingFileModifiedTime,
194645
194871
  modifierToFlag,
194646
194872
  modifiersToFlags,
194873
+ moduleExportNameIsDefault,
194874
+ moduleExportNameTextEscaped,
194875
+ moduleExportNameTextUnescaped,
194647
194876
  moduleOptionDeclaration,
194648
194877
  moduleResolutionIsEqualTo,
194649
194878
  moduleResolutionNameAndModeGetter,
@@ -194789,7 +195018,7 @@ if (typeof console !== "undefined") {
194789
195018
  reducePathComponents,
194790
195019
  refactor,
194791
195020
  regExpEscape,
194792
- regularExpressionFlagToCharacter,
195021
+ regularExpressionFlagToCharacterCode,
194793
195022
  relativeComplement,
194794
195023
  removeAllComments,
194795
195024
  removeEmitHelper,