typescript 5.1.0-dev.20230509 → 5.1.0-dev.20230510

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/tsserver.js CHANGED
@@ -418,6 +418,7 @@ __export(server_exports, {
418
418
  createMemberAccessForPropertyName: () => createMemberAccessForPropertyName,
419
419
  createModeAwareCache: () => createModeAwareCache,
420
420
  createModeAwareCacheKey: () => createModeAwareCacheKey,
421
+ createModuleNotFoundChain: () => createModuleNotFoundChain,
421
422
  createModuleResolutionCache: () => createModuleResolutionCache,
422
423
  createModuleResolutionLoader: () => createModuleResolutionLoader,
423
424
  createModuleSpecifierResolutionHost: () => createModuleSpecifierResolutionHost,
@@ -2303,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
2303
2304
 
2304
2305
  // src/compiler/corePublic.ts
2305
2306
  var versionMajorMinor = "5.1";
2306
- var version = `${versionMajorMinor}.0-dev.20230509`;
2307
+ var version = `${versionMajorMinor}.0-dev.20230510`;
2307
2308
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2308
2309
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2309
2310
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -14573,7 +14574,6 @@ function isLeftHandSideExpressionKind(kind) {
14573
14574
  case 283 /* JsxElement */:
14574
14575
  case 284 /* JsxSelfClosingElement */:
14575
14576
  case 287 /* JsxFragment */:
14576
- case 294 /* JsxNamespacedName */:
14577
14577
  case 214 /* TaggedTemplateExpression */:
14578
14578
  case 208 /* ArrayLiteralExpression */:
14579
14579
  case 216 /* ParenthesizedExpression */:
@@ -15133,7 +15133,39 @@ function projectReferenceIsEqualTo(oldRef, newRef) {
15133
15133
  return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
15134
15134
  }
15135
15135
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
15136
- return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
15136
+ return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.node10Result === newResolution.node10Result;
15137
+ }
15138
+ function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
15139
+ var _a, _b;
15140
+ const node10Result = (_b = (_a = sourceFile.resolvedModules) == null ? void 0 : _a.get(moduleReference, mode)) == null ? void 0 : _b.node10Result;
15141
+ const result = node10Result ? chainDiagnosticMessages(
15142
+ /*details*/
15143
+ void 0,
15144
+ Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings,
15145
+ node10Result,
15146
+ node10Result.indexOf(nodeModulesPathPart + "@types/") > -1 ? `@types/${mangleScopedPackageName(packageName)}` : packageName
15147
+ ) : host.typesPackageExists(packageName) ? chainDiagnosticMessages(
15148
+ /*details*/
15149
+ void 0,
15150
+ Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1,
15151
+ packageName,
15152
+ mangleScopedPackageName(packageName)
15153
+ ) : host.packageBundlesTypes(packageName) ? chainDiagnosticMessages(
15154
+ /*details*/
15155
+ void 0,
15156
+ Diagnostics.If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1,
15157
+ packageName,
15158
+ moduleReference
15159
+ ) : chainDiagnosticMessages(
15160
+ /*details*/
15161
+ void 0,
15162
+ Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0,
15163
+ moduleReference,
15164
+ mangleScopedPackageName(packageName)
15165
+ );
15166
+ if (result)
15167
+ result.repopulateInfo = () => ({ moduleReference, mode, packageName: packageName === moduleReference ? void 0 : packageName });
15168
+ return result;
15137
15169
  }
15138
15170
  function packageIdIsEqual(a, b) {
15139
15171
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
@@ -16088,6 +16120,8 @@ function tryGetTextOfPropertyName(name) {
16088
16120
  if (isStringOrNumericLiteralLike(name.expression))
16089
16121
  return escapeLeadingUnderscores(name.expression.text);
16090
16122
  return void 0;
16123
+ case 294 /* JsxNamespacedName */:
16124
+ return getEscapedTextOfJsxNamespacedName(name);
16091
16125
  default:
16092
16126
  return Debug.assertNever(name);
16093
16127
  }
@@ -18073,6 +18107,8 @@ function getPropertyNameForPropertyNameNode(name) {
18073
18107
  return nameExpression.operand.text;
18074
18108
  }
18075
18109
  return void 0;
18110
+ case 294 /* JsxNamespacedName */:
18111
+ return getEscapedTextOfJsxNamespacedName(name);
18076
18112
  default:
18077
18113
  return Debug.assertNever(name);
18078
18114
  }
@@ -18089,10 +18125,10 @@ function isPropertyNameLiteral(node) {
18089
18125
  }
18090
18126
  }
