typescript 5.4.0-dev.20231221 → 5.4.0-dev.20231223
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 +173 -52
- package/lib/tsserver.js +187 -60
- package/lib/typescript.js +183 -60
- package/lib/typingsInstaller.js +5 -5
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -938,8 +938,10 @@ __export(server_exports, {
|
|
|
938
938
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
939
939
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
940
940
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
941
|
+
getOutputDeclarationFileNameWorker: () => getOutputDeclarationFileNameWorker,
|
|
941
942
|
getOutputExtension: () => getOutputExtension,
|
|
942
943
|
getOutputFileNames: () => getOutputFileNames,
|
|
944
|
+
getOutputJSFileNameWorker: () => getOutputJSFileNameWorker,
|
|
943
945
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
944
946
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
945
947
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -1570,6 +1572,7 @@ __export(server_exports, {
|
|
|
1570
1572
|
isMethodSignature: () => isMethodSignature,
|
|
1571
1573
|
isMinusToken: () => isMinusToken,
|
|
1572
1574
|
isMissingDeclaration: () => isMissingDeclaration,
|
|
1575
|
+
isMissingPackageJsonInfo: () => isMissingPackageJsonInfo,
|
|
1573
1576
|
isModifier: () => isModifier,
|
|
1574
1577
|
isModifierKind: () => isModifierKind,
|
|
1575
1578
|
isModifierLike: () => isModifierLike,
|
|
@@ -2271,6 +2274,7 @@ __export(server_exports, {
|
|
|
2271
2274
|
tryGetSourceMappingURL: () => tryGetSourceMappingURL,
|
|
2272
2275
|
tryGetTextOfPropertyName: () => tryGetTextOfPropertyName,
|
|
2273
2276
|
tryIOAndConsumeErrors: () => tryIOAndConsumeErrors,
|
|
2277
|
+
tryParseJson: () => tryParseJson,
|
|
2274
2278
|
tryParsePattern: () => tryParsePattern,
|
|
2275
2279
|
tryParsePatterns: () => tryParsePatterns,
|
|
2276
2280
|
tryParseRawSourceMap: () => tryParseRawSourceMap,
|
|
@@ -2335,7 +2339,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2335
2339
|
|
|
2336
2340
|
// src/compiler/corePublic.ts
|
|
2337
2341
|
var versionMajorMinor = "5.4";
|
|
2338
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2342
|
+
var version = `${versionMajorMinor}.0-dev.20231223`;
|
|
2339
2343
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2340
2344
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2341
2345
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -3733,9 +3737,9 @@ function levenshteinWithMax(s1, s2, max) {
|
|
|
3733
3737
|
const res = previous[s2.length];
|
|
3734
3738
|
return res > max ? void 0 : res;
|
|
3735
3739
|
}
|
|
3736
|
-
function endsWith(str, suffix) {
|
|
3740
|
+
function endsWith(str, suffix, ignoreCase) {
|
|
3737
3741
|
const expectedPos = str.length - suffix.length;
|
|
3738
|
-
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
|
3742
|
+
return expectedPos >= 0 && (ignoreCase ? equateStringsCaseInsensitive(str.slice(expectedPos), suffix) : str.indexOf(suffix, expectedPos) === expectedPos);
|
|
3739
3743
|
}
|
|
3740
3744
|
function removeSuffix(str, suffix) {
|
|
3741
3745
|
return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
|
|
@@ -3828,8 +3832,8 @@ function findBestPatternMatch(values, getPattern, candidate) {
|
|
|
3828
3832
|
}
|
|
3829
3833
|
return matchedValue;
|
|
3830
3834
|
}
|
|
3831
|
-
function startsWith(str, prefix) {
|
|
3832
|
-
return str.lastIndexOf(prefix, 0) === 0;
|
|
3835
|
+
function startsWith(str, prefix, ignoreCase) {
|
|
3836
|
+
return ignoreCase ? equateStringsCaseInsensitive(str.slice(0, prefix.length), prefix) : str.lastIndexOf(prefix, 0) === 0;
|
|
3833
3837
|
}
|
|
3834
3838
|
function removePrefix(str, prefix) {
|
|
3835
3839
|
return startsWith(str, prefix) ? str.substr(prefix.length) : str;
|
|
@@ -19804,6 +19808,13 @@ function readJsonOrUndefined(path, hostOrText) {
|
|
|
19804
19808
|
function readJson(path, host) {
|
|
19805
19809
|
return readJsonOrUndefined(path, host) || {};
|
|
19806
19810
|
}
|
|
19811
|
+
function tryParseJson(text) {
|
|
19812
|
+
try {
|
|
19813
|
+
return JSON.parse(text);
|
|
19814
|
+
} catch {
|
|
19815
|
+
return void 0;
|
|
19816
|
+
}
|
|
19817
|
+
}
|
|
19807
19818
|
function directoryProbablyExists(directoryName, host) {
|
|
19808
19819
|
return !host.directoryExists || host.directoryExists(directoryName);
|
|
19809
19820
|
}
|
|
@@ -42121,6 +42132,9 @@ function getAutomaticTypeDirectiveNames(options, host) {
|
|
|
42121
42132
|
function isPackageJsonInfo(entry) {
|
|
42122
42133
|
return !!(entry == null ? void 0 : entry.contents);
|
|
42123
42134
|
}
|
|
42135
|
+
function isMissingPackageJsonInfo(entry) {
|
|
42136
|
+
return !!entry && !entry.contents;
|
|
42137
|
+
}
|
|
42124
42138
|
function compilerOptionValueToString(value) {
|
|
42125
42139
|
var _a;
|
|
42126
42140
|
if (value === null || typeof value !== "object") {
|
|
@@ -47464,7 +47478,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47464
47478
|
const { sourceDirectory, canonicalSourceDirectory, getCanonicalFileName } = info;
|
|
47465
47479
|
const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
|
|
47466
47480
|
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
|
|
47467
|
-
if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
|
|
47481
|
+
if (!baseUrl && !paths && !getResolvePackageJsonImports(compilerOptions) || relativePreference === 0 /* Relative */) {
|
|
47468
47482
|
return pathsOnly ? void 0 : relativePath;
|
|
47469
47483
|
}
|
|
47470
47484
|
const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
|
|
@@ -47472,11 +47486,12 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47472
47486
|
if (!relativeToBaseUrl) {
|
|
47473
47487
|
return pathsOnly ? void 0 : relativePath;
|
|
47474
47488
|
}
|
|
47475
|
-
const
|
|
47489
|
+
const fromPackageJsonImports = pathsOnly ? void 0 : tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, compilerOptions, host, importMode);
|
|
47490
|
+
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
|
|
47476
47491
|
if (pathsOnly) {
|
|
47477
47492
|
return fromPaths;
|
|
47478
47493
|
}
|
|
47479
|
-
const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths;
|
|
47494
|
+
const maybeNonRelative = fromPackageJsonImports ?? (fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths);
|
|
47480
47495
|
if (!maybeNonRelative) {
|
|
47481
47496
|
return relativePath;
|
|
47482
47497
|
}
|
|
@@ -47515,8 +47530,8 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
|
|
|
47515
47530
|
if (host.getNearestAncestorDirectoryWithPackageJson) {
|
|
47516
47531
|
return host.getNearestAncestorDirectoryWithPackageJson(fileName);
|
|
47517
47532
|
}
|
|
47518
|
-
return
|
|
47519
|
-
return host.fileExists(combinePaths(directory, "package.json")) ?
|
|
47533
|
+
return forEachAncestorDirectory(fileName, (directory) => {
|
|
47534
|
+
return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
|
|
47520
47535
|
});
|
|
47521
47536
|
}
|
|
47522
47537
|
function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
|
|
@@ -47690,8 +47705,12 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
|
|
|
47690
47705
|
return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
|
|
47691
47706
|
}
|
|
47692
47707
|
}
|
|
47693
|
-
function
|
|
47708
|
+
function tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports2, conditions, mode, isImports) {
|
|
47694
47709
|
if (typeof exports2 === "string") {
|
|
47710
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
|
|
47711
|
+
const getCommonSourceDirectory2 = () => host.getCommonSourceDirectory();
|
|
47712
|
+
const outputFile = isImports && getOutputJSFileNameWorker(targetFilePath, options, ignoreCase, getCommonSourceDirectory2);
|
|
47713
|
+
const declarationFile = isImports && getOutputDeclarationFileNameWorker(targetFilePath, options, ignoreCase, getCommonSourceDirectory2);
|
|
47695
47714
|
const pathOrPattern = getNormalizedAbsolutePath(
|
|
47696
47715
|
combinePaths(packageDirectory, exports2),
|
|
47697
47716
|
/*currentDirectory*/
|
|
@@ -47700,12 +47719,25 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
|
|
|
47700
47719
|
const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : void 0;
|
|
47701
47720
|
switch (mode) {
|
|
47702
47721
|
case 0 /* Exact */:
|
|
47703
|
-
if (comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ ||
|
|
47722
|
+
if (extensionSwappedTarget && comparePaths(extensionSwappedTarget, pathOrPattern, ignoreCase) === 0 /* EqualTo */ || comparePaths(targetFilePath, pathOrPattern, ignoreCase) === 0 /* EqualTo */ || outputFile && comparePaths(outputFile, pathOrPattern, ignoreCase) === 0 /* EqualTo */ || declarationFile && comparePaths(declarationFile, pathOrPattern, ignoreCase) === 0 /* EqualTo */) {
|
|
47704
47723
|
return { moduleFileToTry: packageName };
|
|
47705
47724
|
}
|
|
47706
47725
|
break;
|
|
47707
47726
|
case 1 /* Directory */:
|
|
47708
|
-
if (containsPath(pathOrPattern,
|
|
47727
|
+
if (extensionSwappedTarget && containsPath(pathOrPattern, extensionSwappedTarget, ignoreCase)) {
|
|
47728
|
+
const fragment = getRelativePathFromDirectory(
|
|
47729
|
+
pathOrPattern,
|
|
47730
|
+
extensionSwappedTarget,
|
|
47731
|
+
/*ignoreCase*/
|
|
47732
|
+
false
|
|
47733
|
+
);
|
|
47734
|
+
return { moduleFileToTry: getNormalizedAbsolutePath(
|
|
47735
|
+
combinePaths(combinePaths(packageName, exports2), fragment),
|
|
47736
|
+
/*currentDirectory*/
|
|
47737
|
+
void 0
|
|
47738
|
+
) };
|
|
47739
|
+
}
|
|
47740
|
+
if (containsPath(pathOrPattern, targetFilePath, ignoreCase)) {
|
|
47709
47741
|
const fragment = getRelativePathFromDirectory(
|
|
47710
47742
|
pathOrPattern,
|
|
47711
47743
|
targetFilePath,
|
|
@@ -47718,48 +47750,136 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
|
|
|
47718
47750
|
void 0
|
|
47719
47751
|
) };
|
|
47720
47752
|
}
|
|
47753
|
+
if (outputFile && containsPath(pathOrPattern, outputFile, ignoreCase)) {
|
|
47754
|
+
const fragment = getRelativePathFromDirectory(
|
|
47755
|
+
pathOrPattern,
|
|
47756
|
+
outputFile,
|
|
47757
|
+
/*ignoreCase*/
|
|
47758
|
+
false
|
|
47759
|
+
);
|
|
47760
|
+
return { moduleFileToTry: combinePaths(packageName, fragment) };
|
|
47761
|
+
}
|
|
47762
|
+
if (declarationFile && containsPath(pathOrPattern, declarationFile, ignoreCase)) {
|
|
47763
|
+
const fragment = getRelativePathFromDirectory(
|
|
47764
|
+
pathOrPattern,
|
|
47765
|
+
declarationFile,
|
|
47766
|
+
/*ignoreCase*/
|
|
47767
|
+
false
|
|
47768
|
+
);
|
|
47769
|
+
return { moduleFileToTry: combinePaths(packageName, fragment) };
|
|
47770
|
+
}
|
|
47721
47771
|
break;
|
|
47722
47772
|
case 2 /* Pattern */:
|
|
47723
47773
|
const starPos = pathOrPattern.indexOf("*");
|
|
47724
47774
|
const leadingSlice = pathOrPattern.slice(0, starPos);
|
|
47725
47775
|
const trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
47726
|
-
if (startsWith(
|
|
47776
|
+
if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice, ignoreCase) && endsWith(extensionSwappedTarget, trailingSlice, ignoreCase)) {
|
|
47777
|
+
const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
47778
|
+
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47779
|
+
}
|
|
47780
|
+
if (startsWith(targetFilePath, leadingSlice, ignoreCase) && endsWith(targetFilePath, trailingSlice, ignoreCase)) {
|
|
47727
47781
|
const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
47728
47782
|
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47729
47783
|
}
|
|
47730
|
-
if (
|
|
47731
|
-
const starReplacement =
|
|
47784
|
+
if (outputFile && startsWith(outputFile, leadingSlice, ignoreCase) && endsWith(outputFile, trailingSlice, ignoreCase)) {
|
|
47785
|
+
const starReplacement = outputFile.slice(leadingSlice.length, outputFile.length - trailingSlice.length);
|
|
47786
|
+
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47787
|
+
}
|
|
47788
|
+
if (declarationFile && startsWith(declarationFile, leadingSlice, ignoreCase) && endsWith(declarationFile, trailingSlice, ignoreCase)) {
|
|
47789
|
+
const starReplacement = declarationFile.slice(leadingSlice.length, declarationFile.length - trailingSlice.length);
|
|
47732
47790
|
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47733
47791
|
}
|
|
47734
47792
|
break;
|
|
47735
47793
|
}
|
|
47736
47794
|
} else if (Array.isArray(exports2)) {
|
|
47737
|
-
return forEach(exports2, (e) =>
|
|
47795
|
+
return forEach(exports2, (e) => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
|
|
47738
47796
|
} else if (typeof exports2 === "object" && exports2 !== null) {
|
|
47739
|
-
|
|
47740
|
-
|
|
47741
|
-
const
|
|
47742
|
-
|
|
47743
|
-
|
|
47744
|
-
|
|
47745
|
-
);
|
|
47746
|
-
const mode2 = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
|
|
47747
|
-
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports2[k], conditions, mode2);
|
|
47748
|
-
});
|
|
47749
|
-
} else {
|
|
47750
|
-
for (const key of getOwnKeys(exports2)) {
|
|
47751
|
-
if (key === "default" || conditions.includes(key) || isApplicableVersionedTypesKey(conditions, key)) {
|
|
47752
|
-
const subTarget = exports2[key];
|
|
47753
|
-
const result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode);
|
|
47754
|
-
if (result) {
|
|
47755
|
-
return result;
|
|
47756
|
-
}
|
|
47797
|
+
for (const key of getOwnKeys(exports2)) {
|
|
47798
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) {
|
|
47799
|
+
const subTarget = exports2[key];
|
|
47800
|
+
const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports);
|
|
47801
|
+
if (result) {
|
|
47802
|
+
return result;
|
|
47757
47803
|
}
|
|
47758
47804
|
}
|
|
47759
47805
|
}
|
|
47760
47806
|
}
|
|
47761
47807
|
return void 0;
|
|
47762
47808
|
}
|
|
47809
|
+
function tryGetModuleNameFromExports(options, host, targetFilePath, packageDirectory, packageName, exports2, conditions) {
|
|
47810
|
+
if (typeof exports2 === "object" && exports2 !== null && !Array.isArray(exports2) && allKeysStartWithDot(exports2)) {
|
|
47811
|
+
return forEach(getOwnKeys(exports2), (k) => {
|
|
47812
|
+
const subPackageName = getNormalizedAbsolutePath(
|
|
47813
|
+
combinePaths(packageName, k),
|
|
47814
|
+
/*currentDirectory*/
|
|
47815
|
+
void 0
|
|
47816
|
+
);
|
|
47817
|
+
const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
|
|
47818
|
+
return tryGetModuleNameFromExportsOrImports(
|
|
47819
|
+
options,
|
|
47820
|
+
host,
|
|
47821
|
+
targetFilePath,
|
|
47822
|
+
packageDirectory,
|
|
47823
|
+
subPackageName,
|
|
47824
|
+
exports2[k],
|
|
47825
|
+
conditions,
|
|
47826
|
+
mode,
|
|
47827
|
+
/*isImports*/
|
|
47828
|
+
false
|
|
47829
|
+
);
|
|
47830
|
+
});
|
|
47831
|
+
}
|
|
47832
|
+
return tryGetModuleNameFromExportsOrImports(
|
|
47833
|
+
options,
|
|
47834
|
+
host,
|
|
47835
|
+
targetFilePath,
|
|
47836
|
+
packageDirectory,
|
|
47837
|
+
packageName,
|
|
47838
|
+
exports2,
|
|
47839
|
+
conditions,
|
|
47840
|
+
0 /* Exact */,
|
|
47841
|
+
/*isImports*/
|
|
47842
|
+
false
|
|
47843
|
+
);
|
|
47844
|
+
}
|
|
47845
|
+
function tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, options, host, importMode) {
|
|
47846
|
+
var _a, _b, _c;
|
|
47847
|
+
if (!host.readFile || !getResolvePackageJsonImports(options)) {
|
|
47848
|
+
return void 0;
|
|
47849
|
+
}
|
|
47850
|
+
const ancestorDirectoryWithPackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
|
|
47851
|
+
if (!ancestorDirectoryWithPackageJson) {
|
|
47852
|
+
return void 0;
|
|
47853
|
+
}
|
|
47854
|
+
const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
|
|
47855
|
+
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
47856
|
+
if (isMissingPackageJsonInfo(cachedPackageJson) || !host.fileExists(packageJsonPath)) {
|
|
47857
|
+
return void 0;
|
|
47858
|
+
}
|
|
47859
|
+
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
47860
|
+
const imports = packageJsonContent == null ? void 0 : packageJsonContent.imports;
|
|
47861
|
+
if (!imports) {
|
|
47862
|
+
return void 0;
|
|
47863
|
+
}
|
|
47864
|
+
const conditions = getConditions(options, importMode);
|
|
47865
|
+
return (_c = forEach(getOwnKeys(imports), (k) => {
|
|
47866
|
+
if (!startsWith(k, "#") || k === "#" || startsWith(k, "#/"))
|
|
47867
|
+
return void 0;
|
|
47868
|
+
const mode = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
|
|
47869
|
+
return tryGetModuleNameFromExportsOrImports(
|
|
47870
|
+
options,
|
|
47871
|
+
host,
|
|
47872
|
+
moduleFileName,
|
|
47873
|
+
ancestorDirectoryWithPackageJson,
|
|
47874
|
+
k,
|
|
47875
|
+
imports[k],
|
|
47876
|
+
conditions,
|
|
47877
|
+
mode,
|
|
47878
|
+
/*isImports*/
|
|
47879
|
+
true
|
|
47880
|
+
);
|
|
47881
|
+
})) == null ? void 0 : _c.moduleFileToTry;
|
|
47882
|
+
}
|
|
47763
47883
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
|
|
47764
47884
|
const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
47765
47885
|
if (normalizedTargetPaths === void 0) {
|
|
@@ -47833,22 +47953,21 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
47833
47953
|
let maybeBlockedByTypesVersions = false;
|
|
47834
47954
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
47835
47955
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
|
47836
|
-
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) ||
|
|
47956
|
+
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
47837
47957
|
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
47838
47958
|
if (getResolvePackageJsonExports(options)) {
|
|
47839
47959
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
|
47840
47960
|
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
|
47841
47961
|
const conditions = getConditions(options, importMode);
|
|
47842
|
-
const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
|
|
47962
|
+
const fromExports = (packageJsonContent == null ? void 0 : packageJsonContent.exports) ? tryGetModuleNameFromExports(options, host, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
|
|
47843
47963
|
if (fromExports) {
|
|
47844
|
-
|
|
47845
|
-
return { ...withJsExtension, verbatimFromExports: true };
|
|
47964
|
+
return { ...fromExports, verbatimFromExports: true };
|
|
47846
47965
|
}
|
|
47847
|
-
if (packageJsonContent.exports) {
|
|
47966
|
+
if (packageJsonContent == null ? void 0 : packageJsonContent.exports) {
|
|
47848
47967
|
return { moduleFileToTry: path, blockedByExports: true };
|
|
47849
47968
|
}
|
|
47850
47969
|
}
|
|
47851
|
-
const versionPaths = packageJsonContent.typesVersions ? getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : void 0;
|
|
47970
|
+
const versionPaths = (packageJsonContent == null ? void 0 : packageJsonContent.typesVersions) ? getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : void 0;
|
|
47852
47971
|
if (versionPaths) {
|
|
47853
47972
|
const subModuleName = path.slice(packageRootPath.length + 1);
|
|
47854
47973
|
const fromPaths = tryGetModuleNameFromPaths(
|
|
@@ -47864,13 +47983,13 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
47864
47983
|
moduleFileToTry = combinePaths(packageRootPath, fromPaths);
|
|
47865
47984
|
}
|
|
47866
47985
|
}
|
|
47867
|
-
const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
47986
|
+
const mainFileRelative = (packageJsonContent == null ? void 0 : packageJsonContent.typings) || (packageJsonContent == null ? void 0 : packageJsonContent.types) || (packageJsonContent == null ? void 0 : packageJsonContent.main) || "index.js";
|
|
47868
47987
|
if (isString(mainFileRelative) && !(maybeBlockedByTypesVersions && matchPatternOrExact(tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
47869
47988
|
const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
47870
47989
|
const canonicalModuleFileToTry = getCanonicalFileName(moduleFileToTry);
|
|
47871
47990
|
if (removeFileExtension(mainExportFile) === removeFileExtension(canonicalModuleFileToTry)) {
|
|
47872
47991
|
return { packageRootPath, moduleFileToTry };
|
|
47873
|
-
} else if (packageJsonContent.type !== "module" && !fileExtensionIsOneOf(canonicalModuleFileToTry, extensionsNotSupportingExtensionlessResolution) && startsWith(canonicalModuleFileToTry, mainExportFile) && getDirectoryPath(canonicalModuleFileToTry) === removeTrailingDirectorySeparator(mainExportFile) && removeFileExtension(getBaseFileName(canonicalModuleFileToTry)) === "index") {
|
|
47992
|
+
} else if ((packageJsonContent == null ? void 0 : packageJsonContent.type) !== "module" && !fileExtensionIsOneOf(canonicalModuleFileToTry, extensionsNotSupportingExtensionlessResolution) && startsWith(canonicalModuleFileToTry, mainExportFile) && getDirectoryPath(canonicalModuleFileToTry) === removeTrailingDirectorySeparator(mainExportFile) && removeFileExtension(getBaseFileName(canonicalModuleFileToTry)) === "index") {
|
|
47874
47993
|
return { packageRootPath, moduleFileToTry };
|
|
47875
47994
|
}
|
|
47876
47995
|
}
|
|
@@ -115333,28 +115452,34 @@ function getSourceMapFilePath(jsFilePath, options) {
|
|
|
115333
115452
|
function getOutputExtension(fileName, options) {
|
|
115334
115453
|
return fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : options.jsx === 1 /* Preserve */ && fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : ".js" /* Js */;
|
|
115335
115454
|
}
|
|
115336
|
-
function getOutputPathWithoutChangingExt(inputFileName,
|
|
115455
|
+
function getOutputPathWithoutChangingExt(inputFileName, ignoreCase, outputDir, getCommonSourceDirectory2) {
|
|
115337
115456
|
return outputDir ? resolvePath(
|
|
115338
115457
|
outputDir,
|
|
115339
|
-
getRelativePathFromDirectory(getCommonSourceDirectory2
|
|
115458
|
+
getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)
|
|
115340
115459
|
) : inputFileName;
|
|
115341
115460
|
}
|
|
115342
|
-
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
|
|
115461
|
+
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2 = () => getCommonSourceDirectoryOfConfig(configFile, ignoreCase)) {
|
|
115462
|
+
return getOutputDeclarationFileNameWorker(inputFileName, configFile.options, ignoreCase, getCommonSourceDirectory2);
|
|
115463
|
+
}
|
|
115464
|
+
function getOutputDeclarationFileNameWorker(inputFileName, options, ignoreCase, getCommonSourceDirectory2) {
|
|
115343
115465
|
return changeExtension(
|
|
115344
|
-
getOutputPathWithoutChangingExt(inputFileName,
|
|
115466
|
+
getOutputPathWithoutChangingExt(inputFileName, ignoreCase, options.declarationDir || options.outDir, getCommonSourceDirectory2),
|
|
115345
115467
|
getDeclarationEmitExtensionForPath(inputFileName)
|
|
115346
115468
|
);
|
|
115347
115469
|
}
|
|
115348
|
-
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
|
|
115470
|
+
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2 = () => getCommonSourceDirectoryOfConfig(configFile, ignoreCase)) {
|
|
115349
115471
|
if (configFile.options.emitDeclarationOnly)
|
|
115350
115472
|
return void 0;
|
|
115351
115473
|
const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
115352
|
-
const outputFileName =
|
|
115353
|
-
getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory2),
|
|
115354
|
-
getOutputExtension(inputFileName, configFile.options)
|
|
115355
|
-
);
|
|
115474
|
+
const outputFileName = getOutputJSFileNameWorker(inputFileName, configFile.options, ignoreCase, getCommonSourceDirectory2);
|
|
115356
115475
|
return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
115357
115476
|
}
|
|
115477
|
+
function getOutputJSFileNameWorker(inputFileName, options, ignoreCase, getCommonSourceDirectory2) {
|
|
115478
|
+
return changeExtension(
|
|
115479
|
+
getOutputPathWithoutChangingExt(inputFileName, ignoreCase, options.outDir, getCommonSourceDirectory2),
|
|
115480
|
+
getOutputExtension(inputFileName, options)
|
|
115481
|
+
);
|
|
115482
|
+
}
|
|
115358
115483
|
function createAddOutput() {
|
|
115359
115484
|
let outputs;
|
|
115360
115485
|
return { addOutput, getOutputs };
|
|
@@ -133698,7 +133823,8 @@ function createModuleSpecifierResolutionHost(program, host) {
|
|
|
133698
133823
|
getProjectReferenceRedirect: (fileName) => program.getProjectReferenceRedirect(fileName),
|
|
133699
133824
|
isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
|
|
133700
133825
|
getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
|
|
133701
|
-
getFileIncludeReasons: () => program.getFileIncludeReasons()
|
|
133826
|
+
getFileIncludeReasons: () => program.getFileIncludeReasons(),
|
|
133827
|
+
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
133702
133828
|
};
|
|
133703
133829
|
}
|
|
133704
133830
|
function getModuleSpecifierResolverHost(program, host) {
|
|
@@ -134759,13 +134885,6 @@ function createPackageJsonImportFilter(fromFile, preferences, host) {
|
|
|
134759
134885
|
return components[0];
|
|
134760
134886
|
}
|
|
134761
134887
|
}
|
|
134762
|
-
function tryParseJson(text) {
|
|
134763
|
-
try {
|
|
134764
|
-
return JSON.parse(text);
|
|
134765
|
-
} catch {
|
|
134766
|
-
return void 0;
|
|
134767
|
-
}
|
|
134768
|
-
}
|
|
134769
134888
|
function consumesNodeCoreModules(sourceFile) {
|
|
134770
134889
|
return some(sourceFile.imports, ({ text }) => ts_JsTyping_exports.nodeCoreModules.has(text));
|
|
134771
134890
|
}
|
|
@@ -174489,8 +174608,10 @@ __export(ts_exports2, {
|
|
|
174489
174608
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
174490
174609
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
174491
174610
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
174611
|
+
getOutputDeclarationFileNameWorker: () => getOutputDeclarationFileNameWorker,
|
|
174492
174612
|
getOutputExtension: () => getOutputExtension,
|
|
174493
174613
|
getOutputFileNames: () => getOutputFileNames,
|
|
174614
|
+
getOutputJSFileNameWorker: () => getOutputJSFileNameWorker,
|
|
174494
174615
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
174495
174616
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
174496
174617
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -175121,6 +175242,7 @@ __export(ts_exports2, {
|
|
|
175121
175242
|
isMethodSignature: () => isMethodSignature,
|
|
175122
175243
|
isMinusToken: () => isMinusToken,
|
|
175123
175244
|
isMissingDeclaration: () => isMissingDeclaration,
|
|
175245
|
+
isMissingPackageJsonInfo: () => isMissingPackageJsonInfo,
|
|
175124
175246
|
isModifier: () => isModifier,
|
|
175125
175247
|
isModifierKind: () => isModifierKind,
|
|
175126
175248
|
isModifierLike: () => isModifierLike,
|
|
@@ -175822,6 +175944,7 @@ __export(ts_exports2, {
|
|
|
175822
175944
|
tryGetSourceMappingURL: () => tryGetSourceMappingURL,
|
|
175823
175945
|
tryGetTextOfPropertyName: () => tryGetTextOfPropertyName,
|
|
175824
175946
|
tryIOAndConsumeErrors: () => tryIOAndConsumeErrors,
|
|
175947
|
+
tryParseJson: () => tryParseJson,
|
|
175825
175948
|
tryParsePattern: () => tryParsePattern,
|
|
175826
175949
|
tryParsePatterns: () => tryParsePatterns,
|
|
175827
175950
|
tryParseRawSourceMap: () => tryParseRawSourceMap,
|
|
@@ -189284,8 +189407,10 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189284
189407
|
getOriginalNodeId,
|
|
189285
189408
|
getOriginalSourceFile,
|
|
189286
189409
|
getOutputDeclarationFileName,
|
|
189410
|
+
getOutputDeclarationFileNameWorker,
|
|
189287
189411
|
getOutputExtension,
|
|
189288
189412
|
getOutputFileNames,
|
|
189413
|
+
getOutputJSFileNameWorker,
|
|
189289
189414
|
getOutputPathsFor,
|
|
189290
189415
|
getOutputPathsForBundle,
|
|
189291
189416
|
getOwnEmitOutputFilePath,
|
|
@@ -189916,6 +190041,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189916
190041
|
isMethodSignature,
|
|
189917
190042
|
isMinusToken,
|
|
189918
190043
|
isMissingDeclaration,
|
|
190044
|
+
isMissingPackageJsonInfo,
|
|
189919
190045
|
isModifier,
|
|
189920
190046
|
isModifierKind,
|
|
189921
190047
|
isModifierLike,
|
|
@@ -190617,6 +190743,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
190617
190743
|
tryGetSourceMappingURL,
|
|
190618
190744
|
tryGetTextOfPropertyName,
|
|
190619
190745
|
tryIOAndConsumeErrors,
|
|
190746
|
+
tryParseJson,
|
|
190620
190747
|
tryParsePattern,
|
|
190621
190748
|
tryParsePatterns,
|
|
190622
190749
|
tryParseRawSourceMap,
|