@typescript-deploys/pr-build 5.4.0-pr-56404-7 → 5.4.0-pr-55015-10

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
@@ -16448,6 +16448,22 @@ function getResolvePackageJsonExports(compilerOptions) {
16448
16448
  }
16449
16449
  return false;
16450
16450
  }
16451
+ function getResolvePackageJsonImports(compilerOptions) {
16452
+ const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
16453
+ if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
16454
+ return false;
16455
+ }
16456
+ if (compilerOptions.resolvePackageJsonExports !== void 0) {
16457
+ return compilerOptions.resolvePackageJsonExports;
16458
+ }
16459
+ switch (moduleResolution) {
16460
+ case 3 /* Node16 */:
16461
+ case 99 /* NodeNext */:
16462
+ case 100 /* Bundler */:
16463
+ return true;
16464
+ }
16465
+ return false;
16466
+ }
16451
16467
  function getResolveJsonModule(compilerOptions) {
16452
16468
  if (compilerOptions.resolveJsonModule !== void 0) {
16453
16469
  return compilerOptions.resolveJsonModule;
@@ -42361,6 +42377,13 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
42361
42377
  }
42362
42378
 
42363
42379
  // src/compiler/moduleSpecifiers.ts
42380
+ function safeJsonRead(packageJsonPath, readFile) {
42381
+ try {
42382
+ return JSON.parse(readFile(packageJsonPath));
42383
+ } catch {
42384
+ return {};
42385
+ }
42386
+ }
42364
42387
  function getPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
42365
42388
  const preferredEnding = getPreferredEnding();
42366
42389
  return {
@@ -42553,7 +42576,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42553
42576
  const { sourceDirectory, getCanonicalFileName } = info;
42554
42577
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
42555
42578
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
42556
- if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
42579
+ if (!baseUrl && !paths && !getResolvePackageJsonImports(compilerOptions) || relativePreference === 0 /* Relative */) {
42557
42580
  return pathsOnly ? void 0 : relativePath;
42558
42581
  }
42559
42582
  const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
@@ -42561,11 +42584,12 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42561
42584
  if (!relativeToBaseUrl) {
42562
42585
  return pathsOnly ? void 0 : relativePath;
42563
42586
  }
42564
- const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions);
42587
+ const fromPackageJsonImports = pathsOnly ? void 0 : tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, compilerOptions, host, importMode);
42588
+ const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
42565
42589
  if (pathsOnly) {
42566
42590
  return fromPaths;
42567
42591
  }
42568
- const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths;
42592
+ const maybeNonRelative = fromPackageJsonImports ?? (fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths);
42569
42593
  if (!maybeNonRelative) {
42570
42594
  return relativePath;
42571
42595
  }
@@ -42604,8 +42628,8 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
42604
42628
  if (host.getNearestAncestorDirectoryWithPackageJson) {
42605
42629
  return host.getNearestAncestorDirectoryWithPackageJson(fileName);
42606
42630
  }
42607
- return !!forEachAncestorDirectory(fileName, (directory) => {
42608
- return host.fileExists(combinePaths(directory, "package.json")) ? true : void 0;
42631
+ return forEachAncestorDirectory(fileName, (directory) => {
42632
+ return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
42609
42633
  });
42610
42634
  }
42611
42635
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
@@ -42776,8 +42800,40 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
42776
42800
  return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
42777
42801
  }
42778
42802
  }