18091
18127
  function getTextOfIdentifierOrLiteral(node) {
18092
- return isMemberName(node) ? idText(node) : node.text;
18128
+ return isMemberName(node) ? idText(node) : isJsxNamespacedName(node) ? getTextOfJsxNamespacedName(node) : node.text;
18093
18129
  }
18094
18130
  function getEscapedTextOfIdentifierOrLiteral(node) {
18095
- return isMemberName(node) ? node.escapedText : escapeLeadingUnderscores(node.text);
18131
+ return isMemberName(node) ? node.escapedText : isJsxNamespacedName(node) ? getEscapedTextOfJsxNamespacedName(node) : escapeLeadingUnderscores(node.text);
18096
18132
  }
18097
18133
  function getPropertyNameForUniqueESSymbol(symbol) {
18098
18134
  return `__@${getSymbolId(symbol)}@${symbol.escapedName}`;
@@ -19387,6 +19423,8 @@ function tryGetPropertyAccessOrIdentifierToString(expr) {
19387
19423
  }
19388
19424
  } else if (isIdentifier(expr)) {
19389
19425
  return unescapeLeadingUnderscores(expr.escapedText);
19426
+ } else if (isJsxNamespacedName(expr)) {
19427
+ return getTextOfJsxNamespacedName(expr);
19390
19428
  }
19391
19429
  return void 0;
19392
19430
  }
@@ -33966,7 +34004,11 @@ var Parser;
33966
34004
  }
