typescript 5.1.0-dev.20230420 → 5.1.0-dev.20230422

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.1";
21
- var version = `${versionMajorMinor}.0-dev.20230420`;
21
+ var version = `${versionMajorMinor}.0-dev.20230422`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3396,10 +3396,8 @@ var SyntaxKind = /* @__PURE__ */ ((SyntaxKind4) => {
3396
3396
  SyntaxKind4[SyntaxKind4["NotEmittedStatement"] = 358] = "NotEmittedStatement";
3397
3397
  SyntaxKind4[SyntaxKind4["PartiallyEmittedExpression"] = 359] = "PartiallyEmittedExpression";
3398
3398
  SyntaxKind4[SyntaxKind4["CommaListExpression"] = 360] = "CommaListExpression";
3399
- SyntaxKind4[SyntaxKind4["MergeDeclarationMarker"] = 361] = "MergeDeclarationMarker";
3400
- SyntaxKind4[SyntaxKind4["EndOfDeclarationMarker"] = 362] = "EndOfDeclarationMarker";
3401
- SyntaxKind4[SyntaxKind4["SyntheticReferenceExpression"] = 363] = "SyntheticReferenceExpression";
3402
- SyntaxKind4[SyntaxKind4["Count"] = 364] = "Count";
3399
+ SyntaxKind4[SyntaxKind4["SyntheticReferenceExpression"] = 361] = "SyntheticReferenceExpression";
3400
+ SyntaxKind4[SyntaxKind4["Count"] = 362] = "Count";
3403
3401
  SyntaxKind4[SyntaxKind4["FirstAssignment"] = 64 /* EqualsToken */] = "FirstAssignment";
3404
3402
  SyntaxKind4[SyntaxKind4["LastAssignment"] = 79 /* CaretEqualsToken */] = "LastAssignment";
3405
3403
  SyntaxKind4[SyntaxKind4["FirstCompoundAssignment"] = 65 /* PlusEqualsToken */] = "FirstCompoundAssignment";
@@ -3891,9 +3889,8 @@ var EmitFlags = /* @__PURE__ */ ((EmitFlags3) => {
3891
3889
  EmitFlags3[EmitFlags3["ReuseTempVariableScope"] = 1048576] = "ReuseTempVariableScope";
3892
3890
  EmitFlags3[EmitFlags3["CustomPrologue"] = 2097152] = "CustomPrologue";
3893
3891
  EmitFlags3[EmitFlags3["NoHoisting"] = 4194304] = "NoHoisting";
3894
- EmitFlags3[EmitFlags3["HasEndOfDeclarationMarker"] = 8388608] = "HasEndOfDeclarationMarker";
3895
- EmitFlags3[EmitFlags3["Iterator"] = 16777216] = "Iterator";
3896
- EmitFlags3[EmitFlags3["NoAsciiEscaping"] = 33554432] = "NoAsciiEscaping";
3892
+ EmitFlags3[EmitFlags3["Iterator"] = 8388608] = "Iterator";
3893
+ EmitFlags3[EmitFlags3["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping";
3897
3894
  return EmitFlags3;
3898
3895
  })(EmitFlags || {});
3899
3896
  var commentPragmas = {
@@ -7704,6 +7701,7 @@ var Diagnostics = {
7704
7701
  Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
7705
7702
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
7706
7703
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
7704
+ Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
7707
7705
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
7708
7706
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
7709
7707
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -11159,7 +11157,7 @@ function isDeclarationStatementKind(kind) {
11159
11157
  return kind === 261 /* FunctionDeclaration */ || kind === 281 /* MissingDeclaration */ || kind === 262 /* ClassDeclaration */ || kind === 263 /* InterfaceDeclaration */ || kind === 264 /* TypeAliasDeclaration */ || kind === 265 /* EnumDeclaration */ || kind === 266 /* ModuleDeclaration */ || kind === 271 /* ImportDeclaration */ || kind === 270 /* ImportEqualsDeclaration */ || kind === 277 /* ExportDeclaration */ || kind === 276 /* ExportAssignment */ || kind === 269 /* NamespaceExportDeclaration */;
11160
11158
  }
11161
11159
  function isStatementKindButNotDeclarationKind(kind) {
11162
- return kind === 251 /* BreakStatement */ || kind === 250 /* ContinueStatement */ || kind === 258 /* DebuggerStatement */ || kind === 245 /* DoStatement */ || kind === 243 /* ExpressionStatement */ || kind === 241 /* EmptyStatement */ || kind === 248 /* ForInStatement */ || kind === 249 /* ForOfStatement */ || kind === 247 /* ForStatement */ || kind === 244 /* IfStatement */ || kind === 255 /* LabeledStatement */ || kind === 252 /* ReturnStatement */ || kind === 254 /* SwitchStatement */ || kind === 256 /* ThrowStatement */ || kind === 257 /* TryStatement */ || kind === 242 /* VariableStatement */ || kind === 246 /* WhileStatement */ || kind === 253 /* WithStatement */ || kind === 358 /* NotEmittedStatement */ || kind === 362 /* EndOfDeclarationMarker */ || kind === 361 /* MergeDeclarationMarker */;
11160
+ return kind === 251 /* BreakStatement */ || kind === 250 /* ContinueStatement */ || kind === 258 /* DebuggerStatement */ || kind === 245 /* DoStatement */ || kind === 243 /* ExpressionStatement */ || kind === 241 /* EmptyStatement */ || kind === 248 /* ForInStatement */ || kind === 249 /* ForOfStatement */ || kind === 247 /* ForStatement */ || kind === 244 /* IfStatement */ || kind === 255 /* LabeledStatement */ || kind === 252 /* ReturnStatement */ || kind === 254 /* SwitchStatement */ || kind === 256 /* ThrowStatement */ || kind === 257 /* TryStatement */ || kind === 242 /* VariableStatement */ || kind === 246 /* WhileStatement */ || kind === 253 /* WithStatement */ || kind === 358 /* NotEmittedStatement */;
11163
11161
  }
11164
11162
  function isDeclaration(node) {
11165
11163
  if (node.kind === 167 /* TypeParameter */) {
@@ -12059,7 +12057,7 @@ function getLiteralText(node, sourceFile, flags) {
12059
12057
  }
12060
12058
  switch (node.kind) {
12061
12059
  case 11 /* StringLiteral */: {
12062
- const escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 33554432 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
12060
+ const escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
12063
12061
  if (node.singleQuote) {
12064
12062
  return "'" + escapeText(node.text, 39 /* singleQuote */) + "'";
12065
12063
  } else {
@@ -12070,7 +12068,7 @@ function getLiteralText(node, sourceFile, flags) {
12070
12068
  case 16 /* TemplateHead */:
12071
12069
  case 17 /* TemplateMiddle */:
12072
12070
  case 18 /* TemplateTail */: {
12073
- const escapeText = flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 33554432 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
12071
+ const escapeText = flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
12074
12072
  const rawText = node.rawText ?? escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */));
12075
12073
  switch (node.kind) {
12076
12074
  case 15 /* NoSubstitutionTemplateLiteral */:
@@ -18383,8 +18381,6 @@ function createNodeFactory(flags, baseFactory2) {
18383
18381
  updatePartiallyEmittedExpression,
18384
18382
  createCommaListExpression,
18385
18383
  updateCommaListExpression,
18386
- createEndOfDeclarationMarker,
18387
- createMergeDeclarationMarker,
18388
18384
  createSyntheticReferenceExpression,
18389
18385
  updateSyntheticReferenceExpression,
18390
18386
  cloneNode,
@@ -21452,20 +21448,8 @@ function createNodeFactory(flags, baseFactory2) {
21452
21448
  function updateCommaListExpression(node, elements) {
21453
21449
  return node.elements !== elements ? update(createCommaListExpression(elements), node) : node;
21454
21450
  }
21455
- function createEndOfDeclarationMarker(original) {
21456
- const node = createBaseNode(362 /* EndOfDeclarationMarker */);
21457
- node.emitNode = {};
21458
- node.original = original;
21459
- return node;
21460
- }
21461
- function createMergeDeclarationMarker(original) {
21462
- const node = createBaseNode(361 /* MergeDeclarationMarker */);
21463
- node.emitNode = {};
21464
- node.original = original;
21465
- return node;
21466
- }
21467
21451
  function createSyntheticReferenceExpression(expression, thisArg) {
21468
- const node = createBaseNode(363 /* SyntheticReferenceExpression */);
21452
+ const node = createBaseNode(361 /* SyntheticReferenceExpression */);
21469
21453
  node.expression = expression;
21470
21454
  node.thisArg = thisArg;
21471
21455
  node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.thisArg);
@@ -21857,8 +21841,8 @@ function createNodeFactory(flags, baseFactory2) {
21857
21841
  function inlineExpressions(expressions) {
21858
21842
  return expressions.length > 10 ? createCommaListExpression(expressions) : reduceLeft(expressions, factory2.createComma);
21859
21843
  }
21860
- function getName(node, allowComments, allowSourceMaps, emitFlags = 0) {
21861
- const nodeName = getNameOfDeclaration(node);
21844
+ function getName(node, allowComments, allowSourceMaps, emitFlags = 0, ignoreAssignedName) {
21845
+ const nodeName = ignoreAssignedName ? node && getNonAssignedNameOfDeclaration(node) : getNameOfDeclaration(node);
21862
21846
  if (nodeName && isIdentifier(nodeName) && !isGeneratedIdentifier(nodeName)) {
21863
21847
  const name = setParent(setTextRange(cloneNode(nodeName), nodeName), nodeName.parent);
21864
21848
  emitFlags |= getEmitFlags(nodeName);
@@ -21875,8 +21859,8 @@ function createNodeFactory(flags, baseFactory2) {
21875
21859
  function getInternalName(node, allowComments, allowSourceMaps) {
21876
21860
  return getName(node, allowComments, allowSourceMaps, 32768 /* LocalName */ | 65536 /* InternalName */);
21877
21861
  }
21878
- function getLocalName(node, allowComments, allowSourceMaps) {
21879
- return getName(node, allowComments, allowSourceMaps, 32768 /* LocalName */);
21862
+ function getLocalName(node, allowComments, allowSourceMaps, ignoreAssignedName) {
21863
+ return getName(node, allowComments, allowSourceMaps, 32768 /* LocalName */, ignoreAssignedName);
21880
21864
  }
21881
21865
  function getExportName(node, allowComments, allowSourceMaps) {
21882
21866
  return getName(node, allowComments, allowSourceMaps, 16384 /* ExportName */);
@@ -24169,7 +24153,7 @@ function isNotEmittedStatement(node) {
24169
24153
  return node.kind === 358 /* NotEmittedStatement */;
24170
24154
  }
24171
24155
  function isSyntheticReference(node) {
24172
- return node.kind === 363 /* SyntheticReferenceExpression */;
24156
+ return node.kind === 361 /* SyntheticReferenceExpression */;
24173
24157
  }
24174
24158
  function isExternalModuleReference(node) {
24175
24159
  return node.kind === 282 /* ExternalModuleReference */;
@@ -32360,7 +32344,9 @@ var Parser;
32360
32344
  const usedBrace = parseOptional(19 /* OpenBraceToken */);
32361
32345
  const pos = getNodePos();
32362
32346
  const expression = parsePropertyAccessEntityNameExpression();
32347
+ scanner.setInJSDocType(true);
32363
32348
  const typeArguments = tryParseTypeArguments();
32349
+ scanner.setInJSDocType(false);
32364
32350
  const node = factory2.createExpressionWithTypeArguments(expression, typeArguments);
32365
32351
  const res = finishNode(node, pos);
32366
32352
  if (usedBrace) {
@@ -37140,13 +37126,12 @@ function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonic
37140
37126
  nonRelativeNameResolutionCache.update(options2);
37141
37127
  }
37142
37128
  }
37143
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
37129
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
37144
37130
  const result = createModuleOrTypeReferenceResolutionCache(
37145
37131
  currentDirectory,
37146
37132
  getCanonicalFileName,
37147
37133
  options,
37148
- /*packageJsonInfoCache*/
37149
- void 0,
37134
+ packageJsonInfoCache,
37150
37135
  getOriginalOrResolvedModuleFileName
37151
37136
  );
37152
37137
  result.getOrCreateCacheForModuleName = (nonRelativeName, mode, redirectedReference) => result.getOrCreateCacheForNonRelativeName(nonRelativeName, mode, redirectedReference);
@@ -37161,6 +37146,12 @@ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanoni
37161
37146
  getOriginalOrResolvedTypeReferenceFileName
37162
37147
  );
37163
37148
  }
37149
+ function getOptionsForLibraryResolution(options) {
37150
+ return { moduleResolution: 2 /* Node10 */, traceResolution: options.traceResolution };
37151
+ }
37152
+ function resolveLibrary(libraryName, resolveFrom, compilerOptions, host, cache) {
37153
+ return resolveModuleName(libraryName, resolveFrom, getOptionsForLibraryResolution(compilerOptions), host, cache);
37154
+ }
37164
37155
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
37165
37156
  var _a, _b, _c;
37166
37157
  const traceEnabled = isTraceEnabled(compilerOptions, host);
@@ -41791,15 +41782,16 @@ function getPreferences({ importModuleSpecifierPreference, importModuleSpecifier
41791
41782
  if (getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */) {
41792
41783
  return preferredEnding === 2 /* JsExtension */ ? [2 /* JsExtension */, 1 /* Index */] : [1 /* Index */, 2 /* JsExtension */];
41793
41784
  }
41785
+ const allowImportingTsExtension = shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName);
41794
41786
  switch (preferredEnding) {
41795
41787
  case 2 /* JsExtension */:
41796
- return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
41788
+ return allowImportingTsExtension ? [2 /* JsExtension */, 3 /* TsExtension */, 0 /* Minimal */, 1 /* Index */] : [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
41797
41789
  case 3 /* TsExtension */:
41798
41790
  return [3 /* TsExtension */, 0 /* Minimal */, 2 /* JsExtension */, 1 /* Index */];
41799
41791
  case 1 /* Index */:
41800
- return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
41792
+ return allowImportingTsExtension ? [1 /* Index */, 0 /* Minimal */, 3 /* TsExtension */, 2 /* JsExtension */] : [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
41801
41793
  case 0 /* Minimal */:
41802
- return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
41794
+ return allowImportingTsExtension ? [0 /* Minimal */, 1 /* Index */, 3 /* TsExtension */, 2 /* JsExtension */] : [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
41803
41795
  default:
41804
41796
  Debug.assertNever(preferredEnding);
41805
41797
  }
@@ -41962,7 +41954,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
41962
41954
  return pathsOnly ? void 0 : relativePath;
41963
41955
  }
41964
41956
  const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
41965
- const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
41957
+ const relativeToBaseUrl = getRelativePathIfInSameVolume(moduleFileName, baseDirectory, getCanonicalFileName);
41966
41958
  if (!relativeToBaseUrl) {
41967
41959
  return pathsOnly ? void 0 : relativePath;
41968
41960
  }
@@ -42170,7 +42162,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
42170
42162
  for (const { ending, value } of candidates) {
42171
42163
  if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
42172
42164
  const matchedStar = value.substring(prefix.length, value.length - suffix.length);
42173
- return key.replace("*", matchedStar);
42165
+ return pathIsRelative(matchedStar) ? void 0 : key.replace("*", matchedStar);
42174
42166
  }
42175
42167
  }
42176
42168
  } else if (some(candidates, (c) => c.ending !== 0 /* Minimal */ && pattern === c.value) || some(candidates, (c) => c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c))) {
@@ -42385,7 +42377,7 @@ function tryGetAnyFileFromPath(host, path) {
42385
42377
  }
42386
42378
  function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
42387
42379
  return mapDefined(rootDirs, (rootDir) => {
42388
- const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
42380
+ const relativePath = getRelativePathIfInSameVolume(path, rootDir, getCanonicalFileName);
42389
42381
  return relativePath !== void 0 && isPathRelativeToParent(relativePath) ? void 0 : relativePath;
42390
42382
  });
42391
42383
  }
@@ -42397,7 +42389,11 @@ function processEnding(fileName, allowedEndings, options, host) {
42397
42389
  if (fileName === noExtension) {
42398
42390
  return fileName;
42399
42391
  }
42400
- if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
42392
+ const jsPriority = allowedEndings.indexOf(2 /* JsExtension */);
42393
+ const tsPriority = allowedEndings.indexOf(3 /* TsExtension */);
42394
+ if (fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".cts" /* Cts */]) && tsPriority !== -1 && tsPriority < jsPriority) {
42395
+ return fileName;
42396
+ } else if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
42401
42397
  return noExtension + getJSExtensionForFile(fileName, options);
42402
42398
  } else if (!fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */]) && fileExtensionIsOneOf(fileName, [".ts" /* Ts */]) && stringContains(fileName, ".d.")) {
42403
42399
  return tryGetRealFileNameForNonJsDeclarationFileName(fileName);
@@ -42416,7 +42412,6 @@ function processEnding(fileName, allowedEndings, options, host) {
42416
42412
  case 3 /* TsExtension */:
42417
42413
  if (isDeclarationFileName(fileName)) {
42418
42414
  const extensionlessPriority = allowedEndings.findIndex((e) => e === 0 /* Minimal */ || e === 1 /* Index */);
42419
- const jsPriority = allowedEndings.indexOf(2 /* JsExtension */);
42420
42415
  return extensionlessPriority !== -1 && extensionlessPriority < jsPriority ? noExtension : noExtension + getJSExtensionForFile(fileName, options);
42421
42416
  }
42422
42417
  return fileName;
@@ -42459,7 +42454,7 @@ function tryGetJSExtensionForFile(fileName, options) {
42459
42454
  return void 0;
42460
42455
  }
42461
42456
  }
42462
- function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
42457
+ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName) {
42463
42458
  const relativePath = getRelativePathToDirectoryOrUrl(
42464
42459
  directoryPath,
42465
42460
  path,
@@ -44169,6 +44164,10 @@ function createTypeChecker(host) {
44169
44164
  if (name === "const" && isConstAssertion(location)) {
44170
44165
  return void 0;
44171
44166
  }
44167
+ if (isModuleDeclaration(location) && lastLocation && location.name === lastLocation) {
44168
+ lastLocation = location;
44169
+ location = location.parent;
44170
+ }
44172
44171
  if (canHaveLocals(location) && location.locals && !isGlobalSourceFile(location)) {
44173
44172
  if (result = lookup(location.locals, name, meaning)) {
44174
44173
  let useResult = true;
@@ -44359,6 +44358,11 @@ function createTypeChecker(host) {
44359
44358
  }
44360
44359
  }
44361
44360
  break;
44361
+ case 280 /* ExportSpecifier */:
44362
+ if (lastLocation && lastLocation === location.propertyName && location.parent.parent.moduleSpecifier) {
44363
+ location = location.parent.parent.parent;
44364
+ }
44365
+ break;
44362
44366
  }
44363
44367
  if (isSelfReferenceLocation(location)) {
44364
44368
  lastSelfReferenceLocation = location;
@@ -47164,7 +47168,7 @@ function createTypeChecker(host) {
47164
47168
  }
47165
47169
  if (type.flags & 128 /* StringLiteral */) {
47166
47170
  context.approximateLength += type.value.length + 2;
47167
- return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 33554432 /* NoAsciiEscaping */));
47171
+ return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
47168
47172
  }
47169
47173
  if (type.flags & 256 /* NumberLiteral */) {
47170
47174
  const value = type.value;
@@ -48052,7 +48056,7 @@ function createTypeChecker(host) {
48052
48056
  const typePredicate = getTypePredicateOfSignature(signature);
48053
48057
  if (typePredicate) {
48054
48058
  const assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? factory.createToken(131 /* AssertsKeyword */) : void 0;
48055
- const parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? setEmitFlags(factory.createIdentifier(typePredicate.parameterName), 33554432 /* NoAsciiEscaping */) : factory.createThisTypeNode();
48059
+ const parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? setEmitFlags(factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : factory.createThisTypeNode();
48056
48060
  const typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
48057
48061
  returnTypeNode = factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
48058
48062
  } else {
@@ -48179,7 +48183,7 @@ function createTypeChecker(host) {
48179
48183
  const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
48180
48184
  const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
48181
48185
  const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
48182
- const name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 80 /* Identifier */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name), 33554432 /* NoAsciiEscaping */) : parameterDeclaration.name.kind === 165 /* QualifiedName */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name.right), 33554432 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol);
48186
+ const name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 80 /* Identifier */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : parameterDeclaration.name.kind === 165 /* QualifiedName */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol);
48183
48187
  const isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */;
48184
48188
  const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
48185
48189
  const parameterNode = factory.createParameterDeclaration(
@@ -48220,7 +48224,7 @@ function createTypeChecker(host) {
48220
48224
  if (!nodeIsSynthesized(visited)) {
48221
48225
  visited = factory.cloneNode(visited);
48222
48226
  }
48223
- return setEmitFlags(visited, 1 /* SingleLine */ | 33554432 /* NoAsciiEscaping */);
48227
+ return setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */);
48224
48228
  }
48225
48229
  }
48226
48230
  }
@@ -48545,7 +48549,7 @@ function createTypeChecker(host) {
48545
48549
  return factory.createIndexedAccessTypeNode(factory.createTypeReferenceNode(LHS, typeParameterNodes), factory.createLiteralTypeNode(factory.createStringLiteral(symbolName2)));
48546
48550
  }
48547
48551
  }
48548
- const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 33554432 /* NoAsciiEscaping */);
48552
+ const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
48549
48553
  if (typeParameterNodes)
48550
48554
  setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
48551
48555
  identifier.symbol = symbol2;
@@ -48631,7 +48635,7 @@ function createTypeChecker(host) {
48631
48635
  if (index === 0) {
48632
48636
  context.flags ^= 16777216 /* InInitialEntityName */;
48633
48637
  }
48634
- const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 33554432 /* NoAsciiEscaping */);
48638
+ const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
48635
48639
  if (typeParameterNodes)
48636
48640
  setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
48637
48641
  identifier.symbol = symbol2;
@@ -48656,7 +48660,7 @@ function createTypeChecker(host) {
48656
48660
  return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
48657
48661
  }
48658
48662
  if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
48659
- const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 33554432 /* NoAsciiEscaping */);
48663
+ const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
48660
48664
  if (typeParameterNodes)
48661
48665
  setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
48662
48666
  identifier.symbol = symbol2;
@@ -48673,7 +48677,7 @@ function createTypeChecker(host) {
48673
48677
  expression = factory.createNumericLiteral(+symbolName2);
48674
48678
  }
48675
48679
  if (!expression) {
48676
- const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 33554432 /* NoAsciiEscaping */);
48680
+ const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
48677
48681
  if (typeParameterNodes)
48678
48682
  setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
48679
48683
  identifier.symbol = symbol2;
@@ -48826,7 +48830,7 @@ function createTypeChecker(host) {
48826
48830
  const type = getDeclaredTypeOfSymbol(sym);
48827
48831
  const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
48828
48832
  name.symbol = sym;
48829
- return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 33554432 /* NoAsciiEscaping */) };
48833
+ return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
48830
48834
  }
48831
48835
  }
48832
48836
  return { introducesError, node };
@@ -54309,7 +54313,8 @@ function createTypeChecker(host) {
54309
54313
  thisParameter = createSymbolWithType(createSymbol(1 /* FunctionScopedVariable */, "this" /* This */), getTypeFromTypeNode(thisTag.typeExpression));
54310
54314
  }
54311
54315
  }
54312
- const classType = declaration.kind === 175 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : void 0;
54316
+ const hostDeclaration = isJSDocSignature(declaration) ? getEffectiveJSDocHost(declaration) : declaration;
54317
+ const classType = hostDeclaration && isConstructorDeclaration(hostDeclaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(hostDeclaration.parent.symbol)) : void 0;
54313
54318
  const typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
54314
54319
  if (hasRestParameter(declaration) || isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
54315
54320
  flags |= 1 /* HasRestParameter */;
@@ -81038,6 +81043,41 @@ function createTypeChecker(host) {
81038
81043
  }
81039
81044
  return void 0;
81040
81045
  }
81046
+ function getReferencedValueDeclarations(referenceIn) {
81047
+ if (!isGeneratedIdentifier(referenceIn)) {
81048
+ const reference = getParseTreeNode(referenceIn, isIdentifier);
81049
+ if (reference) {
81050
+ const symbol = getReferencedValueSymbol(reference);
81051
+ if (symbol) {
81052
+ return filter(getExportSymbolOfValueSymbolIfExported(symbol).declarations, (declaration) => {
81053
+ switch (declaration.kind) {
81054
+ case 259 /* VariableDeclaration */:
81055
+ case 168 /* Parameter */:
81056
+ case 207 /* BindingElement */:
81057
+ case 171 /* PropertyDeclaration */:
81058
+ case 302 /* PropertyAssignment */:
81059
+ case 303 /* ShorthandPropertyAssignment */:
81060
+ case 305 /* EnumMember */:
81061
+ case 209 /* ObjectLiteralExpression */:
81062
+ case 261 /* FunctionDeclaration */:
81063
+ case 217 /* FunctionExpression */:
81064
+ case 218 /* ArrowFunction */:
81065
+ case 262 /* ClassDeclaration */:
81066
+ case 230 /* ClassExpression */:
81067
+ case 265 /* EnumDeclaration */:
81068
+ case 173 /* MethodDeclaration */:
81069
+ case 176 /* GetAccessor */:
81070
+ case 177 /* SetAccessor */:
81071
+ case 266 /* ModuleDeclaration */:
81072
+ return true;
81073
+ }
81074
+ return false;
81075
+ });
81076
+ }
81077
+ }
81078
+ }
81079
+ return void 0;
81080
+ }
81041
81081
  function isLiteralConstDeclaration(node) {
81042
81082
  if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node)) {
81043
81083
  return isFreshLiteralType(getTypeOfSymbol(getSymbolOfDeclaration(node)));
@@ -81136,6 +81176,7 @@ function createTypeChecker(host) {
81136
81176
  },
81137
81177
  collectLinkedAliases,
81138
81178
  getReferencedValueDeclaration,
81179
+ getReferencedValueDeclarations,
81139
81180
  getTypeReferenceSerializationKind,
81140
81181
  isOptionalParameter,
81141
81182
  moduleExportsSomeValue,
@@ -85008,7 +85049,7 @@ function collectExternalModuleInfo(context, sourceFile, resolver, compilerOption
85008
85049
  case 242 /* VariableStatement */:
85009
85050
  if (hasSyntacticModifier(node, 1 /* Export */)) {
85010
85051
  for (const decl of node.declarationList.declarations) {
85011
- exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
85052
+ exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings);
85012
85053
  }
85013
85054
  }
85014
85055
  break;
@@ -85070,11 +85111,11 @@ function collectExternalModuleInfo(context, sourceFile, resolver, compilerOption
85070
85111
  }
85071
85112
  }
85072
85113
  }
85073
- function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
85114
+ function collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings) {
85074
85115
  if (isBindingPattern(decl.name)) {
85075
85116
  for (const element of decl.name.elements) {
85076
85117
  if (!isOmittedExpression(element)) {
85077
- exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
85118
+ exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames, exportedBindings);
85078
85119
  }
85079
85120
  }
85080
85121
  } else if (!isGeneratedIdentifier(decl.name)) {
@@ -85082,6 +85123,9 @@ function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
85082
85123
  if (!uniqueExports.get(text)) {
85083
85124
  uniqueExports.set(text, true);
85084
85125
  exportedNames = append(exportedNames, decl.name);
85126
+ if (isLocalName(decl.name)) {
85127
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), decl.name);
85128
+ }
85085
85129
  }
85086
85130
  }
85087
85131
  return exportedNames;
@@ -86196,7 +86240,7 @@ function transformTypeScript(context) {
86196
86240
  if (promoteToIIFE) {
86197
86241
  context.startLexicalEnvironment();
86198
86242
  }
86199
- const moveModifiers = promoteToIIFE || facts & 8 /* IsExportOfNamespace */ || facts & 2 /* HasClassOrConstructorParameterDecorators */ && legacyDecorators || facts & 1 /* HasStaticInitializedProperties */;
86243
+ const moveModifiers = promoteToIIFE || facts & 8 /* IsExportOfNamespace */;
86200
86244
  let modifiers = moveModifiers ? visitNodes2(node.modifiers, modifierElidingVisitor, isModifierLike) : visitNodes2(node.modifiers, visitor, isModifierLike);
86201
86245
  if (facts & 2 /* HasClassOrConstructorParameterDecorators */) {
86202
86246
  modifiers = injectClassTypeMetadata(modifiers, node);
@@ -86262,13 +86306,13 @@ function transformTypeScript(context) {
86262
86306
  }
86263
86307
  if (moveModifiers) {
86264
86308
  if (facts & 8 /* IsExportOfNamespace */) {
86265
- return demarcateMultiStatementExport(
86309
+ return [
86266
86310
  statement,
86267
86311
  createExportMemberAssignmentStatement(node)
86268
- );
86312
+ ];
86269
86313
  }
86270
86314
  if (facts & 32 /* IsDefaultExternalExport */) {
86271
- return demarcateMultiStatementExport(
86315
+ return [
86272
86316
  statement,
86273
86317
  factory2.createExportDefault(factory2.getLocalName(
86274
86318
  node,
@@ -86277,10 +86321,10 @@ function transformTypeScript(context) {
86277
86321
  /*allowSourceMaps*/
86278
86322
  true
86279
86323
  ))
86280
- );
86324
+ ];
86281
86325
  }
86282
86326
  if (facts & 16 /* IsNamedExternalExport */ && !promoteToIIFE) {
86283
- return demarcateMultiStatementExport(
86327
+ return [
86284
86328
  statement,
86285
86329
  factory2.createExternalModuleExport(factory2.getLocalName(
86286
86330
  node,
@@ -86289,19 +86333,11 @@ function transformTypeScript(context) {
86289
86333
  /*allowSourceMaps*/
86290
86334
  true
86291
86335
  ))
86292
- );
86336
+ ];
86293
86337
  }
86294
86338
  }
86295
86339
  return statement;
86296
86340
  }
86297
- function demarcateMultiStatementExport(declarationStatement, exportStatement) {
86298
- addEmitFlags(declarationStatement, 8388608 /* HasEndOfDeclarationMarker */);
86299
- return [
86300
- declarationStatement,
86301
- exportStatement,
86302
- factory2.createEndOfDeclarationMarker(declarationStatement)
86303
- ];
86304
- }
86305
86341
  function visitClassExpression(node) {
86306
86342
  let modifiers = visitNodes2(node.modifiers, modifierElidingVisitor, isModifierLike);
86307
86343
  if (classOrConstructorParameterIsDecorated(legacyDecorators, node)) {
@@ -86919,14 +86955,14 @@ function transformTypeScript(context) {
86919
86955
  }
86920
86956
  const parameterName = getNamespaceParameterName(node);
86921
86957
  const containerName = getNamespaceContainerName(node);
86922
- const exportName = hasSyntacticModifier(node, 1 /* Export */) ? factory2.getExternalModuleOrNamespaceExportName(
86958
+ const exportName = isExportOfNamespace(node) ? factory2.getExternalModuleOrNamespaceExportName(
86923
86959
  currentNamespaceContainerName,
86924
86960
  node,
86925
86961
  /*allowComments*/
86926
86962
  false,
86927
86963
  /*allowSourceMaps*/
86928
86964
  true
86929
- ) : factory2.getLocalName(
86965
+ ) : factory2.getDeclarationName(
86930
86966
  node,
86931
86967
  /*allowComments*/
86932
86968
  false,
@@ -86940,7 +86976,7 @@ function transformTypeScript(context) {
86940
86976
  factory2.createObjectLiteralExpression()
86941
86977
  )
86942
86978
  );
86943
- if (hasNamespaceQualifiedExportName(node)) {
86979
+ if (isExportOfNamespace(node)) {
86944
86980
  const localName = factory2.getLocalName(
86945
86981
  node,
86946
86982
  /*allowComments*/
@@ -86985,7 +87021,6 @@ function transformTypeScript(context) {
86985
87021
  setTextRange(enumStatement, node);
86986
87022
  addEmitFlags(enumStatement, emitFlags);
86987
87023
  statements.push(enumStatement);
86988
- statements.push(factory2.createEndOfDeclarationMarker(node));
86989
87024
  return statements;
86990
87025
  }
86991
87026
  function transformEnumBody(node, localName) {
@@ -87058,9 +87093,6 @@ function transformTypeScript(context) {
87058
87093
  }
87059
87094
  return isInstantiatedModule(node, shouldPreserveConstEnums(compilerOptions));
87060
87095
  }
87061
- function hasNamespaceQualifiedExportName(node) {
87062
- return isExportOfNamespace(node) || isExternalModuleExport(node) && moduleKind !== 5 /* ES2015 */ && moduleKind !== 6 /* ES2020 */ && moduleKind !== 7 /* ES2022 */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 4 /* System */;
87063
- }
87064
87096
  function recordEmittedDeclarationInScope(node) {
87065
87097
  if (!currentScopeFirstDeclarationsOfName) {
87066
87098
  currentScopeFirstDeclarationsOfName = /* @__PURE__ */ new Map();
@@ -87082,20 +87114,21 @@ function transformTypeScript(context) {
87082
87114
  return node.name.escapedText;
87083
87115
  }
87084
87116
  function addVarForEnumOrModuleDeclaration(statements, node) {
87117
+ const varDecl = factory2.createVariableDeclaration(factory2.getLocalName(
87118
+ node,
87119
+ /*allowComments*/
87120
+ false,
87121
+ /*allowSourceMaps*/
87122
+ true
87123
+ ));
87124
+ const varFlags = currentLexicalScope.kind === 311 /* SourceFile */ ? 0 /* None */ : 1 /* Let */;
87085
87125
  const statement = factory2.createVariableStatement(
87086
87126
  visitNodes2(node.modifiers, modifierVisitor, isModifier),
87087
- factory2.createVariableDeclarationList([
87088
- factory2.createVariableDeclaration(
87089
- factory2.getLocalName(
87090
- node,
87091
- /*allowComments*/
87092
- false,
87093
- /*allowSourceMaps*/
87094
- true
87095
- )
87096
- )
87097
- ], currentLexicalScope.kind === 311 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)
87127
+ factory2.createVariableDeclarationList([varDecl], varFlags)
87098
87128
  );
87129
+ setOriginalNode(varDecl, node);
87130
+ setSyntheticLeadingComments(varDecl, void 0);
87131
+ setSyntheticTrailingComments(varDecl, void 0);
87099
87132
  setOriginalNode(statement, node);
87100
87133
  recordEmittedDeclarationInScope(node);
87101
87134
  if (isFirstEmittedDeclarationInScope(node)) {
@@ -87105,15 +87138,11 @@ function transformTypeScript(context) {
87105
87138
  setSourceMapRange(statement, node);
87106
87139
  }
87107
87140
  setCommentRange(statement, node);
87108
- addEmitFlags(statement, 2048 /* NoTrailingComments */ | 8388608 /* HasEndOfDeclarationMarker */);
87141
+ addEmitFlags(statement, 2048 /* NoTrailingComments */);
87109
87142
  statements.push(statement);
87110
87143
  return true;
87111
- } else {
87112
- const mergeMarker = factory2.createMergeDeclarationMarker(statement);
87113
- setEmitFlags(mergeMarker, 3072 /* NoComments */ | 8388608 /* HasEndOfDeclarationMarker */);
87114
- statements.push(mergeMarker);
87115
- return false;
87116
87144
  }
87145
+ return false;
87117
87146
  }
87118
87147
  function visitModuleDeclaration(node) {
87119
87148
  if (!shouldEmitModuleDeclaration(node)) {
@@ -87131,14 +87160,14 @@ function transformTypeScript(context) {
87131
87160
  }
87132
87161
  const parameterName = getNamespaceParameterName(node);
87133
87162
  const containerName = getNamespaceContainerName(node);
87134
- const exportName = hasSyntacticModifier(node, 1 /* Export */) ? factory2.getExternalModuleOrNamespaceExportName(
87163
+ const exportName = isExportOfNamespace(node) ? factory2.getExternalModuleOrNamespaceExportName(
87135
87164
  currentNamespaceContainerName,
87136
87165
  node,
87137
87166
  /*allowComments*/
87138
87167
  false,
87139
87168
  /*allowSourceMaps*/
87140
87169
  true
87141
- ) : factory2.getLocalName(
87170
+ ) : factory2.getDeclarationName(
87142
87171
  node,
87143
87172
  /*allowComments*/
87144
87173
  false,
@@ -87152,7 +87181,7 @@ function transformTypeScript(context) {
87152
87181
  factory2.createObjectLiteralExpression()
87153
87182
  )
87154
87183
  );
87155
- if (hasNamespaceQualifiedExportName(node)) {
87184
+ if (isExportOfNamespace(node)) {
87156
87185
  const localName = factory2.getLocalName(
87157
87186
  node,
87158
87187
  /*allowComments*/
@@ -87197,7 +87226,6 @@ function transformTypeScript(context) {
87197
87226
  setTextRange(moduleStatement, node);
87198
87227
  addEmitFlags(moduleStatement, emitFlags);
87199
87228
  statements.push(moduleStatement);
87200
- statements.push(factory2.createEndOfDeclarationMarker(node));
87201
87229
  return statements;
87202
87230
  }
87203
87231
  function transformModuleBody(node, namespaceLocalName) {
@@ -88783,23 +88811,12 @@ function transformClassFields(context) {
88783
88811
  getClassLexicalEnvironment().classThis = node.emitNode.classThis;
88784
88812
  }
88785
88813
  }
88786
- const modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier);
88814
+ const isExport = hasSyntacticModifier(node, 1 /* Export */);
88815
+ const isDefault = hasSyntacticModifier(node, 1024 /* Default */);
88816
+ let modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier);
88787
88817
  const heritageClauses = visitNodes2(node.heritageClauses, heritageClauseVisitor, isHeritageClause);
88788
88818
  const { members, prologue } = transformClassMembers(node);
88789
- const classDecl = factory2.updateClassDeclaration(
88790
- node,
88791
- modifiers,
88792
- node.name,
88793
- /*typeParameters*/
88794
- void 0,
88795
- heritageClauses,
88796
- members
88797
- );
88798
88819
  const statements = [];
88799
- if (prologue) {
88800
- statements.push(factory2.createExpressionStatement(prologue));
88801
- }
88802
- statements.push(classDecl);
88803
88820
  if (pendingClassReferenceAssignment) {
88804
88821
  getPendingExpressions().unshift(pendingClassReferenceAssignment);
88805
88822
  }
@@ -88812,6 +88829,35 @@ function transformClassFields(context) {
88812
88829
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory2.getInternalName(node));
88813
88830
  }
88814
88831
  }
88832
+ if (statements.length > 0 && isExport && isDefault) {
88833
+ modifiers = visitNodes2(modifiers, (node2) => isExportOrDefaultModifier(node2) ? void 0 : node2, isModifier);
88834
+ statements.push(factory2.createExportAssignment(
88835
+ /*modifiers*/
88836
+ void 0,
88837
+ /*isExportEquals*/
88838
+ false,
88839
+ factory2.getLocalName(
88840
+ node,
88841
+ /*allowComments*/
88842
+ false,
88843
+ /*allowSourceMaps*/
88844
+ true
88845
+ )
88846
+ ));
88847
+ }
88848
+ const classDecl = factory2.updateClassDeclaration(
88849
+ node,
88850
+ modifiers,
88851
+ node.name,
88852
+ /*typeParameters*/
88853
+ void 0,
88854
+ heritageClauses,
88855
+ members
88856
+ );
88857
+ statements.unshift(classDecl);
88858
+ if (prologue) {
88859
+ statements.unshift(factory2.createExpressionStatement(prologue));
88860
+ }
88815
88861
  return statements;
88816
88862
  }
88817
88863
  function visitClassExpression(node, referencedName) {
@@ -90249,10 +90295,6 @@ function transformLegacyDecorators(context) {
90249
90295
  true,
90250
90296
  node
90251
90297
  ) ? transformClassDeclarationWithClassDecorators(node, node.name) : transformClassDeclarationWithoutClassDecorators(node, node.name);
90252
- if (statements.length > 1) {
90253
- statements.push(factory2.createEndOfDeclarationMarker(node));
90254
- setEmitFlags(statements[0], getEmitFlags(statements[0]) | 8388608 /* HasEndOfDeclarationMarker */);
90255
- }
90256
90298
  return singleOrMany(statements);
90257
90299
  }
90258
90300
  function decoratorContainsPrivateIdentifierInExpression(decorator) {
@@ -90325,9 +90367,12 @@ function transformLegacyDecorators(context) {
90325
90367
  return addRange([updated], decorationStatements);
90326
90368
  }
90327
90369
  function transformClassDeclarationWithClassDecorators(node, name) {
90370
+ const isExport = hasSyntacticModifier(node, 1 /* Export */);
90371
+ const isDefault = hasSyntacticModifier(node, 1024 /* Default */);
90372
+ const modifiers = visitNodes2(node.modifiers, (node2) => isExportOrDefaultModifier(node2) || isDecorator(node2) ? void 0 : node2, isModifierLike);
90328
90373
  const location = moveRangePastModifiers(node);
90329
90374
  const classAlias = getClassAliasIfNeeded(node);
90330
- const declName = languageVersion <= 2 /* ES2015 */ ? factory2.getInternalName(
90375
+ const declName = languageVersion < 2 /* ES2015 */ ? factory2.getInternalName(
90331
90376
  node,
90332
90377
  /*allowComments*/
90333
90378
  false,
@@ -90345,8 +90390,7 @@ function transformLegacyDecorators(context) {
90345
90390
  let decorationStatements = [];
90346
90391
  ({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members));
90347
90392
  const classExpression = factory2.createClassExpression(
90348
- /*modifiers*/
90349
- void 0,
90393
+ modifiers,
90350
90394
  name && isGeneratedIdentifier(name) ? void 0 : name,
90351
90395
  /*typeParameters*/
90352
90396
  void 0,
@@ -90355,18 +90399,23 @@ function transformLegacyDecorators(context) {
90355
90399
  );
90356
90400
  setOriginalNode(classExpression, node);
90357
90401
  setTextRange(classExpression, location);
90358
- const statement = factory2.createVariableStatement(
90359
- /*modifiers*/
90402
+ const varDecl = factory2.createVariableDeclaration(
90403
+ declName,
90404
+ /*exclamationToken*/
90405
+ void 0,
90406
+ /*type*/
90360
90407
  void 0,
90408
+ classAlias ? factory2.createAssignment(classAlias, classExpression) : classExpression
90409
+ );
90410
+ setOriginalNode(varDecl, node);
90411
+ let varModifiers;
90412
+ if (isExport && !isDefault) {
90413
+ varModifiers = factory2.createModifiersFromModifierFlags(1 /* Export */);
90414
+ }
90415
+ const statement = factory2.createVariableStatement(
90416
+ varModifiers,
90361
90417
  factory2.createVariableDeclarationList([
90362
- factory2.createVariableDeclaration(
90363
- declName,
90364
- /*exclamationToken*/
90365
- void 0,
90366
- /*type*/
90367
- void 0,
90368
- classAlias ? factory2.createAssignment(classAlias, classExpression) : classExpression
90369
- )
90418
+ varDecl
90370
90419
  ], 1 /* Let */)
90371
90420
  );
90372
90421
  setOriginalNode(statement, node);
@@ -90375,6 +90424,15 @@ function transformLegacyDecorators(context) {
90375
90424
  const statements = [statement];
90376
90425
  addRange(statements, decorationStatements);
90377
90426
  addConstructorDecorationStatement(statements, node);
90427
+ if (isExport && isDefault) {
90428
+ statements.push(factory2.createExportAssignment(
90429
+ /*modifiers*/
90430
+ void 0,
90431
+ /*isExportEquals*/
90432
+ false,
90433
+ declName
90434
+ ));
90435
+ }
90378
90436
  return statements;
90379
90437
  }
90380
90438
  function visitClassExpression(node) {
@@ -90551,13 +90609,13 @@ function transformLegacyDecorators(context) {
90551
90609
  return void 0;
90552
90610
  }
90553
90611
  const classAlias = classAliases && classAliases[getOriginalNodeId(node)];
90554
- const localName = languageVersion <= 2 /* ES2015 */ ? factory2.getInternalName(
90612
+ const localName = languageVersion < 2 /* ES2015 */ ? factory2.getInternalName(
90555
90613
  node,
90556
90614
  /*allowComments*/
90557
90615
  false,
90558
90616
  /*allowSourceMaps*/
90559
90617
  true
90560
- ) : factory2.getLocalName(
90618
+ ) : factory2.getDeclarationName(
90561
90619
  node,
90562
90620
  /*allowComments*/
90563
90621
  false,
@@ -91046,7 +91104,15 @@ function transformESDecorators(context) {
91046
91104
  function transformClassLike(node, className) {
91047
91105
  var _a;
91048
91106
  startLexicalEnvironment();
91049
- const classReference = node.name ?? factory2.getGeneratedNameForNode(node);
91107
+ const classReference = factory2.getLocalName(
91108
+ node,
91109
+ /*allowComments*/
91110
+ false,
91111
+ /*allowSourceMaps*/
91112
+ false,
91113
+ /*ignoreAssignedName*/
91114
+ true
91115
+ );
91050
91116
  const classInfo2 = createClassInfo(node);
91051
91117
  const classDefinitionStatements = [];
91052
91118
  let leadingBlockStatements;
@@ -91362,6 +91428,7 @@ function transformESDecorators(context) {
91362
91428
  void 0,
91363
91429
  iife
91364
91430
  );
91431
+ setOriginalNode(varDecl, node);
91365
91432
  const varDecls = factory2.createVariableDeclarationList([varDecl], 1 /* Let */);
91366
91433
  const statement = factory2.createVariableStatement(modifiers, varDecls);
91367
91434
  setOriginalNode(statement, node);
@@ -96054,11 +96121,6 @@ function transformES2015(context) {
96054
96121
  setOriginalNode(exportStatement, statement);
96055
96122
  statements.push(exportStatement);
96056
96123
  }
96057
- const emitFlags = getEmitFlags(node);
96058
- if ((emitFlags & 8388608 /* HasEndOfDeclarationMarker */) === 0) {
96059
- statements.push(factory2.createEndOfDeclarationMarker(node));
96060
- setEmitFlags(statement, emitFlags | 8388608 /* HasEndOfDeclarationMarker */);
96061
- }
96062
96124
  return singleOrMany(statements);
96063
96125
  }
96064
96126
  function visitClassExpression(node) {
@@ -98021,7 +98083,7 @@ function transformES2015(context) {
98021
98083
  );
98022
98084
  const callResult = containsYield ? factory2.createYieldExpression(
98023
98085
  factory2.createToken(42 /* AsteriskToken */),
98024
- setEmitFlags(call, 16777216 /* Iterator */)
98086
+ setEmitFlags(call, 8388608 /* Iterator */)
98025
98087
  ) : call;
98026
98088
  return factory2.createExpressionStatement(callResult);
98027
98089
  }
@@ -98036,7 +98098,7 @@ function transformES2015(context) {
98036
98098
  );
98037
98099
  const callResult = containsYield ? factory2.createYieldExpression(
98038
98100
  factory2.createToken(42 /* AsteriskToken */),
98039
- setEmitFlags(call, 16777216 /* Iterator */)
98101
+ setEmitFlags(call, 8388608 /* Iterator */)
98040
98102
  ) : call;
98041
98103
  if (isSimpleLoop) {
98042
98104
  statements.push(factory2.createExpressionStatement(callResult));
@@ -99360,7 +99422,7 @@ function transformGenerators(context) {
99360
99422
  const resumeLabel = defineLabel();
99361
99423
  const expression = visitNode(node.expression, visitor, isExpression);
99362
99424
  if (node.asteriskToken) {
99363
- const iterator = (getEmitFlags(node.expression) & 16777216 /* Iterator */) === 0 ? setTextRange(emitHelpers().createValuesHelper(expression), node) : expression;
99425
+ const iterator = (getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 ? setTextRange(emitHelpers().createValuesHelper(expression), node) : expression;
99364
99426
  emitYieldStar(
99365
99427
  iterator,
99366
99428
  /*location*/
@@ -100908,7 +100970,6 @@ function transformModule(context) {
100908
100970
  context.enableSubstitution(303 /* ShorthandPropertyAssignment */);
100909
100971
  context.enableEmitNotification(311 /* SourceFile */);
100910
100972
  const moduleInfoMap = [];
100911
- const deferredExports = [];
100912
100973
  let currentSourceFile;
100913
100974
  let currentModuleInfo;
100914
100975
  const noSubstitution = [];
@@ -101333,10 +101394,6 @@ function transformModule(context) {
101333
101394
  return visitFunctionDeclaration(node);
101334
101395
  case 262 /* ClassDeclaration */:
101335
101396
  return visitClassDeclaration(node);
101336
- case 361 /* MergeDeclarationMarker */:
101337
- return visitMergeDeclarationMarker(node);
101338
- case 362 /* EndOfDeclarationMarker */:
101339
- return visitEndOfDeclarationMarker(node);
101340
101397
  default:
101341
101398
  return visitor(node);
101342
101399
  }
@@ -101813,12 +101870,7 @@ function transformModule(context) {
101813
101870
  )
101814
101871
  );
101815
101872
  }
101816
- if (hasAssociatedEndOfDeclarationMarker(node)) {
101817
- const id = getOriginalNodeId(node);
101818
- deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
101819
- } else {
101820
- statements = appendExportsOfImportDeclaration(statements, node);
101821
- }
101873
+ statements = appendExportsOfImportDeclaration(statements, node);
101822
101874
  return singleOrMany(statements);
101823
101875
  }
101824
101876
  function createRequireCall(importNode) {
@@ -101899,12 +101951,7 @@ function transformModule(context) {
101899
101951
  );
101900
101952
  }
101901
101953
  }
101902
- if (hasAssociatedEndOfDeclarationMarker(node)) {
101903
- const id = getOriginalNodeId(node);
101904
- deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
101905
- } else {
101906
- statements = appendExportsOfImportEqualsDeclaration(statements, node);
101907
- }
101954
+ statements = appendExportsOfImportEqualsDeclaration(statements, node);
101908
101955
  return singleOrMany(statements);
101909
101956
  }
101910
101957
  function visitExportDeclaration(node) {
@@ -102013,31 +102060,14 @@ function transformModule(context) {
102013
102060
  if (node.isExportEquals) {
102014
102061
  return void 0;
102015
102062
  }
102016
- let statements;
102017
- const original = node.original;
102018
- if (original && hasAssociatedEndOfDeclarationMarker(original)) {
102019
- const id = getOriginalNodeId(node);
102020
- deferredExports[id] = appendExportStatement(
102021
- deferredExports[id],
102022
- factory2.createIdentifier("default"),
102023
- visitNode(node.expression, visitor, isExpression),
102024
- /*location*/
102025
- node,
102026
- /*allowComments*/
102027
- true
102028
- );
102029
- } else {
102030
- statements = appendExportStatement(
102031
- statements,
102032
- factory2.createIdentifier("default"),
102033
- visitNode(node.expression, visitor, isExpression),
102034
- /*location*/
102035
- node,
102036
- /*allowComments*/
102037
- true
102038
- );
102039
- }
102040
- return singleOrMany(statements);
102063
+ return createExportStatement(
102064
+ factory2.createIdentifier("default"),
102065
+ visitNode(node.expression, visitor, isExpression),
102066
+ /*location*/
102067
+ node,
102068
+ /*allowComments*/
102069
+ true
102070
+ );
102041
102071
  }
102042
102072
  function visitFunctionDeclaration(node) {
102043
102073
  let statements;
@@ -102073,12 +102103,7 @@ function transformModule(context) {
102073
102103
  } else {
102074
102104
  statements = append(statements, visitEachChild(node, visitor, context));
102075
102105
  }
102076
- if (hasAssociatedEndOfDeclarationMarker(node)) {
102077
- const id = getOriginalNodeId(node);
102078
- deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
102079
- } else {
102080
- statements = appendExportsOfHoistedDeclaration(statements, node);
102081
- }
102106
+ statements = appendExportsOfHoistedDeclaration(statements, node);
102082
102107
  return singleOrMany(statements);
102083
102108
  }
102084
102109
  function visitClassDeclaration(node) {
@@ -102110,12 +102135,7 @@ function transformModule(context) {
102110
102135
  } else {
102111
102136
  statements = append(statements, visitEachChild(node, visitor, context));
102112
102137
  }
102113
- if (hasAssociatedEndOfDeclarationMarker(node)) {
102114
- const id = getOriginalNodeId(node);
102115
- deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
102116
- } else {
102117
- statements = appendExportsOfHoistedDeclaration(statements, node);
102118
- }
102138
+ statements = appendExportsOfHoistedDeclaration(statements, node);
102119
102139
  return singleOrMany(statements);
102120
102140
  }
102121
102141
  function visitVariableStatement(node) {
@@ -102187,12 +102207,7 @@ function transformModule(context) {
102187
102207
  } else {
102188
102208
  statements = append(statements, visitEachChild(node, visitor, context));
102189
102209
  }
102190
- if (hasAssociatedEndOfDeclarationMarker(node)) {
102191
- const id = getOriginalNodeId(node);
102192
- deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
102193
- } else {
102194
- statements = appendExportsOfVariableStatement(statements, node);
102195
- }
102210
+ statements = appendExportsOfVariableStatement(statements, node);
102196
102211
  return singleOrMany(statements);
102197
102212
  }
102198
102213
  function createAllExportExpressions(name, value, location) {
@@ -102237,25 +102252,6 @@ function transformModule(context) {
102237
102252
  );
102238
102253
  }
102239
102254
  }
102240
- function visitMergeDeclarationMarker(node) {
102241
- if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 242 /* VariableStatement */) {
102242
- const id = getOriginalNodeId(node);
102243
- deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
102244
- }
102245
- return node;
102246
- }
102247
- function hasAssociatedEndOfDeclarationMarker(node) {
102248
- return (getEmitFlags(node) & 8388608 /* HasEndOfDeclarationMarker */) !== 0;
102249
- }
102250
- function visitEndOfDeclarationMarker(node) {
102251
- const id = getOriginalNodeId(node);
102252
- const statements = deferredExports[id];
102253
- if (statements) {
102254
- delete deferredExports[id];
102255
- return append(statements, node);
102256
- }
102257
- return node;
102258
- }
102259
102255
  function appendExportsOfImportDeclaration(statements, decl) {
102260
102256
  if (currentModuleInfo.exportEquals) {
102261
102257
  return statements;
@@ -102312,7 +102308,7 @@ function transformModule(context) {
102312
102308
  statements = appendExportsOfBindingElement(statements, element);
102313
102309
  }
102314
102310
  }
102315
- } else if (!isGeneratedIdentifier(decl.name)) {
102311
+ } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer)) {
102316
102312
  statements = appendExportsOfDeclaration(statements, decl);
102317
102313
  }
102318
102314
  return statements;
@@ -102583,7 +102579,7 @@ function transformModule(context) {
102583
102579
  return node;
102584
102580
  }
102585
102581
  function substituteBinaryExpression(node) {
102586
- if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) && !isGeneratedIdentifier(node.left) && !isLocalName(node.left) && !isDeclarationNameOfEnumOrNamespace(node.left)) {
102582
+ if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) && !isGeneratedIdentifier(node.left) && !isLocalName(node.left)) {
102587
102583
  const exportedNames = getExports(node.left);
102588
102584
  if (exportedNames) {
102589
102585
  let expression = node;
@@ -102603,9 +102599,24 @@ function transformModule(context) {
102603
102599
  }
102604
102600
  function getExports(name) {
102605
102601
  if (!isGeneratedIdentifier(name)) {
102606
- const valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
102607
- if (valueDeclaration) {
102608
- return currentModuleInfo && currentModuleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)];
102602
+ const importDeclaration = resolver.getReferencedImportDeclaration(name);
102603
+ if (importDeclaration) {
102604
+ return currentModuleInfo == null ? void 0 : currentModuleInfo.exportedBindings[getOriginalNodeId(importDeclaration)];
102605
+ }
102606
+ const bindingsSet = /* @__PURE__ */ new Set();
102607
+ const declarations = resolver.getReferencedValueDeclarations(name);
102608
+ if (declarations) {
102609
+ for (const declaration of declarations) {
102610
+ const bindings = currentModuleInfo == null ? void 0 : currentModuleInfo.exportedBindings[getOriginalNodeId(declaration)];
102611
+ if (bindings) {
102612
+ for (const binding of bindings) {
102613
+ bindingsSet.add(binding);
102614
+ }
102615
+ }
102616
+ }
102617
+ if (bindingsSet.size) {
102618
+ return arrayFrom(bindingsSet);
102619
+ }
102609
102620
  }
102610
102621
  }
102611
102622
  }
@@ -102638,7 +102649,6 @@ function transformSystemModule(context) {
102638
102649
  context.enableSubstitution(235 /* MetaProperty */);
102639
102650
  context.enableEmitNotification(311 /* SourceFile */);
102640
102651
  const moduleInfoMap = [];
102641
- const deferredExports = [];
102642
102652
  const exportFunctionsMap = [];
102643
102653
  const noSubstitutionMap = [];
102644
102654
  const contextObjectMap = [];
@@ -103111,13 +103121,7 @@ function transformSystemModule(context) {
103111
103121
  if (node.importClause) {
103112
103122
  hoistVariableDeclaration(getLocalNameForExternalImport(factory2, node, currentSourceFile));
103113
103123
  }
103114
- if (hasAssociatedEndOfDeclarationMarker(node)) {
103115
- const id = getOriginalNodeId(node);
103116
- deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
103117
- } else {
103118
- statements = appendExportsOfImportDeclaration(statements, node);
103119
- }
103120
- return singleOrMany(statements);
103124
+ return singleOrMany(appendExportsOfImportDeclaration(statements, node));
103121
103125
  }
103122
103126
  function visitExportDeclaration(node) {
103123
103127
  Debug.assertIsDefined(node);
@@ -103127,37 +103131,19 @@ function transformSystemModule(context) {
103127
103131
  Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
103128
103132
  let statements;
103129
103133
  hoistVariableDeclaration(getLocalNameForExternalImport(factory2, node, currentSourceFile));
103130
- if (hasAssociatedEndOfDeclarationMarker(node)) {
103131
- const id = getOriginalNodeId(node);
103132
- deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
103133
- } else {
103134
- statements = appendExportsOfImportEqualsDeclaration(statements, node);
103135
- }
103136
- return singleOrMany(statements);
103134
+ return singleOrMany(appendExportsOfImportEqualsDeclaration(statements, node));
103137
103135
  }
103138
103136
  function visitExportAssignment(node) {
103139
103137
  if (node.isExportEquals) {
103140
103138
  return void 0;
103141
103139
  }
103142
103140
  const expression = visitNode(node.expression, visitor, isExpression);
103143
- const original = node.original;
103144
- if (original && hasAssociatedEndOfDeclarationMarker(original)) {
103145
- const id = getOriginalNodeId(node);
103146
- deferredExports[id] = appendExportStatement(
103147
- deferredExports[id],
103148
- factory2.createIdentifier("default"),
103149
- expression,
103150
- /*allowComments*/
103151
- true
103152
- );
103153
- } else {
103154
- return createExportStatement(
103155
- factory2.createIdentifier("default"),
103156
- expression,
103157
- /*allowComments*/
103158
- true
103159
- );
103160
- }
103141
+ return createExportStatement(
103142
+ factory2.createIdentifier("default"),
103143
+ expression,
103144
+ /*allowComments*/
103145
+ true
103146
+ );
103161
103147
  }
103162
103148
  function visitFunctionDeclaration(node) {
103163
103149
  if (hasSyntacticModifier(node, 1 /* Export */)) {
@@ -103185,12 +103171,7 @@ function transformSystemModule(context) {
103185
103171
  } else {
103186
103172
  hoistedStatements = append(hoistedStatements, visitEachChild(node, visitor, context));
103187
103173
  }
103188
- if (hasAssociatedEndOfDeclarationMarker(node)) {
103189
- const id = getOriginalNodeId(node);
103190
- deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
103191
- } else {
103192
- hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
103193
- }
103174
+ hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
103194
103175
  return void 0;
103195
103176
  }
103196
103177
  function visitClassDeclaration(node) {
@@ -103219,12 +103200,7 @@ function transformSystemModule(context) {
103219
103200
  node
103220
103201
  )
103221
103202
  );
103222
- if (hasAssociatedEndOfDeclarationMarker(node)) {
103223
- const id = getOriginalNodeId(node);
103224
- deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
103225
- } else {
103226
- statements = appendExportsOfHoistedDeclaration(statements, node);
103227
- }
103203
+ statements = appendExportsOfHoistedDeclaration(statements, node);
103228
103204
  return singleOrMany(statements);
103229
103205
  }
103230
103206
  function visitVariableStatement(node) {
@@ -103233,10 +103209,9 @@ function transformSystemModule(context) {
103233
103209
  }
103234
103210
  let expressions;
103235
103211
  const isExportedDeclaration = hasSyntacticModifier(node, 1 /* Export */);
103236
- const isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
103237
103212
  for (const variable of node.declarationList.declarations) {
103238
103213
  if (variable.initializer) {
103239
- expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
103214
+ expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration));
103240
103215
  } else {
103241
103216
  hoistBindingElement(variable);
103242
103217
  }
@@ -103245,17 +103220,12 @@ function transformSystemModule(context) {
103245
103220
  if (expressions) {
103246
103221
  statements = append(statements, setTextRange(factory2.createExpressionStatement(factory2.inlineExpressions(expressions)), node));
103247
103222
  }
103248
- if (isMarkedDeclaration) {
103249
- const id = getOriginalNodeId(node);
103250
- deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
103251
- } else {
103252
- statements = appendExportsOfVariableStatement(
103253
- statements,
103254
- node,
103255
- /*exportSelf*/
103256
- false
103257
- );
103258
- }
103223
+ statements = appendExportsOfVariableStatement(
103224
+ statements,
103225
+ node,
103226
+ /*exportSelf*/
103227
+ false
103228
+ );
103259
103229
  return singleOrMany(statements);
103260
103230
  }
103261
103231
  function hoistBindingElement(node) {
@@ -103306,31 +103276,6 @@ function transformSystemModule(context) {
103306
103276
  hoistVariableDeclaration(factory2.cloneNode(name));
103307
103277
  return isExportedDeclaration ? createExportExpression(name, preventSubstitution(setTextRange(factory2.createAssignment(name, value), location))) : preventSubstitution(setTextRange(factory2.createAssignment(name, value), location));
103308
103278
  }
103309
- function visitMergeDeclarationMarker(node) {
103310
- if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 242 /* VariableStatement */) {
103311
- const id = getOriginalNodeId(node);
103312
- const isExportedDeclaration = hasSyntacticModifier(node.original, 1 /* Export */);
103313
- deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
103314
- }
103315
- return node;
103316
- }
103317
- function hasAssociatedEndOfDeclarationMarker(node) {
103318
- return (getEmitFlags(node) & 8388608 /* HasEndOfDeclarationMarker */) !== 0;
103319
- }
103320
- function visitEndOfDeclarationMarker(node) {
103321
- const id = getOriginalNodeId(node);
103322
- const statements = deferredExports[id];
103323
- if (statements) {
103324
- delete deferredExports[id];
103325
- return append(statements, node);
103326
- } else {
103327
- const original = getOriginalNode(node);
103328
- if (isModuleOrEnumDeclaration(original)) {
103329
- return append(appendExportsOfDeclaration(statements, original), node);
103330
- }
103331
- }
103332
- return node;
103333
- }
103334
103279
  function appendExportsOfImportDeclaration(statements, decl) {
103335
103280
  if (moduleInfo.exportEquals) {
103336
103281
  return statements;
@@ -103486,10 +103431,6 @@ function transformSystemModule(context) {
103486
103431
  return visitCatchClause(node);
103487
103432
  case 240 /* Block */:
103488
103433
  return visitBlock(node);
103489
- case 361 /* MergeDeclarationMarker */:
103490
- return visitMergeDeclarationMarker(node);
103491
- case 362 /* EndOfDeclarationMarker */:
103492
- return visitEndOfDeclarationMarker(node);
103493
103434
  default:
103494
103435
  return visitor(node);
103495
103436
  }
@@ -103895,7 +103836,7 @@ function transformSystemModule(context) {
103895
103836
  return node;
103896
103837
  }
103897
103838
  function substituteBinaryExpression(node) {
103898
- if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) && !isGeneratedIdentifier(node.left) && !isLocalName(node.left) && !isDeclarationNameOfEnumOrNamespace(node.left)) {
103839
+ if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) && !isGeneratedIdentifier(node.left) && !isLocalName(node.left)) {
103899
103840
  const exportedNames = getExports(node.left);
103900
103841
  if (exportedNames) {
103901
103842
  let expression = node;
@@ -103915,21 +103856,37 @@ function transformSystemModule(context) {
103915
103856
  }
103916
103857
  function getExports(name) {
103917
103858
  let exportedNames;
103859
+ const valueDeclaration = getReferencedDeclaration(name);
103860
+ if (valueDeclaration) {
103861
+ const exportContainer = resolver.getReferencedExportContainer(
103862
+ name,
103863
+ /*prefixLocals*/
103864
+ false
103865
+ );
103866
+ if (exportContainer && exportContainer.kind === 311 /* SourceFile */) {
103867
+ exportedNames = append(exportedNames, factory2.getDeclarationName(valueDeclaration));
103868
+ }
103869
+ exportedNames = addRange(exportedNames, moduleInfo == null ? void 0 : moduleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]);
103870
+ }
103871
+ return exportedNames;
103872
+ }
103873
+ function getReferencedDeclaration(name) {
103918
103874
  if (!isGeneratedIdentifier(name)) {
103919
- const valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
103920
- if (valueDeclaration) {
103921
- const exportContainer = resolver.getReferencedExportContainer(
103922
- name,
103923
- /*prefixLocals*/
103924
- false
103925
- );
103926
- if (exportContainer && exportContainer.kind === 311 /* SourceFile */) {
103927
- exportedNames = append(exportedNames, factory2.getDeclarationName(valueDeclaration));
103875
+ const importDeclaration = resolver.getReferencedImportDeclaration(name);
103876
+ if (importDeclaration)
103877
+ return importDeclaration;
103878
+ const valueDeclaration = resolver.getReferencedValueDeclaration(name);
103879
+ if (valueDeclaration && (moduleInfo == null ? void 0 : moduleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]))
103880
+ return valueDeclaration;
103881
+ const declarations = resolver.getReferencedValueDeclarations(name);
103882
+ if (declarations) {
103883
+ for (const declaration of declarations) {
103884
+ if (declaration !== valueDeclaration && (moduleInfo == null ? void 0 : moduleInfo.exportedBindings[getOriginalNodeId(declaration)]))
103885
+ return declaration;
103928
103886
  }
103929
- exportedNames = addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]);
103930
103887
  }
103888
+ return valueDeclaration;
103931
103889
  }
103932
- return exportedNames;
103933
103890
  }
103934
103891
  function preventSubstitution(node) {
103935
103892
  if (noSubstitution === void 0)
@@ -106343,7 +106300,7 @@ function noEmitNotification(hint, node, callback) {
106343
106300
  }
106344
106301
  function transformNodes(resolver, host, factory2, options, nodes, transformers, allowDtsFiles) {
106345
106302
  var _a, _b;
106346
- const enabledSyntaxKindFeatures = new Array(364 /* Count */);
106303
+ const enabledSyntaxKindFeatures = new Array(362 /* Count */);
106347
106304
  let lexicalEnvironmentVariableDeclarations;
106348
106305
  let lexicalEnvironmentFunctionDeclarations;
106349
106306
  let lexicalEnvironmentStatements;
@@ -107276,6 +107233,7 @@ var notImplementedResolver = {
107276
107233
  // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
107277
107234
  getConstantValue: notImplemented,
107278
107235
  getReferencedValueDeclaration: notImplemented,
107236
+ getReferencedValueDeclarations: notImplemented,
107279
107237
  getTypeReferenceSerializationKind: notImplemented,
107280
107238
  isOptionalParameter: notImplemented,
107281
107239
  moduleExportsSomeValue: notImplemented,
@@ -108229,8 +108187,6 @@ function createPrinter(printerOptions = {}, handlers = {}) {
108229
108187
  case 353 /* JSDocSeeTag */:
108230
108188
  return emitJSDocSeeTag(node);
108231
108189
  case 358 /* NotEmittedStatement */:
108232
- case 362 /* EndOfDeclarationMarker */:
108233
- case 361 /* MergeDeclarationMarker */:
108234
108190
  return;
108235
108191
  }
108236
108192
  if (isExpression(node)) {
@@ -108341,10 +108297,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
108341
108297
  return emitPartiallyEmittedExpression(node);
108342
108298
  case 360 /* CommaListExpression */:
108343
108299
  return emitCommaList(node);
108344
- case 361 /* MergeDeclarationMarker */:
108345
- case 362 /* EndOfDeclarationMarker */:
108346
- return;
108347
- case 363 /* SyntheticReferenceExpression */:
108300
+ case 361 /* SyntheticReferenceExpression */:
108348
108301
  return Debug.fail("SyntheticReferenceExpression should not be printed");
108349
108302
  }
108350
108303
  }
@@ -111180,7 +111133,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
111180
111133
  const textSourceNode = node.textSourceNode;
111181
111134
  if (isIdentifier(textSourceNode) || isPrivateIdentifier(textSourceNode) || isNumericLiteral(textSourceNode)) {
111182
111135
  const text = isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode2(textSourceNode);
111183
- return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` : neverAsciiEscape || getEmitFlags(node) & 33554432 /* NoAsciiEscaping */ ? `"${escapeString(text)}"` : `"${escapeNonAsciiString(text)}"`;
111136
+ return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` : neverAsciiEscape || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? `"${escapeString(text)}"` : `"${escapeNonAsciiString(text)}"`;
111184
111137
  } else {
111185
111138
  return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
111186
111139
  }
@@ -113127,6 +113080,25 @@ function forEachProjectReference(projectReferences, resolvedProjectReferences, c
113127
113080
  }
113128
113081
  }
113129
113082
  var inferredTypesContainingFile = "__inferred type names__.ts";
113083
+ function getInferredLibraryNameResolveFrom(options, currentDirectory, libFileName) {
113084
+ const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
113085
+ return combinePaths(containingDirectory, `__lib_node_modules_lookup_${libFileName}__.ts`);
113086
+ }
113087
+ function getLibraryNameFromLibFileName(libFileName) {
113088
+ const components = libFileName.split(".");
113089
+ let path = components[1];
113090
+ let i = 2;
113091
+ while (components[i] && components[i] !== "d") {
113092
+ path += (i === 2 ? "/" : "-") + components[i];
113093
+ i++;
113094
+ }
113095
+ return "@typescript/lib-" + path;
113096
+ }
113097
+ function getLibFileNameFromLibReference(libReference) {
113098
+ const libName = toFileNameLowerCase(libReference.fileName);
113099
+ const libFileName = libMap.get(libName);
113100
+ return { libName, libFileName };
113101
+ }
113130
113102
  function isReferencedFile(reason) {
113131
113103
  switch (reason == null ? void 0 : reason.kind) {
113132
113104
  case 3 /* Import */:
@@ -113170,7 +113142,7 @@ function getReferencedFileLocation(getSourceFileByPath, ref) {
113170
113142
  }
113171
113143
  return { file, pos, end, packageId };
113172
113144
  }
113173
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
113145
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
113174
113146
  if (!program || (hasChangedAutomaticTypeDirectiveNames == null ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
113175
113147
  return false;
113176
113148
  if (!arrayIsEqualTo(program.getRootFileNames(), rootFileNames))
@@ -113185,6 +113157,8 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
113185
113157
  const currentOptions = program.getCompilerOptions();
113186
113158
  if (!compareDataObjects(currentOptions, newOptions))
113187
113159
  return false;
113160
+ if (program.resolvedLibReferences && forEachEntry(program.resolvedLibReferences, (_value, libFileName) => hasInvalidatedLibResolutions(libFileName)))
113161
+ return false;
113188
113162
  if (currentOptions.configFile && newOptions.configFile)
113189
113163
  return currentOptions.configFile.text === newOptions.configFile.text;
113190
113164
  return true;
@@ -113367,6 +113341,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113367
113341
  let fileProcessingDiagnostics;
113368
113342
  let automaticTypeDirectiveNames;
113369
113343
  let automaticTypeDirectiveResolutions;
113344
+ let resolvedLibReferences;
113345
+ let resolvedLibProcessing;
113370
113346
  const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
113371
113347
  let currentNodeModulesDepth = 0;
113372
113348
  const modulesWithElidedImports = /* @__PURE__ */ new Map();
@@ -113454,6 +113430,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113454
113430
  createTypeReferenceResolutionLoader
113455
113431
  );
113456
113432
  }
113433
+ const hasInvalidatedLibResolutions = host.hasInvalidatedLibResolutions || returnFalse;
113434
+ let actualResolveLibrary;
113435
+ if (host.resolveLibrary) {
113436
+ actualResolveLibrary = host.resolveLibrary.bind(host);
113437
+ } else {
113438
+ const libraryResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
113439
+ actualResolveLibrary = (libraryName, resolveFrom, options2) => resolveLibrary(libraryName, resolveFrom, options2, host, libraryResolutionCache);
113440
+ }
113457
113441
  const packageIdToSourceFile = /* @__PURE__ */ new Map();
113458
113442
  let sourceFileToPackageName = /* @__PURE__ */ new Map();
113459
113443
  let redirectTargetsMap = createMultiMap();
@@ -113620,6 +113604,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113620
113604
  );
113621
113605
  }
113622
113606
  oldProgram = void 0;
113607
+ resolvedLibProcessing = void 0;
113623
113608
  const program = {
113624
113609
  getRootFileNames: () => rootNames,
113625
113610
  getSourceFile,
@@ -113661,6 +113646,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113661
113646
  sourceFileToPackageName,
113662
113647
  redirectTargetsMap,
113663
113648
  usesUriStyleNodeCoreModules,
113649
+ resolvedLibReferences,
113664
113650
  isEmittedFile,
113665
113651
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
113666
113652
  getProjectReferences,
@@ -114149,6 +114135,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114149
114135
  if (changesAffectingProgramStructure(oldOptions, options)) {
114150
114136
  return 1 /* SafeModules */;
114151
114137
  }
114138
+ if (oldProgram.resolvedLibReferences && forEachEntry(oldProgram.resolvedLibReferences, (resolution, libFileName) => pathForLibFileWorker(libFileName).actual !== resolution.actual)) {
114139
+ return 1 /* SafeModules */;
114140
+ }
114152
114141
  if (host.hasChangedAutomaticTypeDirectiveNames) {
114153
114142
  if (host.hasChangedAutomaticTypeDirectiveNames())
114154
114143
  return 1 /* SafeModules */;
@@ -114185,6 +114174,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114185
114174
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
114186
114175
  redirectTargetsMap = oldProgram.redirectTargetsMap;
114187
114176
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
114177
+ resolvedLibReferences = oldProgram.resolvedLibReferences;
114188
114178
  return 2 /* Completely */;
114189
114179
  }
114190
114180
  function getEmitHost(writeFileCallback) {
@@ -114294,7 +114284,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114294
114284
  if (!options.lib) {
114295
114285
  return equalityComparer(file.fileName, getDefaultLibraryFileName());
114296
114286
  } else {
114297
- return some(options.lib, (libFileName) => equalityComparer(file.fileName, pathForLibFile(libFileName)));
114287
+ return some(options.lib, (libFileName) => equalityComparer(file.fileName, resolvedLibReferences.get(libFileName).actual));
114298
114288
  }
114299
114289
  }
114300
114290
  function getTypeChecker() {
@@ -114885,11 +114875,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114885
114875
  }
114886
114876
  }
114887
114877
  function getLibFileFromReference(ref) {
114888
- const libName = toFileNameLowerCase(ref.fileName);
114889
- const libFileName = libMap.get(libName);
114890
- if (libFileName) {
114891
- return getSourceFile(pathForLibFile(libFileName));
114892
- }
114878
+ var _a2;
114879
+ const { libFileName } = getLibFileNameFromLibReference(ref);
114880
+ const actualFileName = libFileName && ((_a2 = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName)) == null ? void 0 : _a2.actual);
114881
+ return actualFileName !== void 0 ? getSourceFile(actualFileName) : void 0;
114893
114882
  }
114894
114883
  function getSourceFileFromReference(referencingFile, ref) {
114895
114884
  return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), getSourceFile);
@@ -115314,25 +115303,55 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115314
115303
  }
115315
115304
  }
115316
115305
  function pathForLibFile(libFileName) {
115317
- const components = libFileName.split(".");
115318
- let path = components[1];
115319
- let i = 2;
115320
- while (components[i] && components[i] !== "d") {
115321
- path += (i === 2 ? "/" : "-") + components[i];
115322
- i++;
115323
- }
115324
- const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
115325
- const resolveFrom = combinePaths(containingDirectory, `__lib_node_modules_lookup_${libFileName}__.ts`);
115326
- const localOverrideModuleResult = resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: 2 /* Node10 */, traceResolution: options.traceResolution }, host, moduleResolutionCache);
115327
- if (localOverrideModuleResult == null ? void 0 : localOverrideModuleResult.resolvedModule) {
115328
- return localOverrideModuleResult.resolvedModule.resolvedFileName;
115329
- }
115330
- return combinePaths(defaultLibraryPath, libFileName);
115306
+ const existing = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName);
115307
+ if (existing)
115308
+ return existing.actual;
115309
+ const result = pathForLibFileWorker(libFileName);
115310
+ (resolvedLibReferences ?? (resolvedLibReferences = /* @__PURE__ */ new Map())).set(libFileName, result);
115311
+ return result.actual;
115312
+ }
115313
+ function pathForLibFileWorker(libFileName) {
115314
+ var _a2, _b2, _c2, _d2, _e2;
115315
+ const existing = resolvedLibProcessing == null ? void 0 : resolvedLibProcessing.get(libFileName);
115316
+ if (existing)
115317
+ return existing;
115318
+ if (structureIsReused !== 0 /* Not */ && oldProgram && !hasInvalidatedLibResolutions(libFileName)) {
115319
+ const oldResolution = (_a2 = oldProgram.resolvedLibReferences) == null ? void 0 : _a2.get(libFileName);
115320
+ if (oldResolution) {
115321
+ if (oldResolution.resolution && isTraceEnabled(options, host)) {
115322
+ const libraryName2 = getLibraryNameFromLibFileName(libFileName);
115323
+ const resolveFrom2 = getInferredLibraryNameResolveFrom(options, currentDirectory, libFileName);
115324
+ trace(
115325
+ host,
115326
+ oldResolution.resolution.resolvedModule ? oldResolution.resolution.resolvedModule.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved,
115327
+ libraryName2,
115328
+ getNormalizedAbsolutePath(resolveFrom2, currentDirectory),
115329
+ (_b2 = oldResolution.resolution.resolvedModule) == null ? void 0 : _b2.resolvedFileName,
115330
+ ((_c2 = oldResolution.resolution.resolvedModule) == null ? void 0 : _c2.packageId) && packageIdToString(oldResolution.resolution.resolvedModule.packageId)
115331
+ );
115332
+ }
115333
+ (resolvedLibProcessing ?? (resolvedLibProcessing = /* @__PURE__ */ new Map())).set(libFileName, oldResolution);
115334
+ return oldResolution;
115335
+ }
115336
+ }
115337
+ const libraryName = getLibraryNameFromLibFileName(libFileName);
115338
+ const resolveFrom = getInferredLibraryNameResolveFrom(options, currentDirectory, libFileName);
115339
+ (_d2 = tracing) == null ? void 0 : _d2.push(tracing.Phase.Program, "resolveLibrary", { resolveFrom });
115340
+ mark("beforeResolveLibrary");
115341
+ const resolution = actualResolveLibrary(libraryName, resolveFrom, options, libFileName);
115342
+ mark("afterResolveLibrary");
115343
+ measure("ResolveLibrary", "beforeResolveLibrary", "afterResolveLibrary");
115344
+ (_e2 = tracing) == null ? void 0 : _e2.pop();
115345
+ const result = {
115346
+ resolution,
115347
+ actual: resolution.resolvedModule ? resolution.resolvedModule.resolvedFileName : combinePaths(defaultLibraryPath, libFileName)
115348
+ };
115349
+ (resolvedLibProcessing ?? (resolvedLibProcessing = /* @__PURE__ */ new Map())).set(libFileName, result);
115350
+ return result;
115331
115351
  }
115332
115352
  function processLibReferenceDirectives(file) {
115333
115353
  forEach(file.libReferenceDirectives, (libReference, index) => {
115334
- const libName = toFileNameLowerCase(libReference.fileName);
115335
- const libFileName = libMap.get(libName);
115354
+ const { libName, libFileName } = getLibFileNameFromLibReference(libReference);
115336
115355
  if (libFileName) {
115337
115356
  processRootFile(
115338
115357
  pathForLibFile(libFileName),
@@ -118299,7 +118318,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118299
118318
  let failedLookupChecks;
118300
118319
  let startsWithPathChecks;
118301
118320
  let isInDirectoryChecks;
118302
- let allResolutionsAreInvalidated = false;
118321
+ let allModuleAndTypeResolutionsAreInvalidated = false;
118303
118322
  const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
118304
118323
  const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
118305
118324
  const resolvedModuleNames = /* @__PURE__ */ new Map();
@@ -118315,6 +118334,13 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118315
118334
  resolutionHost.getCompilationSettings(),
118316
118335
  moduleResolutionCache.getPackageJsonInfoCache()
118317
118336
  );
118337
+ const resolvedLibraries = /* @__PURE__ */ new Map();
118338
+ const libraryResolutionCache = createModuleResolutionCache(
118339
+ getCurrentDirectory(),
118340
+ resolutionHost.getCanonicalFileName,
118341
+ getOptionsForLibraryResolution(resolutionHost.getCompilationSettings()),
118342
+ moduleResolutionCache.getPackageJsonInfoCache()
118343
+ );
118318
118344
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
118319
118345
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
118320
118346
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
@@ -118331,6 +118357,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118331
118357
  finishCachingPerDirectoryResolution,
118332
118358
  resolveModuleNameLiterals,
118333
118359
  resolveTypeReferenceDirectiveReferences,
118360
+ resolveLibrary: resolveLibrary2,
118334
118361
  resolveSingleModuleNameWithoutWatching,
118335
118362
  removeResolutionsFromProjectReferenceRedirects,
118336
118363
  removeResolutionsOfFile,
@@ -118366,16 +118393,18 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118366
118393
  isInDirectoryChecks = void 0;
118367
118394
  affectingPathChecks = void 0;
118368
118395
  affectingPathChecksForFile = void 0;
118369
- allResolutionsAreInvalidated = false;
118396
+ allModuleAndTypeResolutionsAreInvalidated = false;
118370
118397
  moduleResolutionCache.clear();
118371
118398
  typeReferenceDirectiveResolutionCache.clear();
118372
118399
  moduleResolutionCache.update(resolutionHost.getCompilationSettings());
118373
118400
  typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
118401
+ libraryResolutionCache.clear();
118374
118402
  impliedFormatPackageJsons.clear();
118403
+ resolvedLibraries.clear();
118375
118404
  hasChangedAutomaticTypeDirectiveNames = false;
118376
118405
  }
118377
118406
  function onChangesAffectModuleResolution() {
118378
- allResolutionsAreInvalidated = true;
118407
+ allModuleAndTypeResolutionsAreInvalidated = true;
118379
118408
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
118380
118409
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
118381
118410
  moduleResolutionCache.update(resolutionHost.getCompilationSettings());
@@ -118396,24 +118425,45 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118396
118425
  const value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
118397
118426
  return !!value && !!value.length;
118398
118427
  }
118399
- function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
118428
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions, customHasInvalidatedLibResolutions) {
118400
118429
  invalidateResolutionsOfFailedLookupLocations();
118401
118430
  const collected = filesWithInvalidatedResolutions;
118402
118431
  filesWithInvalidatedResolutions = void 0;
118403
- return (path) => customHasInvalidatedResolutions(path) || allResolutionsAreInvalidated || !!(collected == null ? void 0 : collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path);
118432
+ return {
118433
+ hasInvalidatedResolutions: (path) => customHasInvalidatedResolutions(path) || allModuleAndTypeResolutionsAreInvalidated || !!(collected == null ? void 0 : collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path),
118434
+ hasInvalidatedLibResolutions: (libFileName) => {
118435
+ var _a;
118436
+ return customHasInvalidatedLibResolutions(libFileName) || !!((_a = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName)) == null ? void 0 : _a.isInvalidated);
118437
+ }
118438
+ };
118404
118439
  }
118405
118440
  function startCachingPerDirectoryResolution() {
118406
118441
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
118407
118442
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
118443
+ libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
118408
118444
  nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
118409
118445
  nonRelativeExternalModuleResolutions.clear();
118410
118446
  }
118447
+ function cleanupLibResolutionWatching(newProgram) {
118448
+ resolvedLibraries.forEach((resolution, libFileName) => {
118449
+ var _a;
118450
+ if (!((_a = newProgram == null ? void 0 : newProgram.resolvedLibReferences) == null ? void 0 : _a.has(libFileName))) {
118451
+ stopWatchFailedLookupLocationOfResolution(
118452
+ resolution,
118453
+ resolutionHost.toPath(getInferredLibraryNameResolveFrom(newProgram.getCompilerOptions(), getCurrentDirectory(), libFileName)),
118454
+ getResolvedModule2
118455
+ );
118456
+ resolvedLibraries.delete(libFileName);
118457
+ }
118458
+ });
118459
+ }
118411
118460
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
118412
118461
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
118413
- allResolutionsAreInvalidated = false;
118462
+ allModuleAndTypeResolutionsAreInvalidated = false;
118414
118463
  nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
118415
118464
  nonRelativeExternalModuleResolutions.clear();
118416
118465
  if (newProgram !== oldProgram) {
118466
+ cleanupLibResolutionWatching(newProgram);
118417
118467
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
118418
118468
  var _a;
118419
118469
  const expected = isExternalOrCommonJsModule(newFile) ? ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0 : 0;
@@ -118522,7 +118572,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118522
118572
  const name = loader.nameAndMode.getName(entry);
118523
118573
  const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
118524
118574
  let resolution = resolutionsInFile.get(name, mode);
118525
- if (!seenNamesInFile.has(name, mode) && (allResolutionsAreInvalidated || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
118575
+ if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
118526
118576
  hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
118527
118577
  const existingResolution = resolution;
118528
118578
  resolution = loader.resolve(name, mode);
@@ -118631,6 +118681,41 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118631
118681
  // Defer non relative resolution watch because we could be using ambient modules
118632
118682
  });
118633
118683
  }
118684
+ function resolveLibrary2(libraryName, resolveFrom, options, libFileName) {
118685
+ var _a;
118686
+ const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost;
118687
+ let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName);
118688
+ if (!resolution || resolution.isInvalidated) {
118689
+ const existingResolution = resolution;
118690
+ resolution = resolveLibrary(libraryName, resolveFrom, options, host, libraryResolutionCache);
118691
+ const path = resolutionHost.toPath(resolveFrom);
118692
+ watchFailedLookupLocationsOfExternalModuleResolutions(
118693
+ libraryName,
118694
+ resolution,
118695
+ path,
118696
+ getResolvedModule2,
118697
+ /*deferWatchingNonRelativeResolution*/
118698
+ false
118699
+ );
118700
+ resolvedLibraries.set(libFileName, resolution);
118701
+ if (existingResolution) {
118702
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModule2);
118703
+ }
118704
+ } else {
118705
+ if (isTraceEnabled(options, host)) {
118706
+ const resolved = getResolvedModule2(resolution);
118707
+ trace(
118708
+ host,
118709
+ (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved,
118710
+ libraryName,
118711
+ resolveFrom,
118712
+ resolved == null ? void 0 : resolved.resolvedFileName,
118713
+ (resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
118714
+ );
118715
+ }
118716
+ }
118717
+ return resolution;
118718
+ }
118634
118719
  function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
118635
118720
  const path = resolutionHost.toPath(containingFile);
118636
118721
  const resolutionsInFile = resolvedModuleNames.get(path);
@@ -118953,9 +119038,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118953
119038
  }
118954
119039
  function invalidateResolutionsOfFailedLookupLocations() {
118955
119040
  var _a;
118956
- if (allResolutionsAreInvalidated) {
119041
+ if (allModuleAndTypeResolutionsAreInvalidated) {
118957
119042
  affectingPathChecksForFile = void 0;
118958
119043
  invalidatePackageJsonMap();
119044
+ if (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks || affectingPathChecks) {
119045
+ invalidateResolutions(resolvedLibraries, canInvalidateFailedLookupResolution);
119046
+ }
118959
119047
  failedLookupChecks = void 0;
118960
119048
  startsWithPathChecks = void 0;
118961
119049
  isInDirectoryChecks = void 0;
@@ -119832,9 +119920,11 @@ function createWatchProgram(host) {
119832
119920
  if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
119833
119921
  compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
119834
119922
  }
119923
+ compilerHost.resolveLibrary = !host.resolveLibrary ? resolutionCache.resolveLibrary.bind(resolutionCache) : host.resolveLibrary.bind(host);
119835
119924
  compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
119836
119925
  const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
119837
119926
  const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
119927
+ const customHasInvalidLibResolutions = host.resolveLibrary ? maybeBind(host, host.hasInvalidatedLibResolutions) || returnTrue : returnFalse;
119838
119928
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
119839
119929
  synchronizeProgram();
119840
119930
  watchConfigFileWildCardDirectories();
@@ -119899,7 +119989,7 @@ function createWatchProgram(host) {
119899
119989
  resolutionCache.onChangesAffectModuleResolution();
119900
119990
  }
119901
119991
  }
119902
- const hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
119992
+ const { hasInvalidatedResolutions, hasInvalidatedLibResolutions } = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions, customHasInvalidLibResolutions);
119903
119993
  const {
119904
119994
  originalReadFile,
119905
119995
  originalFileExists,
@@ -119908,7 +119998,7 @@ function createWatchProgram(host) {
119908
119998
  originalWriteFile,
119909
119999
  readFileWithCache
119910
120000
  } = changeCompilerHostLikeToUseCache(compilerHost, toPath3);
119911
- if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, (path) => getSourceVersion(path, readFileWithCache), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
120001
+ if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, (path) => getSourceVersion(path, readFileWithCache), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
119912
120002
  if (hasChangedConfigFileParsingErrors) {
119913
120003
  if (reportFileChangeDetectedOnCreateProgram) {
119914
120004
  reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -119929,7 +120019,7 @@ function createWatchProgram(host) {
119929
120019
  if (reportFileChangeDetectedOnCreateProgram) {
119930
120020
  reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation);
119931
120021
  }
119932
- createNewProgram(hasInvalidatedResolutions);
120022
+ createNewProgram(hasInvalidatedResolutions, hasInvalidatedLibResolutions);
119933
120023
  }
119934
120024
  reportFileChangeDetectedOnCreateProgram = false;
119935
120025
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -119942,7 +120032,7 @@ function createWatchProgram(host) {
119942
120032
  compilerHost.writeFile = originalWriteFile;
119943
120033
  return builderProgram;
119944
120034
  }
119945
- function createNewProgram(hasInvalidatedResolutions) {
120035
+ function createNewProgram(hasInvalidatedResolutions, hasInvalidatedLibResolutions) {
119946
120036
  writeLog("CreatingProgramWith::");
119947
120037
  writeLog(` roots: ${JSON.stringify(rootFileNames)}`);
119948
120038
  writeLog(` options: ${JSON.stringify(compilerOptions)}`);
@@ -119953,6 +120043,7 @@ function createWatchProgram(host) {
119953
120043
  hasChangedConfigFileParsingErrors = false;
119954
120044
  resolutionCache.startCachingPerDirectoryResolution();
119955
120045
  compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
120046
+ compilerHost.hasInvalidatedLibResolutions = hasInvalidatedLibResolutions;
119956
120047
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
119957
120048
  const oldProgram = getCurrentProgram();
119958
120049
  builderProgram = createProgram2(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -120505,6 +120596,7 @@ function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, optio
120505
120596
  compilerHost.getParsedCommandLine = (fileName) => parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName));
120506
120597
  compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
120507
120598
  compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
120599
+ compilerHost.resolveLibrary = maybeBind(host, host.resolveLibrary);
120508
120600
  compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
120509
120601
  compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
120510
120602
  compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache);
@@ -120542,6 +120634,23 @@ function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, optio
120542
120634
  createTypeReferenceResolutionLoader
120543
120635
  );
120544
120636
  }
120637
+ let libraryResolutionCache;
120638
+ if (!compilerHost.resolveLibrary) {
120639
+ libraryResolutionCache = createModuleResolutionCache(
120640
+ compilerHost.getCurrentDirectory(),
120641
+ compilerHost.getCanonicalFileName,
120642
+ /*options*/
120643
+ void 0,
120644
+ moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()
120645
+ );
120646
+ compilerHost.resolveLibrary = (libraryName, resolveFrom, options2) => resolveLibrary(
120647
+ libraryName,
120648
+ resolveFrom,
120649
+ options2,
120650
+ host,
120651
+ libraryResolutionCache
120652
+ );
120653
+ }
120545
120654
  compilerHost.getBuildInfo = (fileName, configFilePath) => getBuildInfo3(
120546
120655
  state,
120547
120656
  fileName,
@@ -120573,6 +120682,7 @@ function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, optio
120573
120682
  compilerHost,
120574
120683
  moduleResolutionCache,
120575
120684
  typeReferenceDirectiveResolutionCache,
120685
+ libraryResolutionCache,
120576
120686
  // Mutable state
120577
120687
  buildOrder: void 0,
120578
120688
  readFileWithCache: (f) => host.readFile(f),
@@ -120790,7 +120900,7 @@ function enableCache(state) {
120790
120900
  function disableCache(state) {
120791
120901
  if (!state.cache)
120792
120902
  return;
120793
- const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache, typeReferenceDirectiveResolutionCache } = state;
120903
+ const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache, typeReferenceDirectiveResolutionCache, libraryResolutionCache } = state;
120794
120904
  host.readFile = cache.originalReadFile;
120795
120905
  host.fileExists = cache.originalFileExists;
120796
120906
  host.directoryExists = cache.originalDirectoryExists;
@@ -120801,6 +120911,7 @@ function disableCache(state) {
120801
120911
  extendedConfigCache.clear();
120802
120912
  moduleResolutionCache == null ? void 0 : moduleResolutionCache.clear();
120803
120913
  typeReferenceDirectiveResolutionCache == null ? void 0 : typeReferenceDirectiveResolutionCache.clear();
120914
+ libraryResolutionCache == null ? void 0 : libraryResolutionCache.clear();
120804
120915
  state.cache = void 0;
120805
120916
  }
120806
120917
  function clearProjectStatus(state, resolved) {