42779
- function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode = 0 /* Exact */) {
42803
+ function getOutputPath(targetFilePath, options, commonSourceDirectory) {
42804
+ return changeExtension(
42805
+ options.outDir ? resolvePath(
42806
+ options.outDir,
42807
+ getRelativePathFromDirectory(
42808
+ commonSourceDirectory,
42809
+ targetFilePath,
42810
+ /*ignoreCase*/
42811
+ false
42812
+ )
42813
+ ) : targetFilePath,
42814
+ getOutputExtension(targetFilePath, options)
42815
+ );
42816
+ }
42817
+ function getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory) {
42818
+ const declarationDir = options.declarationDir || options.outDir;
42819
+ return changeExtension(
42820
+ declarationDir ? resolvePath(
42821
+ declarationDir,
42822
+ getRelativePathFromDirectory(
42823
+ commonSourceDirectory,
42824
+ targetFilePath,
42825
+ /*ignoreCase*/
42826
+ false
42827
+ )
42828
+ ) : targetFilePath,
42829
+ getDeclarationEmitExtensionForPath(targetFilePath)
42830
+ );
42831
+ }
42832
+ function tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions, mode, isImports) {
42780
42833
  if (typeof exports === "string") {
42834
+ const commonSourceDirectory = host.getCommonSourceDirectory();
42835
+ const outputFile = isImports && getOutputPath(targetFilePath, options, commonSourceDirectory);
42836
+ const declarationFile = isImports && getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory);
42781
42837
  const pathOrPattern = getNormalizedAbsolutePath(
42782
42838
  combinePaths(packageDirectory, exports),
42783
42839
  /*currentDirectory*/
@@ -42786,11 +42842,24 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
42786
42842
  const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : void 0;
42787
42843
  switch (mode) {
42788
42844
  case 0 /* Exact */:
42789
- if (comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */) {
42845
+ if (extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */ || comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || outputFile && comparePaths(outputFile, pathOrPattern) === 0 /* EqualTo */ || declarationFile && comparePaths(declarationFile, pathOrPattern) === 0 /* EqualTo */) {
42790
42846
  return { moduleFileToTry: packageName };
42791
42847
  }
42792
42848
  break;
42793
42849
  case 1 /* Directory */:
42850
+ if (extensionSwappedTarget && containsPath(pathOrPattern, extensionSwappedTarget)) {
42851
+ const fragment = getRelativePathFromDirectory(
42852
+ pathOrPattern,
42853
+ extensionSwappedTarget,
42854
+ /*ignoreCase*/
42855
+ false
42856
+ );
42857
+ return { moduleFileToTry: getNormalizedAbsolutePath(
42858
+ combinePaths(combinePaths(packageName, exports), fragment),
42859
+ /*currentDirectory*/
42860
+ void 0
42861
+ ) };
42862
+ }
42794
42863
  if (containsPath(pathOrPattern, targetFilePath)) {
42795
42864
  const fragment = getRelativePathFromDirectory(
42796
42865
  pathOrPattern,
@@ -42804,48 +42873,136 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
42804
42873
  void 0
42805
42874
  ) };
42806
42875
  }
42876
+ if (outputFile && containsPath(pathOrPattern, outputFile)) {
42877
+ const fragment = getRelativePathFromDirectory(
42878
+ pathOrPattern,
42879
+ outputFile,
42880
+ /*ignoreCase*/
42881
+ false
42882
+ );
42883
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
42884
+ }
42885
+ if (declarationFile && containsPath(pathOrPattern, declarationFile)) {
42886
+ const fragment = getRelativePathFromDirectory(
42887
+ pathOrPattern,
42888
+ declarationFile,
42889
+ /*ignoreCase*/
42890
+ false
42891
+ );
42892
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
42893
+ }
42807
42894
  break;
42808
42895
  case 2 /* Pattern */:
42809
42896
  const starPos = pathOrPattern.indexOf("*");
42810
42897
  const leadingSlice = pathOrPattern.slice(0, starPos);
42811
42898
  const trailingSlice = pathOrPattern.slice(starPos + 1);
42899
+ if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
42900
+ const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
42901
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
42902
+ }
42812
42903
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
42813
42904
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
42814
42905
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
42815
42906
  }
42816
- if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
42817
- const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
42907
+ if (outputFile && startsWith(outputFile, leadingSlice) && endsWith(outputFile, trailingSlice)) {
42908
+ const starReplacement = outputFile.slice(leadingSlice.length, outputFile.length - trailingSlice.length);
42909
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
42910
+ }
42911
+ if (declarationFile && startsWith(declarationFile, leadingSlice) && endsWith(declarationFile, trailingSlice)) {
42912
+ const starReplacement = declarationFile.slice(leadingSlice.length, declarationFile.length - trailingSlice.length);
42818
42913
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
42819
42914
  }
42820
42915
  break;
42821
42916
  }
42822
42917
  } else if (Array.isArray(exports)) {
42823
- return forEach(exports, (e) => tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions));
42918
+ return forEach(exports, (e) => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
42824
42919
  } else if (typeof exports === "object" && exports !== null) {
42825
- if (allKeysStartWithDot(exports)) {
42826
- return forEach(getOwnKeys(exports), (k) => {
42827
- const subPackageName = getNormalizedAbsolutePath(
42828
- combinePaths(packageName, k),
42829
- /*currentDirectory*/
42830
- void 0
42831
- );
42832
- const mode2 = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
42833
- return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode2);
42834
- });
42835
- } else {
42836
- for (const key of getOwnKeys(exports)) {
42837
- if (key === "default" || conditions.includes(key) || isApplicableVersionedTypesKey(conditions, key)) {
42838
- const subTarget = exports[key];
42839
- const result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode);
42840
- if (result) {
42841
- return result;
42842
- }
42920
+ for (const key of getOwnKeys(exports)) {
42921
+ if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) {
42922
+ const subTarget = exports[key];
42923
+ const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports);
42924
+ if (result) {
42925
+ return result;
42843
42926
  }
42844
42927
  }
42845
42928
  }
42846
42929
  }
42847
42930
  return void 0;
42848
42931
  }