33967
34005
  function parseJsxElementName() {
33968
34006
  const pos = getNodePos();
33969
- let expression = parseJsxTagName();
34007
+ const initialExpression = parseJsxTagName();
34008
+ if (isJsxNamespacedName(initialExpression)) {
34009
+ return initialExpression;
34010
+ }
34011
+ let expression = initialExpression;
33970
34012
  while (parseOptional(25 /* DotToken */)) {
33971
34013
  expression = finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(
33972
34014
  /*allowIdentifierNames*/
@@ -42019,8 +42061,6 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
42019
42061
  const diagnosticState = {
42020
42062
  ...state,
42021
42063
  features: state.features & ~8 /* Exports */,
42022
- failedLookupLocations: [],
42023
- affectingLocations: [],
42024
42064
  reportDiagnostic: noop
42025
42065
  };
42026
42066
  const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
@@ -47028,7 +47068,10 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
47028
47068
  const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
47029
47069
  if (isString(mainFileRelative) && !(maybeBlockedByTypesVersions && matchPatternOrExact(tryParsePatterns(versionPaths.paths), mainFileRelative))) {
47030
47070
  const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
47031
- if (removeFileExtension(mainExportFile) === removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
47071
+ const canonicalModuleFileToTry = getCanonicalFileName(moduleFileToTry);
47072
+ if (removeFileExtension(mainExportFile) === removeFileExtension(canonicalModuleFileToTry)) {
47073
+ return { packageRootPath, moduleFileToTry };
47074
+ } else if (packageJsonContent.type !== "module" && !fileExtensionIsOneOf(canonicalModuleFileToTry, extensionsNotSupportingExtensionlessResolution) && startsWith(canonicalModuleFileToTry, mainExportFile) && getDirectoryPath(canonicalModuleFileToTry) === removeTrailingDirectorySeparator(mainExportFile) && removeFileExtension(getBaseFileName(canonicalModuleFileToTry)) === "index") {
47032
47075
  return { packageRootPath, moduleFileToTry };
47033
47076
  }
47034
47077
  }
@@ -47294,18 +47337,6 @@ function isInstantiatedModule(node, preserveConstEnums) {
47294
47337
  return moduleState === 1 /* Instantiated */ || preserveConstEnums && moduleState === 2 /* ConstEnumOnly */;
47295
47338
  }
47296
47339
  function createTypeChecker(host) {
47297
- var getPackagesMap = memoize(() => {
47298
- var map2 = /* @__PURE__ */ new Map();
47299
- host.getSourceFiles().forEach((sf) => {
47300
- if (!sf.resolvedModules)
47301
- return;
47302
- sf.resolvedModules.forEach(({ resolvedModule }) => {
47303
- if (resolvedModule == null ? void 0 : resolvedModule.packageId)
47304
- map2.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map2.get(resolvedModule.packageId.name));
47305
- });
47306
- });
47307
- return map2;
47308
- });
47309
47340
  var deferredDiagnosticsCallbacks = [];
47310
47341
  var addLazyDiagnostic = (arg) => {
47311
47342
  deferredDiagnosticsCallbacks.push(arg);
@@ -49088,7 +49119,7 @@ function createTypeChecker(host) {
49088
49119
  if (!result) {
49089
49120
  if (nameNotFoundMessage) {
49090
49121
  addLazyDiagnostic(() => {
49091
- if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49122
+ if (!errorLocation || errorLocation.parent.kind !== 330 /* JSDocLink */ && !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49092
49123
  !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
49093
49124
  let suggestion;
49094
49125
  let suggestedLib;
@@ -50641,35 +50672,9 @@ function createTypeChecker(host) {
50641
50672
  }
50642
50673
  }
50643
50674
  function errorOnImplicitAnyModule(isError, errorNode, sourceFile, mode, { packageId, resolvedFileName }, moduleReference) {
50644
- var _a, _b;
50645
50675
  let errorInfo;
50646
50676
  if (!isExternalModuleNameRelative(moduleReference) && packageId) {
50647
- const node10Result = (_b = (_a = sourceFile.resolvedModules) == null ? void 0 : _a.get(moduleReference, mode)) == null ? void 0 : _b.node10Result;
50648
- errorInfo = node10Result ? chainDiagnosticMessages(
50649
- /*details*/
50650
- void 0,
50651
- Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings,
50652
- node10Result,
50653
- node10Result.indexOf(nodeModulesPathPart + "@types/") > -1 ? `@types/${mangleScopedPackageName(packageId.name)}` : packageId.name
50654
- ) : typesPackageExists(packageId.name) ? chainDiagnosticMessages(
50655
- /*details*/
50656
- void 0,
50657
- Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1,
50658
- packageId.name,
50659
- mangleScopedPackageName(packageId.name)
50660
- ) : packageBundlesTypes(packageId.name) ? chainDiagnosticMessages(
50661
- /*details*/
50662
- void 0,
50663
- Diagnostics.If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1,
50664
- packageId.name,
50665
- moduleReference
50666
- ) : chainDiagnosticMessages(
50667
- /*details*/
50668
- void 0,
50669
- Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0,
50670
- moduleReference,
50671
- mangleScopedPackageName(packageId.name)
50672
- );
50677
+ errorInfo = createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageId.name);
50673
50678
  }
50674
50679
  errorOrSuggestion(isError, errorNode, chainDiagnosticMessages(
50675
50680
  errorInfo,
@@ -50678,12 +50683,6 @@ function createTypeChecker(host) {
50678
50683
  resolvedFileName
50679
50684
  ));
50680
50685
  }
50681
- function typesPackageExists(packageName) {
50682
- return getPackagesMap().has(getTypesPackageName(packageName));
50683
- }
50684
- function packageBundlesTypes(packageName) {
50685
- return !!getPackagesMap().get(packageName);
50686
- }
50687
50686
  function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
50688
50687
  if (moduleSymbol == null ? void 0 : moduleSymbol.exports) {
50689
50688
  const exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias);
@@ -61194,7 +61193,20 @@ function createTypeChecker(host) {
61194
61193
  if (isPrivateIdentifier(name)) {
61195
61194
  return neverType;
61196
61195
  }
61197
- return isIdentifier(name) ? getStringLiteralType(unescapeLeadingUnderscores(name.escapedText)) : getRegularTypeOfLiteralType(isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
61196
+ if (isNumericLiteral(name)) {
61197
+ return getRegularTypeOfLiteralType(checkExpression(name));
61198
+ }
61199
+ if (isComputedPropertyName(name)) {
61200
+ return getRegularTypeOfLiteralType(checkComputedPropertyName(name));
61201
+ }
61202
+ const propertyName = getPropertyNameForPropertyNameNode(name);
61203
+ if (propertyName !== void 0) {
61204
+ return getStringLiteralType(unescapeLeadingUnderscores(propertyName));
61205
+ }
61206
+ if (isExpression(name)) {
61207
+ return getRegularTypeOfLiteralType(checkExpression(name));
61208
+ }
61209
+ return neverType;
61198
61210
  }
61199
61211
  function getLiteralTypeFromProperty(prop, include, includeNonPublic) {
61200
61212
  if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) {
@@ -74324,7 +74336,7 @@ function createTypeChecker(host) {
74324
74336
  if (getJsxNamespaceContainerForImplicitImport(node)) {
74325
74337
  return true;
74326
74338
  }
74327
- const tagType = isJsxOpeningElement(node) || isJsxSelfClosingElement(node) && !isJsxIntrinsicTagName(node.tagName) ? checkExpression(node.tagName) : void 0;
74339
+ const tagType = (isJsxOpeningElement(node) || isJsxSelfClosingElement(node)) && !(isJsxIntrinsicTagName(node.tagName) || isJsxNamespacedName(node.tagName)) ? checkExpression(node.tagName) : void 0;
74328
74340
  if (!tagType) {
74329
74341
  return true;
74330
74342
  }
@@ -84906,7 +84918,7 @@ function createTypeChecker(host) {
84906
84918
  name,
84907
84919
  meaning,
84908
84920
  /*ignoreErrors*/
84909
- false,
84921
+ true,
84910
84922
  /*dontResolveAlias*/
84911
84923
  true,
84912
84924
  getHostSignatureFromJSDoc(name)
@@ -84917,7 +84929,7 @@ function createTypeChecker(host) {
84917
84929
  return resolveJSDocMemberName(
84918
84930
  name,
84919
84931
  /*ignoreErrors*/
84920
- false,
84932
+ true,
84921
84933
  getSymbolOfDeclaration(container)
84922
84934
  );
84923
84935
  }
@@ -113224,6 +113236,8 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113224
113236
  return emitJsxSpreadAttribute(node);
113225
113237
  case 293 /* JsxExpression */:
113226
113238
  return emitJsxExpression(node);
113239
+ case 294 /* JsxNamespacedName */:
113240
+ return emitJsxNamespacedName(node);
113227
113241
  case 295 /* CaseClause */:
113228
113242
  return emitCaseClause(node);
113229
113243
  case 296 /* DefaultClause */:
@@ -113419,8 +113433,6 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113419
113433
  return emitJsxSelfClosingElement(node);
113420
113434
  case 287 /* JsxFragment */:
113421
113435
  return emitJsxFragment(node);
113422
- case 294 /* JsxNamespacedName */:
113423
- return emitJsxNamespacedName(node);
113424
113436
  case 357 /* SyntaxList */:
113425
113437
  return Debug.fail("SyntaxList should not be printed");
113426
113438
  case 358 /* NotEmittedStatement */:
@@ -116252,6 +116264,10 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116252
116264
  if (!canUseSourceFile || getSourceFileOfNode(node) !== getOriginalNode(sourceFile)) {
116253
116265
  return idText(node);
116254
116266
  }
116267
+ } else if (isJsxNamespacedName(node)) {
116268
+ if (!canUseSourceFile || getSourceFileOfNode(node) !== getOriginalNode(sourceFile)) {
116269
+ return getTextOfJsxNamespacedName(node);
116270
+ }
116255
116271
  } else {
116256
116272
  Debug.assertNode(node, isLiteralExpression);
116257
116273
  if (!canUseSourceFile) {
@@ -116263,7 +116279,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116263
116279
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
116264
116280
  if (node.kind === 11 /* StringLiteral */ && node.textSourceNode) {
116265
116281
  const textSourceNode = node.textSourceNode;
116266
- if (isIdentifier(textSourceNode) || isPrivateIdentifier(textSourceNode) || isNumericLiteral(textSourceNode)) {
116282
+ if (isIdentifier(textSourceNode) || isPrivateIdentifier(textSourceNode) || isNumericLiteral(textSourceNode) || isJsxNamespacedName(textSourceNode)) {
116267
116283
  const text = isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode2(textSourceNode);
116268
116284
  return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` : neverAsciiEscape || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? `"${escapeString(text)}"` : `"${escapeNonAsciiString(text)}"`;
116269
116285
  } else {
@@ -118529,6 +118545,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118529
118545
  let automaticTypeDirectiveResolutions;
118530
118546
  let resolvedLibReferences;
118531
118547
  let resolvedLibProcessing;
118548
+ let packageMap;
118532
118549
  const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
118533
118550
  let currentNodeModulesDepth = 0;
118534
118551
  const modulesWithElidedImports = /* @__PURE__ */ new Map();
@@ -118833,6 +118850,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118833
118850
  redirectTargetsMap,
118834
118851
  usesUriStyleNodeCoreModules,
118835
118852
  resolvedLibReferences,
118853
+ getCurrentPackagesMap: () => packageMap,
118854
+ typesPackageExists,
118855
+ packageBundlesTypes,
118836
118856
  isEmittedFile,
118837
118857
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
118838
118858
  getProjectReferences,
@@ -118873,6 +118893,26 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118873
118893
  measure("Program", "beforeProgram", "afterProgram");
118874
118894
  (_p = tracing) == null ? void 0 : _p.pop();
118875
118895
  return program;
118896
+ function getPackagesMap() {
118897
+ if (packageMap)
118898
+ return packageMap;
118899
+ packageMap = /* @__PURE__ */ new Map();
118900
+ files.forEach((sf) => {
118901
+ if (!sf.resolvedModules)
118902
+ return;
118903
+ sf.resolvedModules.forEach(({ resolvedModule }) => {
118904
+ if (resolvedModule == null ? void 0 : resolvedModule.packageId)
118905
+ packageMap.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!packageMap.get(resolvedModule.packageId.name));
118906
+ });
118907
+ });
118908
+ return packageMap;
118909
+ }
118910
+ function typesPackageExists(packageName) {
118911
+ return getPackagesMap().has(getTypesPackageName(packageName));
118912
+ }
118913
+ function packageBundlesTypes(packageName) {
118914
+ return !!getPackagesMap().get(packageName);
118915
+ }
118876
118916
  function addResolutionDiagnostics(resolution) {
118877
118917
  var _a2;
118878
118918
  if (!((_a2 = resolution.resolutionDiagnostics) == null ? void 0 : _a2.length))
@@ -119361,6 +119401,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119361
119401
  redirectTargetsMap = oldProgram.redirectTargetsMap;
119362
119402
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
119363
119403
  resolvedLibReferences = oldProgram.resolvedLibReferences;
119404
+ packageMap = oldProgram.getCurrentPackagesMap();
119364
119405
  return 2 /* Completely */;
119365
119406
  }
119366
119407
  function getEmitHost(writeFileCallback) {
@@ -122236,7 +122277,10 @@ function createBuilderProgramState(newProgram, oldState) {
122236
122277
  return;
122237
122278
  const diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
122238
122279
  if (diagnostics) {
122239
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
122280
+ state.semanticDiagnosticsPerFile.set(
122281
+ sourceFilePath,
122282
+ oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
122283
+ );
122240
122284
  if (!state.semanticDiagnosticsFromOldState) {
122241
122285
  state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set();
122242
122286
  }
@@ -122307,6 +122351,33 @@ function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature)
122307
122351
  isString(oldEmitSignature) ? [oldEmitSignature] : oldEmitSignature[0]
122308
122352
  );
122309
122353
  }
122354
+ function repopulateDiagnostics(diagnostics, newProgram) {
122355
+ if (!diagnostics.length)
122356
+ return diagnostics;
122357
+ return sameMap(diagnostics, (diag2) => {
122358
+ if (isString(diag2.messageText))
122359
+ return diag2;
122360
+ const repopulatedChain = convertOrRepopulateDiagnosticMessageChain(diag2.messageText, diag2.file, newProgram, (chain) => {
122361
+ var _a;
122362
+ return (_a = chain.repopulateInfo) == null ? void 0 : _a.call(chain);
122363
+ });
122364
+ return repopulatedChain === diag2.messageText ? diag2 : { ...diag2, messageText: repopulatedChain };
122365
+ });
122366
+ }
122367
+ function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo) {
122368
+ const info = repopulateInfo(chain);
122369
+ if (info) {
122370
+ return {
122371
+ ...createModuleNotFoundChain(sourceFile, newProgram, info.moduleReference, info.mode, info.packageName || info.moduleReference),
122372
+ next: convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo)
122373
+ };
122374
+ }
122375
+ const next = convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo);
122376
+ return next === chain.next ? chain : { ...chain, next };
122377
+ }
122378
+ function convertOrRepopulateDiagnosticMessageChainArray(array, sourceFile, newProgram, repopulateInfo) {
122379
+ return sameMap(array, (chain) => convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo));
122380
+ }
122310
122381
  function convertToDiagnostics(diagnostics, newProgram) {
122311
122382
  if (!diagnostics.length)
122312
122383
  return emptyArray;
@@ -122328,9 +122399,11 @@ function convertToDiagnostics(diagnostics, newProgram) {
122328
122399
  }
122329
122400
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
122330
122401
  const { file } = diagnostic;
122402
+ const sourceFile = file ? newProgram.getSourceFileByPath(toPath3(file)) : void 0;
122331
122403
  return {
122332
122404
  ...diagnostic,
122333
- file: file ? newProgram.getSourceFileByPath(toPath3(file)) : void 0
122405
+ file: sourceFile,
122406
+ messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertOrRepopulateDiagnosticMessageChain(diagnostic.messageText, sourceFile, newProgram, (chain) => chain.info)
122334
122407
  };
122335
122408
  }
122336
122409
  function releaseCache(state) {
@@ -122872,9 +122945,35 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBui
122872
122945
  const { file } = diagnostic;
122873
122946
  return {
122874
122947
  ...diagnostic,
122875
- file: file ? relativeToBuildInfo(file.resolvedPath) : void 0
122948
+ file: file ? relativeToBuildInfo(file.resolvedPath) : void 0,
122949
+ messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
122876
122950
  };
122877
122951
  }
122952
+ function convertToReusableDiagnosticMessageChain(chain) {
122953
+ if (chain.repopulateInfo) {
122954
+ return {
122955
+ info: chain.repopulateInfo(),
122956
+ next: convertToReusableDiagnosticMessageChainArray(chain.next)
122957
+ };
122958
+ }
122959
+ const next = convertToReusableDiagnosticMessageChainArray(chain.next);
122960
+ return next === chain.next ? chain : { ...chain, next };
122961
+ }
122962
+ function convertToReusableDiagnosticMessageChainArray(array) {
122963
+ if (!array)
122964
+ return array;
122965
+ return forEach(array, (chain, index) => {
122966
+ const reusable = convertToReusableDiagnosticMessageChain(chain);
122967
+ if (chain === reusable)
122968
+ return void 0;
122969
+ const result = index > 0 ? array.slice(0, index - 1) : [];
122970
+ result.push(reusable);
122971
+ for (let i = index + 1; i < array.length; i++) {
122972
+ result.push(convertToReusableDiagnosticMessageChain(array[i]));
122973
+ }
122974
+ return result;
122975
+ }) || array;
122976
+ }
122878
122977
  var BuilderProgramKind = /* @__PURE__ */ ((BuilderProgramKind2) => {
122879
122978
  BuilderProgramKind2[BuilderProgramKind2["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
122880
122979
  BuilderProgramKind2[BuilderProgramKind2["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
@@ -123976,45 +124075,51 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123976
124075
  }
123977
124076
  (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
123978
124077
  }
124078
+ function watchFailedLookupLocation(failedLookupLocation, setAtRoot) {
124079
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
124080
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
124081
+ failedLookupLocation,
124082
+ failedLookupLocationPath,
124083
+ rootDir,
124084
+ rootPath,
124085
+ rootPathComponents,
124086
+ getCurrentDirectory
124087
+ );
124088
+ if (toWatch) {
124089
+ const { dir, dirPath, nonRecursive } = toWatch;
124090
+ if (dirPath === rootPath) {
124091
+ Debug.assert(nonRecursive);
124092
+ setAtRoot = true;
124093
+ } else {
124094
+ setDirectoryWatcher(dir, dirPath, nonRecursive);
124095
+ }
124096
+ }
124097
+ return setAtRoot;
124098
+ }
123979
124099
  function watchFailedLookupLocationOfResolution(resolution) {
123980
124100
  Debug.assert(!!resolution.refCount);
123981
- const { failedLookupLocations, affectingLocations } = resolution;
123982
- if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
124101
+ const { failedLookupLocations, affectingLocations, node10Result } = resolution;
124102
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !node10Result)
123983
124103
  return;
123984
- if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
124104
+ if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || node10Result)
123985
124105
  resolutionsWithFailedLookups.add(resolution);
123986
124106
  let setAtRoot = false;
123987
124107
  if (failedLookupLocations) {
123988
124108
  for (const failedLookupLocation of failedLookupLocations) {
123989
- const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123990
- const toWatch = getDirectoryToWatchFailedLookupLocation(
123991
- failedLookupLocation,
123992
- failedLookupLocationPath,
123993
- rootDir,
123994
- rootPath,
123995
- rootPathComponents,
123996
- getCurrentDirectory
123997
- );
123998
- if (toWatch) {
123999
- const { dir, dirPath, nonRecursive } = toWatch;
124000
- if (dirPath === rootPath) {
124001
- Debug.assert(nonRecursive);
124002
- setAtRoot = true;
124003
- } else {
124004
- setDirectoryWatcher(dir, dirPath, nonRecursive);
124005
- }
124006
- }
124007
- }
124008
- if (setAtRoot) {
124009
- setDirectoryWatcher(
124010
- rootDir,
124011
- rootPath,
124012
- /*nonRecursive*/
124013
- true
124014
- );
124109
+ setAtRoot = watchFailedLookupLocation(failedLookupLocation, setAtRoot);
124015
124110
  }
124016
124111
  }
124017
- watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length));
124112
+ if (node10Result)
124113
+ setAtRoot = watchFailedLookupLocation(node10Result, setAtRoot);
124114
+ if (setAtRoot) {
124115
+ setDirectoryWatcher(
124116
+ rootDir,
124117
+ rootPath,
124118
+ /*nonRecursive*/
124119
+ true
124120
+ );
124121
+ }
124122
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !node10Result);
124018
124123
  }
124019
124124
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
124020
124125
  Debug.assert(!!resolution.refCount);
@@ -124108,6 +124213,26 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124108
124213
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive });
124109
124214
  }
124110
124215
  }
124216
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
124217
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
124218
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
124219
+ failedLookupLocation,
124220
+ failedLookupLocationPath,
124221
+ rootDir,
124222
+ rootPath,
124223
+ rootPathComponents,
124224
+ getCurrentDirectory
124225
+ );
124226
+ if (toWatch) {
124227
+ const { dirPath } = toWatch;
124228
+ if (dirPath === rootPath) {
124229
+ removeAtRoot = true;
124230
+ } else {
124231
+ removeDirectoryWatcher(dirPath);
124232
+ }
124233
+ }
124234
+ return removeAtRoot;
124235
+ }
124111
124236
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
124112
124237
  Debug.checkDefined(resolution.files).delete(filePath);
124113
124238
  resolution.refCount--;
@@ -124121,31 +124246,18 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124121
124246
  if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size)
124122
124247
  resolvedFileToResolution.delete(key);
124123
124248
  }
124124
- const { failedLookupLocations, affectingLocations } = resolution;
124249
+ const { failedLookupLocations, affectingLocations, node10Result } = resolution;
124125
124250
  if (resolutionsWithFailedLookups.delete(resolution)) {
124126
124251
  let removeAtRoot = false;
124127
- for (const failedLookupLocation of failedLookupLocations) {
124128
- const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
124129
- const toWatch = getDirectoryToWatchFailedLookupLocation(
124130
- failedLookupLocation,
124131
- failedLookupLocationPath,
124132
- rootDir,
124133
- rootPath,
124134
- rootPathComponents,
124135
- getCurrentDirectory
124136
- );
124137
- if (toWatch) {
124138
- const { dirPath } = toWatch;
124139
- if (dirPath === rootPath) {
124140
- removeAtRoot = true;
124141
- } else {
124142
- removeDirectoryWatcher(dirPath);
124143
- }
124252
+ if (failedLookupLocations) {
124253
+ for (const failedLookupLocation of failedLookupLocations) {
124254
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
124144
124255
  }
124145
124256
  }
124146
- if (removeAtRoot) {
124257
+ if (node10Result)
124258
+ removeAtRoot = stopWatchFailedLookupLocation(node10Result, removeAtRoot);
124259
+ if (removeAtRoot)
124147
124260
  removeDirectoryWatcher(rootPath);
124148
- }
124149
124261
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
124150
124262
  resolutionsWithOnlyAffectingLocations.delete(resolution);
124151
124263
  }
@@ -124299,7 +124411,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124299
124411
  return true;
124300
124412
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
124301
124413
  return false;
124302
- return (_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
124414
+ return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)))) || !!resolution.node10Result && isInvalidatedFailedLookup(resolutionHost.toPath(resolution.node10Result));
124303
124415
  }
124304
124416
  function isInvalidatedFailedLookup(locationPath) {
124305
124417
  return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (dirPath) => locationPath.length > dirPath.length && startsWith(locationPath, dirPath) && (isDiskPathRoot(dirPath) || locationPath[dirPath.length] === directorySeparator) ? true : void 0);
@@ -166241,8 +166353,9 @@ var changesToText;
166241
166353
  }
166242
166354
  const textChanges2 = mapDefined(normalized, (c) => {
166243
166355
  const span = createTextSpanFromRange(c.range);
166244
- const newText = computeNewText(c, sourceFile, newLineCharacter, formatContext, validate);
166245
- if (span.length === newText.length && stringContainsAt(sourceFile.text, newText, span.start)) {
166356
+ const targetSourceFile = c.kind === 1 /* ReplaceWithSingleNode */ ? getSourceFileOfNode(getOriginalNode(c.node)) ?? c.sourceFile : c.kind === 2 /* ReplaceWithMultipleNodes */ ? getSourceFileOfNode(getOriginalNode(c.nodes[0])) ?? c.sourceFile : c.sourceFile;
166357
+ const newText = computeNewText(c, targetSourceFile, sourceFile, newLineCharacter, formatContext, validate);
166358
+ if (span.length === newText.length && stringContainsAt(targetSourceFile.text, newText, span.start)) {
166246
166359
  return void 0;
166247
166360
  }
166248
166361
  return createTextChange(span, newText);
@@ -166270,7 +166383,7 @@ var changesToText;
166270
166383
  return applyChanges(nonFormattedText, changes) + newLineCharacter;
166271
166384
  }
166272
166385
  changesToText2.newFileChangesWorker = newFileChangesWorker;
166273
- function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) {
166386
+ function computeNewText(change, targetSourceFile, sourceFile, newLineCharacter, formatContext, validate) {
166274
166387
  var _a;
166275
166388
  if (change.kind === 0 /* Remove */) {
166276
166389
  return "";
@@ -166279,17 +166392,17 @@ var changesToText;
166279
166392
  return change.text;
166280
166393
  }
166281
166394
  const { options = {}, range: { pos } } = change;
166282
- const format = (n) => getFormattedTextOfNode(n, sourceFile, pos, options, newLineCharacter, formatContext, validate);
166395
+ const format = (n) => getFormattedTextOfNode(n, targetSourceFile, sourceFile, pos, options, newLineCharacter, formatContext, validate);
166283
166396
  const text = change.kind === 2 /* ReplaceWithMultipleNodes */ ? change.nodes.map((n) => removeSuffix(format(n), newLineCharacter)).join(((_a = change.options) == null ? void 0 : _a.joiner) || newLineCharacter) : format(change.node);
166284
- const noIndent = options.indentation !== void 0 || getLineStartPositionForPosition(pos, sourceFile) === pos ? text : text.replace(/^\s+/, "");
166397
+ const noIndent = options.indentation !== void 0 || getLineStartPositionForPosition(pos, targetSourceFile) === pos ? text : text.replace(/^\s+/, "");
166285
166398
  return (options.prefix || "") + noIndent + (!options.suffix || endsWith(noIndent, options.suffix) ? "" : options.suffix);
166286
166399
  }
166287
- function getFormattedTextOfNode(nodeIn, sourceFile, pos, { indentation, prefix, delta }, newLineCharacter, formatContext, validate) {
166288
- const { node, text } = getNonformattedText(nodeIn, sourceFile, newLineCharacter);
166400
+ function getFormattedTextOfNode(nodeIn, targetSourceFile, sourceFile, pos, { indentation, prefix, delta }, newLineCharacter, formatContext, validate) {
166401
+ const { node, text } = getNonformattedText(nodeIn, targetSourceFile, newLineCharacter);
166289
166402
  if (validate)
166290
166403
  validate(node, text);
166291
- const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
166292
- const initialIndentation = indentation !== void 0 ? indentation : ts_formatting_exports.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || getLineStartPositionForPosition(pos, sourceFile) === pos);
166404
+ const formatOptions = getFormatCodeSettingsForWriting(formatContext, targetSourceFile);
166405
+ const initialIndentation = indentation !== void 0 ? indentation : ts_formatting_exports.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || getLineStartPositionForPosition(pos, targetSourceFile) === pos);
166293
166406
  if (delta === void 0) {
166294
166407
  delta = ts_formatting_exports.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? formatOptions.indentSize || 0 : 0;
166295
166408
  }
@@ -166299,7 +166412,7 @@ var changesToText;
166299
166412
  return getLineAndCharacterOfPosition(this, pos2);
166300
166413
  }
166301
166414
  };
166302
- const changes = ts_formatting_exports.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, { ...formatContext, options: formatOptions });
166415
+ const changes = ts_formatting_exports.formatNodeGivenIndentation(node, file, targetSourceFile.languageVariant, initialIndentation, delta, { ...formatContext, options: formatOptions });
166303
166416
  return applyChanges(text, changes);
166304
166417
  }
166305
166418
  function getNonformattedText(node, sourceFile, newLineCharacter) {
@@ -169845,6 +169958,7 @@ __export(ts_exports2, {
169845
169958
  createMemberAccessForPropertyName: () => createMemberAccessForPropertyName,
169846
169959
  createModeAwareCache: () => createModeAwareCache,
169847
169960
  createModeAwareCacheKey: () => createModeAwareCacheKey,
169961
+ createModuleNotFoundChain: () => createModuleNotFoundChain,
169848
169962
  createModuleResolutionCache: () => createModuleResolutionCache,
169849
169963
  createModuleResolutionLoader: () => createModuleResolutionLoader,
169850
169964
  createModuleSpecifierResolutionHost: () => createModuleSpecifierResolutionHost,
@@ -184314,6 +184428,7 @@ start(initializeNodeSystem(), require("os").platform());
184314
184428
  createMemberAccessForPropertyName,
184315
184429
  createModeAwareCache,
184316
184430
  createModeAwareCacheKey,
184431
+ createModuleNotFoundChain,
184317
184432
  createModuleResolutionCache,
184318
184433
  createModuleResolutionLoader,
184319
184434
  createModuleSpecifierResolutionHost,