typescript 5.4.0-dev.20231220 → 5.4.0-dev.20231222
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 +209 -56
- package/lib/tsserver.js +223 -64
- package/lib/typescript.js +219 -64
- package/lib/typingsInstaller.js +8 -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.20231222`;
|
|
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;
|
|
@@ -6239,6 +6243,7 @@ var JsxFlags = /* @__PURE__ */ ((JsxFlags2) => {
|
|
|
6239
6243
|
return JsxFlags2;
|
|
6240
6244
|
})(JsxFlags || {});
|
|
6241
6245
|
var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => {
|
|
6246
|
+
RelationComparisonResult3[RelationComparisonResult3["None"] = 0] = "None";
|
|
6242
6247
|
RelationComparisonResult3[RelationComparisonResult3["Succeeded"] = 1] = "Succeeded";
|
|
6243
6248
|
RelationComparisonResult3[RelationComparisonResult3["Failed"] = 2] = "Failed";
|
|
6244
6249
|
RelationComparisonResult3[RelationComparisonResult3["Reported"] = 4] = "Reported";
|
|
@@ -10338,6 +10343,8 @@ var Diagnostics = {
|
|
|
10338
10343
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, 1 /* Error */, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
10339
10344
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, 1 /* Error */, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
10340
10345
|
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, 1 /* Error */, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
10346
|
+
Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given: diag(4125, 1 /* Error */, "Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given_4125", "Each declaration of '{0}.{1}' differs in its value, where '{2}' was expected but '{3}' was given."),
|
|
10347
|
+
One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value: diag(4126, 1 /* Error */, "One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value_4126", "One value of '{0}.{1}' is the string '{2}', and the other is assumed to be an unknown numeric value."),
|
|
10341
10348
|
The_current_host_does_not_support_the_0_option: diag(5001, 1 /* Error */, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
10342
10349
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, 1 /* Error */, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
10343
10350
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, 1 /* Error */, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -19801,6 +19808,13 @@ function readJsonOrUndefined(path, hostOrText) {
|
|
|
19801
19808
|
function readJson(path, host) {
|
|
19802
19809
|
return readJsonOrUndefined(path, host) || {};
|
|
19803
19810
|
}
|
|
19811
|
+
function tryParseJson(text) {
|
|
19812
|
+
try {
|
|
19813
|
+
return JSON.parse(text);
|
|
19814
|
+
} catch {
|
|
19815
|
+
return void 0;
|
|
19816
|
+
}
|
|
19817
|
+
}
|
|
19804
19818
|
function directoryProbablyExists(directoryName, host) {
|
|
19805
19819
|
return !host.directoryExists || host.directoryExists(directoryName);
|
|
19806
19820
|
}
|
|
@@ -42118,6 +42132,9 @@ function getAutomaticTypeDirectiveNames(options, host) {
|
|
|
42118
42132
|
function isPackageJsonInfo(entry) {
|
|
42119
42133
|
return !!(entry == null ? void 0 : entry.contents);
|
|
42120
42134
|
}
|
|
42135
|
+
function isMissingPackageJsonInfo(entry) {
|
|
42136
|
+
return !!entry && !entry.contents;
|
|
42137
|
+
}
|
|
42121
42138
|
function compilerOptionValueToString(value) {
|
|
42122
42139
|
var _a;
|
|
42123
42140
|
if (value === null || typeof value !== "object") {
|
|
@@ -47461,7 +47478,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47461
47478
|
const { sourceDirectory, canonicalSourceDirectory, getCanonicalFileName } = info;
|
|
47462
47479
|
const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
|
|
47463
47480
|
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
|
|
47464
|
-
if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
|
|
47481
|
+
if (!baseUrl && !paths && !getResolvePackageJsonImports(compilerOptions) || relativePreference === 0 /* Relative */) {
|
|
47465
47482
|
return pathsOnly ? void 0 : relativePath;
|
|
47466
47483
|
}
|
|
47467
47484
|
const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
|
|
@@ -47469,11 +47486,12 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47469
47486
|
if (!relativeToBaseUrl) {
|
|
47470
47487
|
return pathsOnly ? void 0 : relativePath;
|
|
47471
47488
|
}
|
|
47472
|
-
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;
|
|
47473
47491
|
if (pathsOnly) {
|
|
47474
47492
|
return fromPaths;
|
|
47475
47493
|
}
|
|
47476
|
-
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);
|
|
47477
47495
|
if (!maybeNonRelative) {
|
|
47478
47496
|
return relativePath;
|
|
47479
47497
|
}
|
|
@@ -47512,8 +47530,8 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
|
|
|
47512
47530
|
if (host.getNearestAncestorDirectoryWithPackageJson) {
|
|
47513
47531
|
return host.getNearestAncestorDirectoryWithPackageJson(fileName);
|
|
47514
47532
|
}
|
|
47515
|
-
return
|
|
47516
|
-
return host.fileExists(combinePaths(directory, "package.json")) ?
|
|
47533
|
+
return forEachAncestorDirectory(fileName, (directory) => {
|
|
47534
|
+
return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
|
|
47517
47535
|
});
|
|
47518
47536
|
}
|
|
47519
47537
|
function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
|
|
@@ -47687,8 +47705,12 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
|
|
|
47687
47705
|
return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
|
|
47688
47706
|
}
|
|
47689
47707
|
}
|
|
47690
|
-
function
|
|
47708
|
+
function tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports2, conditions, mode, isImports) {
|
|
47691
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);
|
|
47692
47714
|
const pathOrPattern = getNormalizedAbsolutePath(
|
|
47693
47715
|
combinePaths(packageDirectory, exports2),
|
|
47694
47716
|
/*currentDirectory*/
|
|
@@ -47697,12 +47719,25 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
|
|
|
47697
47719
|
const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : void 0;
|
|
47698
47720
|
switch (mode) {
|
|
47699
47721
|
case 0 /* Exact */:
|
|
47700
|
-
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 */) {
|
|
47701
47723
|
return { moduleFileToTry: packageName };
|
|
47702
47724
|
}
|
|
47703
47725
|
break;
|
|
47704
47726
|
case 1 /* Directory */:
|
|
47705
|
-
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)) {
|
|
47706
47741
|
const fragment = getRelativePathFromDirectory(
|
|
47707
47742
|
pathOrPattern,
|
|
47708
47743
|
targetFilePath,
|
|
@@ -47715,48 +47750,136 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
|
|
|
47715
47750
|
void 0
|
|
47716
47751
|
) };
|
|
47717
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
|
+
}
|
|
47718
47771
|
break;
|
|
47719
47772
|
case 2 /* Pattern */:
|
|
47720
47773
|
const starPos = pathOrPattern.indexOf("*");
|
|
47721
47774
|
const leadingSlice = pathOrPattern.slice(0, starPos);
|
|
47722
47775
|
const trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
47723
|
-
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)) {
|
|
47724
47781
|
const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
47725
47782
|
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47726
47783
|
}
|
|
47727
|
-
if (
|
|
47728
|
-
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);
|
|
47729
47790
|
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
|
47730
47791
|
}
|
|
47731
47792
|
break;
|
|
47732
47793
|
}
|
|
47733
47794
|
} else if (Array.isArray(exports2)) {
|
|
47734
|
-
return forEach(exports2, (e) =>
|
|
47795
|
+
return forEach(exports2, (e) => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
|
|
47735
47796
|
} else if (typeof exports2 === "object" && exports2 !== null) {
|
|
47736
|
-
|
|
47737
|
-
|
|
47738
|
-
const
|
|
47739
|
-
|
|
47740
|
-
|
|
47741
|
-
|
|
47742
|
-
);
|
|
47743
|
-
const mode2 = endsWith(k, "/") ? 1 /* Directory */ : k.includes("*") ? 2 /* Pattern */ : 0 /* Exact */;
|
|
47744
|
-
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports2[k], conditions, mode2);
|
|
47745
|
-
});
|
|
47746
|
-
} else {
|
|
47747
|
-
for (const key of getOwnKeys(exports2)) {
|
|
47748
|
-
if (key === "default" || conditions.includes(key) || isApplicableVersionedTypesKey(conditions, key)) {
|
|
47749
|
-
const subTarget = exports2[key];
|
|
47750
|
-
const result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode);
|
|
47751
|
-
if (result) {
|
|
47752
|
-
return result;
|
|
47753
|
-
}
|
|
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;
|
|
47754
47803
|
}
|
|
47755
47804
|
}
|
|
47756
47805
|
}
|
|
47757
47806
|
}
|
|
47758
47807
|
return void 0;
|
|
47759
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
|
+
}
|
|
47760
47883
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
|
|
47761
47884
|
const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
47762
47885
|
if (normalizedTargetPaths === void 0) {
|
|
@@ -47830,22 +47953,21 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
47830
47953
|
let maybeBlockedByTypesVersions = false;
|
|
47831
47954
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
47832
47955
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
|
47833
|
-
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) ||
|
|
47956
|
+
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
47834
47957
|
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
47835
47958
|
if (getResolvePackageJsonExports(options)) {
|
|
47836
47959
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
|
47837
47960
|
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
|
47838
47961
|
const conditions = getConditions(options, importMode);
|
|
47839
|
-
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;
|
|
47840
47963
|
if (fromExports) {
|
|
47841
|
-
|
|
47842
|
-
return { ...withJsExtension, verbatimFromExports: true };
|
|
47964
|
+
return { ...fromExports, verbatimFromExports: true };
|
|
47843
47965
|
}
|
|
47844
|
-
if (packageJsonContent.exports) {
|
|
47966
|
+
if (packageJsonContent == null ? void 0 : packageJsonContent.exports) {
|
|
47845
47967
|
return { moduleFileToTry: path, blockedByExports: true };
|
|
47846
47968
|
}
|
|
47847
47969
|
}
|
|
47848
|
-
const versionPaths = packageJsonContent.typesVersions ? getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : void 0;
|
|
47970
|
+
const versionPaths = (packageJsonContent == null ? void 0 : packageJsonContent.typesVersions) ? getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : void 0;
|
|
47849
47971
|
if (versionPaths) {
|
|
47850
47972
|
const subModuleName = path.slice(packageRootPath.length + 1);
|
|
47851
47973
|
const fromPaths = tryGetModuleNameFromPaths(
|
|
@@ -47861,13 +47983,13 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
47861
47983
|
moduleFileToTry = combinePaths(packageRootPath, fromPaths);
|
|
47862
47984
|
}
|
|
47863
47985
|
}
|
|
47864
|
-
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";
|
|
47865
47987
|
if (isString(mainFileRelative) && !(maybeBlockedByTypesVersions && matchPatternOrExact(tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
47866
47988
|
const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
47867
47989
|
const canonicalModuleFileToTry = getCanonicalFileName(moduleFileToTry);
|
|
47868
47990
|
if (removeFileExtension(mainExportFile) === removeFileExtension(canonicalModuleFileToTry)) {
|
|
47869
47991
|
return { packageRootPath, moduleFileToTry };
|
|
47870
|
-
} 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") {
|
|
47871
47993
|
return { packageRootPath, moduleFileToTry };
|
|
47872
47994
|
}
|
|
47873
47995
|
}
|
|
@@ -65203,12 +65325,12 @@ function createTypeChecker(host) {
|
|
|
65203
65325
|
return !!(entry & 1 /* Succeeded */);
|
|
65204
65326
|
}
|
|
65205
65327
|
const targetEnumType = getTypeOfSymbol(targetSymbol);
|
|
65206
|
-
for (const
|
|
65207
|
-
if (
|
|
65208
|
-
const targetProperty = getPropertyOfType(targetEnumType,
|
|
65328
|
+
for (const sourceProperty of getPropertiesOfType(getTypeOfSymbol(sourceSymbol))) {
|
|
65329
|
+
if (sourceProperty.flags & 8 /* EnumMember */) {
|
|
65330
|
+
const targetProperty = getPropertyOfType(targetEnumType, sourceProperty.escapedName);
|
|
65209
65331
|
if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) {
|
|
65210
65332
|
if (errorReporter) {
|
|
65211
|
-
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(
|
|
65333
|
+
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(sourceProperty), typeToString(
|
|
65212
65334
|
getDeclaredTypeOfSymbol(targetSymbol),
|
|
65213
65335
|
/*enclosingDeclaration*/
|
|
65214
65336
|
void 0,
|
|
@@ -65220,6 +65342,35 @@ function createTypeChecker(host) {
|
|
|
65220
65342
|
}
|
|
65221
65343
|
return false;
|
|
65222
65344
|
}
|
|
65345
|
+
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
|
|
65346
|
+
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */));
|
|
65347
|
+
if (sourceValue !== targetValue) {
|
|
65348
|
+
const sourceIsString = typeof sourceValue === "string";
|
|
65349
|
+
const targetIsString = typeof targetValue === "string";
|
|
65350
|
+
if (sourceValue !== void 0 && targetValue !== void 0) {
|
|
65351
|
+
if (!errorReporter) {
|
|
65352
|
+
enumRelation.set(id, 2 /* Failed */);
|
|
65353
|
+
} else {
|
|
65354
|
+
const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
|
|
65355
|
+
const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
|
|
65356
|
+
errorReporter(Diagnostics.Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given, symbolName(targetSymbol), symbolName(targetProperty), escapedTarget, escapedSource);
|
|
65357
|
+
enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
|
|
65358
|
+
}
|
|
65359
|
+
return false;
|
|
65360
|
+
}
|
|
65361
|
+
if (sourceIsString || targetIsString) {
|
|
65362
|
+
if (!errorReporter) {
|
|
65363
|
+
enumRelation.set(id, 2 /* Failed */);
|
|
65364
|
+
} else {
|
|
65365
|
+
const knownStringValue = sourceValue ?? targetValue;
|
|
65366
|
+
Debug.assert(typeof knownStringValue === "string");
|
|
65367
|
+
const escapedValue = `"${escapeString(knownStringValue)}"`;
|
|
65368
|
+
errorReporter(Diagnostics.One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value, symbolName(targetSymbol), symbolName(targetProperty), escapedValue);
|
|
65369
|
+
enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
|
|
65370
|
+
}
|
|
65371
|
+
return false;
|
|
65372
|
+
}
|
|
65373
|
+
}
|
|
65223
65374
|
}
|
|
65224
65375
|
}
|
|
65225
65376
|
enumRelation.set(id, 1 /* Succeeded */);
|
|
@@ -115301,28 +115452,34 @@ function getSourceMapFilePath(jsFilePath, options) {
|
|
|
115301
115452
|
function getOutputExtension(fileName, options) {
|
|
115302
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 */;
|
|
115303
115454
|
}
|
|
115304
|
-
function getOutputPathWithoutChangingExt(inputFileName,
|
|
115455
|
+
function getOutputPathWithoutChangingExt(inputFileName, ignoreCase, outputDir, getCommonSourceDirectory2) {
|
|
115305
115456
|
return outputDir ? resolvePath(
|
|
115306
115457
|
outputDir,
|
|
115307
|
-
getRelativePathFromDirectory(getCommonSourceDirectory2
|
|
115458
|
+
getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)
|
|
115308
115459
|
) : inputFileName;
|
|
115309
115460
|
}
|
|
115310
|
-
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) {
|
|
115311
115465
|
return changeExtension(
|
|
115312
|
-
getOutputPathWithoutChangingExt(inputFileName,
|
|
115466
|
+
getOutputPathWithoutChangingExt(inputFileName, ignoreCase, options.declarationDir || options.outDir, getCommonSourceDirectory2),
|
|
115313
115467
|
getDeclarationEmitExtensionForPath(inputFileName)
|
|
115314
115468
|
);
|
|
115315
115469
|
}
|
|
115316
|
-
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
|
|
115470
|
+
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2 = () => getCommonSourceDirectoryOfConfig(configFile, ignoreCase)) {
|
|
115317
115471
|
if (configFile.options.emitDeclarationOnly)
|
|
115318
115472
|
return void 0;
|
|
115319
115473
|
const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
115320
|
-
const outputFileName =
|
|
115321
|
-
getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory2),
|
|
115322
|
-
getOutputExtension(inputFileName, configFile.options)
|
|
115323
|
-
);
|
|
115474
|
+
const outputFileName = getOutputJSFileNameWorker(inputFileName, configFile.options, ignoreCase, getCommonSourceDirectory2);
|
|
115324
115475
|
return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
115325
115476
|
}
|
|
115477
|
+
function getOutputJSFileNameWorker(inputFileName, options, ignoreCase, getCommonSourceDirectory2) {
|
|
115478
|
+
return changeExtension(
|
|
115479
|
+
getOutputPathWithoutChangingExt(inputFileName, ignoreCase, options.outDir, getCommonSourceDirectory2),
|
|
115480
|
+
getOutputExtension(inputFileName, options)
|
|
115481
|
+
);
|
|
115482
|
+
}
|
|
115326
115483
|
function createAddOutput() {
|
|
115327
115484
|
let outputs;
|
|
115328
115485
|
return { addOutput, getOutputs };
|
|
@@ -133666,7 +133823,8 @@ function createModuleSpecifierResolutionHost(program, host) {
|
|
|
133666
133823
|
getProjectReferenceRedirect: (fileName) => program.getProjectReferenceRedirect(fileName),
|
|
133667
133824
|
isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
|
|
133668
133825
|
getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
|
|
133669
|
-
getFileIncludeReasons: () => program.getFileIncludeReasons()
|
|
133826
|
+
getFileIncludeReasons: () => program.getFileIncludeReasons(),
|
|
133827
|
+
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
133670
133828
|
};
|
|
133671
133829
|
}
|
|
133672
133830
|
function getModuleSpecifierResolverHost(program, host) {
|
|
@@ -134727,13 +134885,6 @@ function createPackageJsonImportFilter(fromFile, preferences, host) {
|
|
|
134727
134885
|
return components[0];
|
|
134728
134886
|
}
|
|
134729
134887
|
}
|
|
134730
|
-
function tryParseJson(text) {
|
|
134731
|
-
try {
|
|
134732
|
-
return JSON.parse(text);
|
|
134733
|
-
} catch {
|
|
134734
|
-
return void 0;
|
|
134735
|
-
}
|
|
134736
|
-
}
|
|
134737
134888
|
function consumesNodeCoreModules(sourceFile) {
|
|
134738
134889
|
return some(sourceFile.imports, ({ text }) => ts_JsTyping_exports.nodeCoreModules.has(text));
|
|
134739
134890
|
}
|
|
@@ -174457,8 +174608,10 @@ __export(ts_exports2, {
|
|
|
174457
174608
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
174458
174609
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
174459
174610
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
174611
|
+
getOutputDeclarationFileNameWorker: () => getOutputDeclarationFileNameWorker,
|
|
174460
174612
|
getOutputExtension: () => getOutputExtension,
|
|
174461
174613
|
getOutputFileNames: () => getOutputFileNames,
|
|
174614
|
+
getOutputJSFileNameWorker: () => getOutputJSFileNameWorker,
|
|
174462
174615
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
174463
174616
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
174464
174617
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -175089,6 +175242,7 @@ __export(ts_exports2, {
|
|
|
175089
175242
|
isMethodSignature: () => isMethodSignature,
|
|
175090
175243
|
isMinusToken: () => isMinusToken,
|
|
175091
175244
|
isMissingDeclaration: () => isMissingDeclaration,
|
|
175245
|
+
isMissingPackageJsonInfo: () => isMissingPackageJsonInfo,
|
|
175092
175246
|
isModifier: () => isModifier,
|
|
175093
175247
|
isModifierKind: () => isModifierKind,
|
|
175094
175248
|
isModifierLike: () => isModifierLike,
|
|
@@ -175790,6 +175944,7 @@ __export(ts_exports2, {
|
|
|
175790
175944
|
tryGetSourceMappingURL: () => tryGetSourceMappingURL,
|
|
175791
175945
|
tryGetTextOfPropertyName: () => tryGetTextOfPropertyName,
|
|
175792
175946
|
tryIOAndConsumeErrors: () => tryIOAndConsumeErrors,
|
|
175947
|
+
tryParseJson: () => tryParseJson,
|
|
175793
175948
|
tryParsePattern: () => tryParsePattern,
|
|
175794
175949
|
tryParsePatterns: () => tryParsePatterns,
|
|
175795
175950
|
tryParseRawSourceMap: () => tryParseRawSourceMap,
|
|
@@ -189252,8 +189407,10 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189252
189407
|
getOriginalNodeId,
|
|
189253
189408
|
getOriginalSourceFile,
|
|
189254
189409
|
getOutputDeclarationFileName,
|
|
189410
|
+
getOutputDeclarationFileNameWorker,
|
|
189255
189411
|
getOutputExtension,
|
|
189256
189412
|
getOutputFileNames,
|
|
189413
|
+
getOutputJSFileNameWorker,
|
|
189257
189414
|
getOutputPathsFor,
|
|
189258
189415
|
getOutputPathsForBundle,
|
|
189259
189416
|
getOwnEmitOutputFilePath,
|
|
@@ -189884,6 +190041,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189884
190041
|
isMethodSignature,
|
|
189885
190042
|
isMinusToken,
|
|
189886
190043
|
isMissingDeclaration,
|
|
190044
|
+
isMissingPackageJsonInfo,
|
|
189887
190045
|
isModifier,
|
|
189888
190046
|
isModifierKind,
|
|
189889
190047
|
isModifierLike,
|
|
@@ -190585,6 +190743,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
190585
190743
|
tryGetSourceMappingURL,
|
|
190586
190744
|
tryGetTextOfPropertyName,
|
|
190587
190745
|
tryIOAndConsumeErrors,
|
|
190746
|
+
tryParseJson,
|
|
190588
190747
|
tryParsePattern,
|
|
190589
190748
|
tryParsePatterns,
|
|
190590
190749
|
tryParseRawSourceMap,
|