42932
+ function tryGetModuleNameFromExports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions) {
42933
+ if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports)) {
42934
+ return forEach(getOwnKeys(exports), (k) => {
42935
+ const subPackageName = getNormalizedAbsolutePath(
42936
+ combinePaths(packageName, k),
42937
+ /*currentDirectory*/
42938
+ void 0
42939
+ );
42940
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
42941
+ return tryGetModuleNameFromExportsOrImports(
42942
+ options,
42943
+ host,
42944
+ targetFilePath,
42945
+ packageDirectory,
42946
+ subPackageName,
42947
+ exports[k],
42948
+ conditions,
42949
+ mode,
42950
+ /*isImports*/
42951
+ false
42952
+ );
42953
+ });
42954
+ }
42955
+ return tryGetModuleNameFromExportsOrImports(
42956
+ options,
42957
+ host,
42958
+ targetFilePath,
42959
+ packageDirectory,
42960
+ packageName,
42961
+ exports,
42962
+ conditions,
42963
+ 0 /* Exact */,
42964
+ /*isImports*/
42965
+ false
42966
+ );
42967
+ }
42968
+ function tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, options, host, importMode) {
42969
+ var _a, _b, _c;
42970
+ if (!host.readFile || !getResolvePackageJsonImports(options)) {
42971
+ return void 0;
42972
+ }
42973
+ const ancestorDirectoryWithPackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
42974
+ if (!ancestorDirectoryWithPackageJson) {
42975
+ return void 0;
42976
+ }
42977
+ const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
42978
+ const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
42979
+ if (typeof cachedPackageJson !== "object" && cachedPackageJson !== void 0 || !host.fileExists(packageJsonPath)) {
42980
+ return void 0;
42981
+ }
42982
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
42983
+ const imports = packageJsonContent == null ? void 0 : packageJsonContent.imports;
42984
+ if (!imports) {
42985
+ return void 0;
42986
+ }
42987
+ const conditions = getConditions(options, importMode);
42988
+ return (_c = forEach(getOwnKeys(imports), (k) => {
42989
+ if (!startsWith(k, "#") || k === "#" || startsWith(k, "#/"))
42990
+ return void 0;
42991
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
42992
+ return tryGetModuleNameFromExportsOrImports(
42993
+ options,
42994
+ host,
42995
+ moduleFileName,
42996
+ ancestorDirectoryWithPackageJson,
42997
+ k,
42998
+ imports[k],
42999
+ conditions,
43000
+ mode,
43001
+ /*isImports*/
43002
+ true
43003
+ );
43004
+ })) == null ? void 0 : _c.moduleFileToTry;
43005
+ }
42849
43006
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
42850
43007
  const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
42851
43008
  if (normalizedTargetPaths === void 0) {
@@ -42919,16 +43076,15 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42919
43076
  let maybeBlockedByTypesVersions = false;
42920
43077
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
42921
43078
  if (typeof cachedPackageJson === "object" || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
42922
- const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
43079
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
42923
43080
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
42924
43081
  if (getResolvePackageJsonExports(options)) {
42925
43082
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
42926
43083
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
42927
43084
  const conditions = getConditions(options, importMode);
42928
- const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
43085
+ const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, host, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
42929
43086
  if (fromExports) {
42930
- const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
42931
- return { ...withJsExtension, verbatimFromExports: true };
43087
+ return { ...fromExports, verbatimFromExports: true };
42932
43088
  }
42933
43089
  if (packageJsonContent.exports) {
42934
43090
  return { moduleFileToTry: path, blockedByExports: true };
@@ -48232,15 +48388,13 @@ function createTypeChecker(host) {
48232
48388
  }
48233
48389
  const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key);
48234
48390
  if (cachedResult) {
48235
- if (context.trackedSymbols !== cachedResult.trackedSymbols) {
48236
- (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
48237
- ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
48238
- symbol,
48239
- enclosingDeclaration,
48240
- meaning
48241
- )
48242
- );
48243
- }
48391
+ (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
48392
+ ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
48393
+ symbol,
48394
+ enclosingDeclaration,
48395
+ meaning
48396
+ )
48397
+ );
48244
48398
  if (cachedResult.truncating) {
48245
48399
  context.truncating = true;
48246
48400
  }
package/lib/tsserver.js CHANGED
@@ -47039,6 +47039,13 @@ __export(ts_moduleSpecifiers_exports, {
47039
47039
  });
47040
47040
 
47041
47041
  // src/compiler/moduleSpecifiers.ts
47042
+ function safeJsonRead(packageJsonPath, readFile) {
47043
+ try {
47044
+ return JSON.parse(readFile(packageJsonPath));
47045
+ } catch {
47046
+ return {};
47047
+ }
47048
+ }
47042
47049
  function getPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
47043
47050
  const preferredEnding = getPreferredEnding();
47044
47051
  return {
@@ -47261,7 +47268,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
47261
47268
  const { sourceDirectory, getCanonicalFileName } = info;
47262
47269
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
47263
47270
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
47264
- if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
47271
+ if (!baseUrl && !paths && !getResolvePackageJsonImports(compilerOptions) || relativePreference === 0 /* Relative */) {
47265
47272
  return pathsOnly ? void 0 : relativePath;
47266
47273
  }
47267
47274
  const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
@@ -47269,11 +47276,12 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
47269
47276
  if (!relativeToBaseUrl) {
47270
47277
  return pathsOnly ? void 0 : relativePath;
47271
47278
  }
47272
- const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions);
47279
+ const fromPackageJsonImports = pathsOnly ? void 0 : tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, compilerOptions, host, importMode);
47280
+ const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
47273
47281
  if (pathsOnly) {
47274
47282
  return fromPaths;
47275
47283
  }
47276
- const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths;
47284
+ const maybeNonRelative = fromPackageJsonImports ?? (fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths);
47277
47285
  if (!maybeNonRelative) {
47278
47286
  return relativePath;
47279
47287
  }
@@ -47312,8 +47320,8 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
47312
47320
  if (host.getNearestAncestorDirectoryWithPackageJson) {
47313
47321
  return host.getNearestAncestorDirectoryWithPackageJson(fileName);
47314
47322
  }
47315
- return !!forEachAncestorDirectory(fileName, (directory) => {
47316
- return host.fileExists(combinePaths(directory, "package.json")) ? true : void 0;
47323
+ return forEachAncestorDirectory(fileName, (directory) => {
47324
+ return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
47317
47325
  });
47318
47326
  }
47319
47327
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
@@ -47484,8 +47492,40 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
47484
47492
  return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
47485
47493
  }
47486
47494
  }
47487
- function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode = 0 /* Exact */) {
47495
+ function getOutputPath(targetFilePath, options, commonSourceDirectory) {
47496
+ return changeExtension(
47497
+ options.outDir ? resolvePath(
47498
+ options.outDir,
47499
+ getRelativePathFromDirectory(
47500
+ commonSourceDirectory,
47501
+ targetFilePath,
47502
+ /*ignoreCase*/
47503
+ false
47504
+ )
47505
+ ) : targetFilePath,
47506
+ getOutputExtension(targetFilePath, options)
47507
+ );
47508
+ }
47509
+ function getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory) {
47510
+ const declarationDir = options.declarationDir || options.outDir;
47511
+ return changeExtension(
47512
+ declarationDir ? resolvePath(
47513
+ declarationDir,
47514
+ getRelativePathFromDirectory(
47515
+ commonSourceDirectory,
47516
+ targetFilePath,
47517
+ /*ignoreCase*/
47518
+ false
47519
+ )
47520
+ ) : targetFilePath,
47521
+ getDeclarationEmitExtensionForPath(targetFilePath)
47522
+ );
47523
+ }
47524
+ function tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions, mode, isImports) {
47488
47525
  if (typeof exports === "string") {
47526
+ const commonSourceDirectory = host.getCommonSourceDirectory();
47527
+ const outputFile = isImports && getOutputPath(targetFilePath, options, commonSourceDirectory);
47528
+ const declarationFile = isImports && getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory);
47489
47529
  const pathOrPattern = getNormalizedAbsolutePath(
47490
47530
  combinePaths(packageDirectory, exports),
47491
47531
  /*currentDirectory*/
@@ -47494,11 +47534,24 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
47494
47534
  const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : void 0;
47495
47535
  switch (mode) {
47496
47536
  case 0 /* Exact */:
47497
- if (comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */) {
47537
+ if (extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */ || comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || outputFile && comparePaths(outputFile, pathOrPattern) === 0 /* EqualTo */ || declarationFile && comparePaths(declarationFile, pathOrPattern) === 0 /* EqualTo */) {
47498
47538
  return { moduleFileToTry: packageName };
47499
47539
  }
47500
47540
  break;
47501
47541
  case 1 /* Directory */:
47542
+ if (extensionSwappedTarget && containsPath(pathOrPattern, extensionSwappedTarget)) {
47543
+ const fragment = getRelativePathFromDirectory(
47544
+ pathOrPattern,
47545
+ extensionSwappedTarget,
47546
+ /*ignoreCase*/
47547
+ false
47548
+ );
47549
+ return { moduleFileToTry: getNormalizedAbsolutePath(
47550
+ combinePaths(combinePaths(packageName, exports), fragment),
47551
+ /*currentDirectory*/
47552
+ void 0
47553
+ ) };
47554
+ }
47502
47555
  if (containsPath(pathOrPattern, targetFilePath)) {
47503
47556
  const fragment = getRelativePathFromDirectory(
47504
47557
  pathOrPattern,
@@ -47512,48 +47565,136 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
47512
47565
  void 0
47513
47566
  ) };
47514
47567
  }
47568
+ if (outputFile && containsPath(pathOrPattern, outputFile)) {
47569
+ const fragment = getRelativePathFromDirectory(
47570
+ pathOrPattern,
47571
+ outputFile,
47572
+ /*ignoreCase*/
47573
+ false
47574
+ );
47575
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
47576
+ }
47577
+ if (declarationFile && containsPath(pathOrPattern, declarationFile)) {
47578
+ const fragment = getRelativePathFromDirectory(
47579
+ pathOrPattern,
47580
+ declarationFile,
47581
+ /*ignoreCase*/
47582
+ false
47583
+ );
47584
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
47585
+ }
47515
47586
  break;
47516
47587
  case 2 /* Pattern */:
47517
47588
  const starPos = pathOrPattern.indexOf("*");
47518
47589
  const leadingSlice = pathOrPattern.slice(0, starPos);
47519
47590
  const trailingSlice = pathOrPattern.slice(starPos + 1);
47591
+ if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
47592
+ const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
47593
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
47594
+ }
47520
47595
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
47521
47596
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
47522
47597
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
47523
47598
  }
47524
- if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
47525
- const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
47599
+ if (outputFile && startsWith(outputFile, leadingSlice) && endsWith(outputFile, trailingSlice)) {
47600
+ const starReplacement = outputFile.slice(leadingSlice.length, outputFile.length - trailingSlice.length);
47601
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
47602
+ }
47603
+ if (declarationFile && startsWith(declarationFile, leadingSlice) && endsWith(declarationFile, trailingSlice)) {
47604
+ const starReplacement = declarationFile.slice(leadingSlice.length, declarationFile.length - trailingSlice.length);
47526
47605
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
47527
47606
  }
47528
47607
  break;
47529
47608
  }
47530
47609
  } else if (Array.isArray(exports)) {
47531
- return forEach(exports, (e) => tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions));
47610
+ return forEach(exports, (e) => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
47532
47611
  } else if (typeof exports === "object" && exports !== null) {
47533
- if (allKeysStartWithDot(exports)) {
47534
- return forEach(getOwnKeys(exports), (k) => {
47535
- const subPackageName = getNormalizedAbsolutePath(
47536
- combinePaths(packageName, k),
47537
- /*currentDirectory*/
47538
- void 0
47539
- );
47540
- const mode2 = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
47541
- return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode2);
47542
- });
47543
- } else {
47544
- for (const key of getOwnKeys(exports)) {
47545
- if (key === "default" || conditions.includes(key) || isApplicableVersionedTypesKey(conditions, key)) {
47546
- const subTarget = exports[key];
47547
- const result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode);
47548
- if (result) {
47549
- return result;
47550
- }
47612
+ for (const key of getOwnKeys(exports)) {
47613
+ if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) {
47614
+ const subTarget = exports[key];
47615
+ const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports);
47616
+ if (result) {
47617
+ return result;
47551
47618
  }
47552
47619
  }
47553
47620
  }
47554
47621
  }
47555
47622
  return void 0;
47556
47623
  }
47624
+ function tryGetModuleNameFromExports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions) {
47625
+ if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports)) {
47626
+ return forEach(getOwnKeys(exports), (k) => {
47627
+ const subPackageName = getNormalizedAbsolutePath(
47628
+ combinePaths(packageName, k),
47629
+ /*currentDirectory*/
47630
+ void 0
47631
+ );
47632
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
47633
+ return tryGetModuleNameFromExportsOrImports(
47634
+ options,
47635
+ host,
47636
+ targetFilePath,
47637
+ packageDirectory,
47638
+ subPackageName,
47639
+ exports[k],
47640
+ conditions,
47641
+ mode,
47642
+ /*isImports*/
47643
+ false
47644
+ );
47645
+ });
47646
+ }
47647
+ return tryGetModuleNameFromExportsOrImports(
47648
+ options,
47649
+ host,
47650
+ targetFilePath,
47651
+ packageDirectory,
47652
+ packageName,
47653
+ exports,
47654
+ conditions,
47655
+ 0 /* Exact */,
47656
+ /*isImports*/
47657
+ false
47658
+ );
47659
+ }
47660
+ function tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, options, host, importMode) {
47661
+ var _a, _b, _c;
47662
+ if (!host.readFile || !getResolvePackageJsonImports(options)) {
47663
+ return void 0;
47664
+ }
47665
+ const ancestorDirectoryWithPackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
47666
+ if (!ancestorDirectoryWithPackageJson) {
47667
+ return void 0;
47668
+ }
47669
+ const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
47670
+ const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
47671
+ if (typeof cachedPackageJson !== "object" && cachedPackageJson !== void 0 || !host.fileExists(packageJsonPath)) {
47672
+ return void 0;
47673
+ }
47674
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
47675
+ const imports = packageJsonContent == null ? void 0 : packageJsonContent.imports;
47676
+ if (!imports) {
47677
+ return void 0;
47678
+ }
47679
+ const conditions = getConditions(options, importMode);
47680
+ return (_c = forEach(getOwnKeys(imports), (k) => {
47681
+ if (!startsWith(k, "#") || k === "#" || startsWith(k, "#/"))
47682
+ return void 0;
47683
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
47684
+ return tryGetModuleNameFromExportsOrImports(
47685
+ options,
47686
+ host,
47687
+ moduleFileName,
47688
+ ancestorDirectoryWithPackageJson,
47689
+ k,
47690
+ imports[k],
47691
+ conditions,
47692
+ mode,
47693
+ /*isImports*/
47694
+ true
47695
+ );
47696
+ })) == null ? void 0 : _c.moduleFileToTry;
47697
+ }
47557
47698
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
47558
47699
  const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
47559
47700
  if (normalizedTargetPaths === void 0) {
@@ -47627,16 +47768,15 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
47627
47768
  let maybeBlockedByTypesVersions = false;
47628
47769
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
47629
47770
  if (typeof cachedPackageJson === "object" || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
47630
- const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
47771
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
47631
47772
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
47632
47773
  if (getResolvePackageJsonExports(options)) {
47633
47774
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
47634
47775
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
47635
47776
  const conditions = getConditions(options, importMode);
47636
- const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
47777
+ const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, host, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
47637
47778
  if (fromExports) {
47638
- const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
47639
- return { ...withJsExtension, verbatimFromExports: true };
47779
+ return { ...fromExports, verbatimFromExports: true };
47640
47780
  }
47641
47781
  if (packageJsonContent.exports) {
47642
47782
  return { moduleFileToTry: path, blockedByExports: true };
@@ -52940,15 +53080,13 @@ function createTypeChecker(host) {
52940
53080
  }
52941
53081
  const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key);
52942
53082
  if (cachedResult) {
52943
- if (context.trackedSymbols !== cachedResult.trackedSymbols) {
52944
- (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
52945
- ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
52946
- symbol,
52947
- enclosingDeclaration,
52948
- meaning
52949
- )
52950
- );
52951
- }
53083
+ (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
53084
+ ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
53085
+ symbol,
53086
+ enclosingDeclaration,
53087
+ meaning
53088
+ )
53089
+ );
52952
53090
  if (cachedResult.truncating) {
52953
53091
  context.truncating = true;
52954
53092
  }
@@ -133012,7 +133150,8 @@ function createModuleSpecifierResolutionHost(program, host) {
133012
133150
  getProjectReferenceRedirect: (fileName) => program.getProjectReferenceRedirect(fileName),
133013
133151
  isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
133014
133152
  getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
133015
- getFileIncludeReasons: () => program.getFileIncludeReasons()
133153
+ getFileIncludeReasons: () => program.getFileIncludeReasons(),
133154
+ getCommonSourceDirectory: () => program.getCommonSourceDirectory()
133016
133155
  };
133017
133156
  }
133018
133157
  function getModuleSpecifierResolverHost(program, host) {
@@ -135738,6 +135877,7 @@ var DocumentHighlights;
135738
135877
  case 127 /* YieldKeyword */:
135739
135878
  return highlightSpans(getYieldOccurrences(node));
135740
135879
  case 103 /* InKeyword */:
135880
+ case 147 /* OutKeyword */:
135741
135881
  return void 0;
135742
135882
  default:
135743
135883
  return isModifierKind(node.kind) && (isDeclaration(node.parent) || isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) : void 0;
package/lib/typescript.js CHANGED
@@ -44902,6 +44902,13 @@ ${lanes.join("\n")}
44902
44902
  });
44903
44903
 
44904
44904
  // src/compiler/moduleSpecifiers.ts
44905
+ function safeJsonRead(packageJsonPath, readFile) {
44906
+ try {
44907
+ return JSON.parse(readFile(packageJsonPath));
44908
+ } catch {
44909
+ return {};
44910
+ }
44911
+ }
44905
44912
  function getPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
44906
44913
  const preferredEnding = getPreferredEnding();
44907
44914
  return {
@@ -45124,7 +45131,7 @@ ${lanes.join("\n")}
45124
45131
  const { sourceDirectory, getCanonicalFileName } = info;
45125
45132
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
45126
45133
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
45127
- if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
45134
+ if (!baseUrl && !paths && !getResolvePackageJsonImports(compilerOptions) || relativePreference === 0 /* Relative */) {
45128
45135
  return pathsOnly ? void 0 : relativePath;
45129
45136
  }
45130
45137
  const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
@@ -45132,11 +45139,12 @@ ${lanes.join("\n")}
45132
45139
  if (!relativeToBaseUrl) {
45133
45140
  return pathsOnly ? void 0 : relativePath;
45134
45141
  }
45135
- const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions);
45142
+ const fromPackageJsonImports = pathsOnly ? void 0 : tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, compilerOptions, host, importMode);
45143
+ const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
45136
45144
  if (pathsOnly) {
45137
45145
  return fromPaths;
45138
45146
  }
45139
- const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths;
45147
+ const maybeNonRelative = fromPackageJsonImports ?? (fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths);
45140
45148
  if (!maybeNonRelative) {
45141
45149
  return relativePath;
45142
45150
  }
@@ -45175,8 +45183,8 @@ ${lanes.join("\n")}
45175
45183
  if (host.getNearestAncestorDirectoryWithPackageJson) {
45176
45184
  return host.getNearestAncestorDirectoryWithPackageJson(fileName);
45177
45185
  }
45178
- return !!forEachAncestorDirectory(fileName, (directory) => {
45179
- return host.fileExists(combinePaths(directory, "package.json")) ? true : void 0;
45186
+ return forEachAncestorDirectory(fileName, (directory) => {
45187
+ return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
45180
45188
  });
45181
45189
  }
45182
45190
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
@@ -45347,8 +45355,40 @@ ${lanes.join("\n")}
45347
45355
  return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
45348
45356
  }
45349
45357
  }
45350
- function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode = 0 /* Exact */) {
45358
+ function getOutputPath(targetFilePath, options, commonSourceDirectory) {
45359
+ return changeExtension(
45360
+ options.outDir ? resolvePath(
45361
+ options.outDir,
45362
+ getRelativePathFromDirectory(
45363
+ commonSourceDirectory,
45364
+ targetFilePath,
45365
+ /*ignoreCase*/
45366
+ false
45367
+ )
45368
+ ) : targetFilePath,
45369
+ getOutputExtension(targetFilePath, options)
45370
+ );
45371
+ }
45372
+ function getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory) {
45373
+ const declarationDir = options.declarationDir || options.outDir;
45374
+ return changeExtension(
45375
+ declarationDir ? resolvePath(
45376
+ declarationDir,
45377
+ getRelativePathFromDirectory(
45378
+ commonSourceDirectory,
45379
+ targetFilePath,
45380
+ /*ignoreCase*/
45381
+ false
45382
+ )
45383
+ ) : targetFilePath,
45384
+ getDeclarationEmitExtensionForPath(targetFilePath)
45385
+ );
45386
+ }
45387
+ function tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions, mode, isImports) {
45351
45388
  if (typeof exports === "string") {
45389
+ const commonSourceDirectory = host.getCommonSourceDirectory();
45390
+ const outputFile = isImports && getOutputPath(targetFilePath, options, commonSourceDirectory);
45391
+ const declarationFile = isImports && getOutputDeclarationPath(targetFilePath, options, commonSourceDirectory);
45352
45392
  const pathOrPattern = getNormalizedAbsolutePath(
45353
45393
  combinePaths(packageDirectory, exports),
45354
45394
  /*currentDirectory*/
@@ -45357,11 +45397,24 @@ ${lanes.join("\n")}
45357
45397
  const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : void 0;
45358
45398
  switch (mode) {
45359
45399
  case 0 /* Exact */:
45360
- if (comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */) {
45400
+ if (extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */ || comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || outputFile && comparePaths(outputFile, pathOrPattern) === 0 /* EqualTo */ || declarationFile && comparePaths(declarationFile, pathOrPattern) === 0 /* EqualTo */) {
45361
45401
  return { moduleFileToTry: packageName };
45362
45402
  }
45363
45403
  break;
45364
45404
  case 1 /* Directory */:
45405
+ if (extensionSwappedTarget && containsPath(pathOrPattern, extensionSwappedTarget)) {
45406
+ const fragment = getRelativePathFromDirectory(
45407
+ pathOrPattern,
45408
+ extensionSwappedTarget,
45409
+ /*ignoreCase*/
45410
+ false
45411
+ );
45412
+ return { moduleFileToTry: getNormalizedAbsolutePath(
45413
+ combinePaths(combinePaths(packageName, exports), fragment),
45414
+ /*currentDirectory*/
45415
+ void 0
45416
+ ) };
45417
+ }
45365
45418
  if (containsPath(pathOrPattern, targetFilePath)) {
45366
45419
  const fragment = getRelativePathFromDirectory(
45367
45420
  pathOrPattern,
@@ -45375,48 +45428,136 @@ ${lanes.join("\n")}
45375
45428
  void 0
45376
45429
  ) };
45377
45430
  }
45431
+ if (outputFile && containsPath(pathOrPattern, outputFile)) {
45432
+ const fragment = getRelativePathFromDirectory(
45433
+ pathOrPattern,
45434
+ outputFile,
45435
+ /*ignoreCase*/
45436
+ false
45437
+ );
45438
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
45439
+ }
45440
+ if (declarationFile && containsPath(pathOrPattern, declarationFile)) {
45441
+ const fragment = getRelativePathFromDirectory(
45442
+ pathOrPattern,
45443
+ declarationFile,
45444
+ /*ignoreCase*/
45445
+ false
45446
+ );
45447
+ return { moduleFileToTry: combinePaths(packageName, fragment) };
45448
+ }
45378
45449
  break;
45379
45450
  case 2 /* Pattern */:
45380
45451
  const starPos = pathOrPattern.indexOf("*");
45381
45452
  const leadingSlice = pathOrPattern.slice(0, starPos);
45382
45453
  const trailingSlice = pathOrPattern.slice(starPos + 1);
45454
+ if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
45455
+ const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
45456
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
45457
+ }
45383
45458
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
45384
45459
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
45385
45460
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
45386
45461
  }
45387
- if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
45388
- const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
45462
+ if (outputFile && startsWith(outputFile, leadingSlice) && endsWith(outputFile, trailingSlice)) {
45463
+ const starReplacement = outputFile.slice(leadingSlice.length, outputFile.length - trailingSlice.length);
45464
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
45465
+ }
45466
+ if (declarationFile && startsWith(declarationFile, leadingSlice) && endsWith(declarationFile, trailingSlice)) {
45467
+ const starReplacement = declarationFile.slice(leadingSlice.length, declarationFile.length - trailingSlice.length);
45389
45468
  return { moduleFileToTry: packageName.replace("*", starReplacement) };
45390
45469
  }
45391
45470
  break;
45392
45471
  }
45393
45472
  } else if (Array.isArray(exports)) {
45394
- return forEach(exports, (e) => tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions));
45473
+ return forEach(exports, (e) => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
45395
45474
  } else if (typeof exports === "object" && exports !== null) {
45396
- if (allKeysStartWithDot(exports)) {
45397
- return forEach(getOwnKeys(exports), (k) => {
45398
- const subPackageName = getNormalizedAbsolutePath(
45399
- combinePaths(packageName, k),
45400
- /*currentDirectory*/
45401
- void 0
45402
- );
45403
- const mode2 = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
45404
- return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode2);
45405
- });
45406
- } else {
45407
- for (const key of getOwnKeys(exports)) {
45408
- if (key === "default" || conditions.includes(key) || isApplicableVersionedTypesKey(conditions, key)) {
45409
- const subTarget = exports[key];
45410
- const result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode);
45411
- if (result) {
45412
- return result;
45413
- }
45475
+ for (const key of getOwnKeys(exports)) {
45476
+ if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) {
45477
+ const subTarget = exports[key];
45478
+ const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports);
45479
+ if (result) {
45480
+ return result;
45414
45481
  }
45415
45482
  }
45416
45483
  }
45417
45484
  }
45418
45485
  return void 0;
45419
45486
  }
45487
+ function tryGetModuleNameFromExports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions) {
45488
+ if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports)) {
45489
+ return forEach(getOwnKeys(exports), (k) => {
45490
+ const subPackageName = getNormalizedAbsolutePath(
45491
+ combinePaths(packageName, k),
45492
+ /*currentDirectory*/
45493
+ void 0
45494
+ );
45495
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
45496
+ return tryGetModuleNameFromExportsOrImports(
45497
+ options,
45498
+ host,
45499
+ targetFilePath,
45500
+ packageDirectory,
45501
+ subPackageName,
45502
+ exports[k],
45503
+ conditions,
45504
+ mode,
45505
+ /*isImports*/
45506
+ false
45507
+ );
45508
+ });
45509
+ }
45510
+ return tryGetModuleNameFromExportsOrImports(
45511
+ options,
45512
+ host,
45513
+ targetFilePath,
45514
+ packageDirectory,
45515
+ packageName,
45516
+ exports,
45517
+ conditions,
45518
+ 0 /* Exact */,
45519
+ /*isImports*/
45520
+ false
45521
+ );
45522
+ }
45523
+ function tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, options, host, importMode) {
45524
+ var _a, _b, _c;
45525
+ if (!host.readFile || !getResolvePackageJsonImports(options)) {
45526
+ return void 0;
45527
+ }
45528
+ const ancestorDirectoryWithPackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
45529
+ if (!ancestorDirectoryWithPackageJson) {
45530
+ return void 0;
45531
+ }
45532
+ const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
45533
+ const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
45534
+ if (typeof cachedPackageJson !== "object" && cachedPackageJson !== void 0 || !host.fileExists(packageJsonPath)) {
45535
+ return void 0;
45536
+ }
45537
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
45538
+ const imports = packageJsonContent == null ? void 0 : packageJsonContent.imports;
45539
+ if (!imports) {
45540
+ return void 0;
45541
+ }
45542
+ const conditions = getConditions(options, importMode);
45543
+ return (_c = forEach(getOwnKeys(imports), (k) => {
45544
+ if (!startsWith(k, "#") || k === "#" || startsWith(k, "#/"))
45545
+ return void 0;
45546
+ const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
45547
+ return tryGetModuleNameFromExportsOrImports(
45548
+ options,
45549
+ host,
45550
+ moduleFileName,
45551
+ ancestorDirectoryWithPackageJson,
45552
+ k,
45553
+ imports[k],
45554
+ conditions,
45555
+ mode,
45556
+ /*isImports*/
45557
+ true
45558
+ );
45559
+ })) == null ? void 0 : _c.moduleFileToTry;
45560
+ }
45420
45561
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
45421
45562
  const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
45422
45563
  if (normalizedTargetPaths === void 0) {
@@ -45490,16 +45631,15 @@ ${lanes.join("\n")}
45490
45631
  let maybeBlockedByTypesVersions = false;
45491
45632
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
45492
45633
  if (typeof cachedPackageJson === "object" || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
45493
- const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
45634
+ const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || safeJsonRead(packageJsonPath, host.readFile);
45494
45635
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
45495
45636
  if (getResolvePackageJsonExports(options)) {
45496
45637
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
45497
45638
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
45498
45639
  const conditions = getConditions(options, importMode);
45499
- const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
45640
+ const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, host, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
45500
45641
  if (fromExports) {
45501
- const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
45502
- return { ...withJsExtension, verbatimFromExports: true };
45642
+ return { ...fromExports, verbatimFromExports: true };
45503
45643
  }
45504
45644
  if (packageJsonContent.exports) {
45505
45645
  return { moduleFileToTry: path, blockedByExports: true };
@@ -50705,15 +50845,13 @@ ${lanes.join("\n")}
50705
50845
  }
50706
50846
  const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key);
50707
50847
  if (cachedResult) {
50708
- if (context.trackedSymbols !== cachedResult.trackedSymbols) {
50709
- (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
50710
- ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
50711
- symbol,
50712
- enclosingDeclaration,
50713
- meaning
50714
- )
50715
- );
50716
- }
50848
+ (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach(
50849
+ ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
50850
+ symbol,
50851
+ enclosingDeclaration,
50852
+ meaning
50853
+ )
50854
+ );
50717
50855
  if (cachedResult.truncating) {
50718
50856
  context.truncating = true;
50719
50857
  }
@@ -131282,7 +131420,8 @@ ${lanes.join("\n")}
131282
131420
  getProjectReferenceRedirect: (fileName) => program.getProjectReferenceRedirect(fileName),
131283
131421
  isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
131284
131422
  getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
131285
- getFileIncludeReasons: () => program.getFileIncludeReasons()
131423
+ getFileIncludeReasons: () => program.getFileIncludeReasons(),
131424
+ getCommonSourceDirectory: () => program.getCommonSourceDirectory()
131286
131425
  };
131287
131426
  }
131288
131427
  function getModuleSpecifierResolverHost(program, host) {
@@ -134069,6 +134208,7 @@ ${lanes.join("\n")}
134069
134208
  case 127 /* YieldKeyword */:
134070
134209
  return highlightSpans(getYieldOccurrences(node));
134071
134210
  case 103 /* InKeyword */:
134211
+ case 147 /* OutKeyword */:
134072
134212
  return void 0;
134073
134213
  default:
134074
134214
  return isModifierKind(node.kind) && (isDeclaration(node.parent) || isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) : void 0;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.4.0-pr-56404-7",
5
+ "version": "5.4.0-pr-55015-10",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -115,5 +115,5 @@
115
115
  "node": "20.1.0",
116
116
  "npm": "8.19.4"
117
117
  },
118
- "gitHead": "6ab635994fd78fd55a82a7c5078db32c34525259"
118
+ "gitHead": "d6f199d69cfaf8f69510f81d95c5358f1f16e9a7"
119
119
  }