typescript 5.0.0-dev.20230108 → 5.0.0-dev.20230110
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 +100 -74
- package/lib/tsserver.js +102 -77
- package/lib/tsserverlibrary.d.ts +2 -2
- package/lib/tsserverlibrary.js +102 -76
- package/lib/typescript.d.ts +2 -2
- package/lib/typescript.js +102 -75
- package/lib/typingsInstaller.js +38 -40
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts = (() => {
|
|
|
42
42
|
"src/compiler/corePublic.ts"() {
|
|
43
43
|
"use strict";
|
|
44
44
|
versionMajorMinor = "5.0";
|
|
45
|
-
version = `${versionMajorMinor}.0-dev.
|
|
45
|
+
version = `${versionMajorMinor}.0-dev.20230110`;
|
|
46
46
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
47
47
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
48
48
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -8394,6 +8394,9 @@ ${lanes.join("\n")}
|
|
|
8394
8394
|
Found_1_error_in_1: diag(6259, 3 /* Message */, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
|
|
8395
8395
|
Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, 3 /* Message */, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
|
|
8396
8396
|
Found_0_errors_in_1_files: diag(6261, 3 /* Message */, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
|
|
8397
|
+
File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
|
|
8398
|
+
Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
|
|
8399
|
+
Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
|
|
8397
8400
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
8398
8401
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
8399
8402
|
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
@@ -15859,13 +15862,13 @@ ${lanes.join("\n")}
|
|
|
15859
15862
|
return removeFileExtension(path) + declarationExtension;
|
|
15860
15863
|
}
|
|
15861
15864
|
function getDeclarationEmitExtensionForPath(path) {
|
|
15862
|
-
return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.json.
|
|
15865
|
+
return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.d.json.ts` : (
|
|
15863
15866
|
// Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
|
|
15864
15867
|
".d.ts" /* Dts */
|
|
15865
15868
|
);
|
|
15866
15869
|
}
|
|
15867
15870
|
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
15868
|
-
return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.json.
|
|
15871
|
+
return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
15869
15872
|
}
|
|
15870
15873
|
function outFile(options) {
|
|
15871
15874
|
return options.outFile || options.out;
|
|
@@ -17872,7 +17875,7 @@ ${lanes.join("\n")}
|
|
|
17872
17875
|
return !(pos >= 0);
|
|
17873
17876
|
}
|
|
17874
17877
|
function extensionIsTS(ext) {
|
|
17875
|
-
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts
|
|
17878
|
+
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */ || startsWith(ext, ".d.") && endsWith(ext, ".ts");
|
|
17876
17879
|
}
|
|
17877
17880
|
function resolutionExtensionIsTSOrJson(ext) {
|
|
17878
17881
|
return extensionIsTS(ext) || ext === ".json" /* Json */;
|
|
@@ -26928,7 +26931,7 @@ ${lanes.join("\n")}
|
|
|
26928
26931
|
return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length2);
|
|
26929
26932
|
}
|
|
26930
26933
|
function isDeclarationFileName(fileName) {
|
|
26931
|
-
return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions);
|
|
26934
|
+
return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions) || fileExtensionIs(fileName, ".ts" /* Ts */) && stringContains(getBaseFileName(fileName), ".d.");
|
|
26932
26935
|
}
|
|
26933
26936
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
26934
26937
|
if (!mode) {
|
|
@@ -37298,6 +37301,14 @@ ${lanes.join("\n")}
|
|
|
37298
37301
|
description: Diagnostics.Enable_importing_json_files,
|
|
37299
37302
|
defaultValueDescription: false
|
|
37300
37303
|
},
|
|
37304
|
+
{
|
|
37305
|
+
name: "allowArbitraryExtensions",
|
|
37306
|
+
type: "boolean",
|
|
37307
|
+
affectsModuleResolution: true,
|
|
37308
|
+
category: Diagnostics.Modules,
|
|
37309
|
+
description: Diagnostics.Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present,
|
|
37310
|
+
defaultValueDescription: false
|
|
37311
|
+
},
|
|
37301
37312
|
{
|
|
37302
37313
|
name: "out",
|
|
37303
37314
|
type: "string",
|
|
@@ -39045,14 +39056,19 @@ ${lanes.join("\n")}
|
|
|
39045
39056
|
}
|
|
39046
39057
|
}
|
|
39047
39058
|
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
39048
|
-
|
|
39049
|
-
|
|
39050
|
-
|
|
39051
|
-
if (state.traceEnabled) {
|
|
39052
|
-
trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
39053
|
-
}
|
|
39054
|
-
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
39059
|
+
const filename = getBaseFileName(candidate);
|
|
39060
|
+
if (filename.indexOf(".") === -1) {
|
|
39061
|
+
return void 0;
|
|
39055
39062
|
}
|
|
39063
|
+
let extensionless = removeFileExtension(candidate);
|
|
39064
|
+
if (extensionless === candidate) {
|
|
39065
|
+
extensionless = candidate.substring(0, candidate.lastIndexOf("."));
|
|
39066
|
+
}
|
|
39067
|
+
const extension = candidate.substring(extensionless.length);
|
|
39068
|
+
if (state.traceEnabled) {
|
|
39069
|
+
trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
39070
|
+
}
|
|
39071
|
+
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
39056
39072
|
}
|
|
39057
39073
|
function loadFileNameFromPackageJsonField(extensions, candidate, onlyRecordFailures, state) {
|
|
39058
39074
|
if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
|
|
@@ -39076,38 +39092,23 @@ ${lanes.join("\n")}
|
|
|
39076
39092
|
case ".mjs" /* Mjs */:
|
|
39077
39093
|
case ".mts" /* Mts */:
|
|
39078
39094
|
case ".d.mts" /* Dmts */:
|
|
39079
|
-
return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
|
|
39095
|
+
return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
|
|
39080
39096
|
case ".cjs" /* Cjs */:
|
|
39081
39097
|
case ".cts" /* Cts */:
|
|
39082
39098
|
case ".d.cts" /* Dcts */:
|
|
39083
|
-
return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
|
|
39099
|
+
return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
|
|
39084
39100
|
case ".json" /* Json */:
|
|
39085
|
-
|
|
39086
|
-
if (extensions & 4 /* Declaration */) {
|
|
39087
|
-
candidate += ".json" /* Json */;
|
|
39088
|
-
const result = tryExtension(".d.ts" /* Dts */);
|
|
39089
|
-
if (result)
|
|
39090
|
-
return result;
|
|
39091
|
-
}
|
|
39092
|
-
if (extensions & 8 /* Json */) {
|
|
39093
|
-
candidate = originalCandidate;
|
|
39094
|
-
const result = tryExtension(".json" /* Json */);
|
|
39095
|
-
if (result)
|
|
39096
|
-
return result;
|
|
39097
|
-
}
|
|
39098
|
-
return void 0;
|
|
39099
|
-
case ".ts" /* Ts */:
|
|
39101
|
+
return extensions & 4 /* Declaration */ && tryExtension(".d.json.ts") || extensions & 8 /* Json */ && tryExtension(".json" /* Json */) || void 0;
|
|
39100
39102
|
case ".tsx" /* Tsx */:
|
|
39103
|
+
case ".jsx" /* Jsx */:
|
|
39104
|
+
return extensions & 1 /* TypeScript */ && (tryExtension(".tsx" /* Tsx */, originalExtension === ".tsx" /* Tsx */) || tryExtension(".ts" /* Ts */, originalExtension === ".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".tsx" /* Tsx */) || extensions & 2 /* JavaScript */ && (tryExtension(".jsx" /* Jsx */) || tryExtension(".js" /* Js */)) || void 0;
|
|
39105
|
+
case ".ts" /* Ts */:
|
|
39101
39106
|
case ".d.ts" /* Dts */:
|
|
39102
|
-
|
|
39103
|
-
|
|
39104
|
-
|
|
39105
|
-
/*resolvedUsingTsExtension*/
|
|
39106
|
-
true
|
|
39107
|
-
);
|
|
39108
|
-
}
|
|
39107
|
+
case ".js" /* Js */:
|
|
39108
|
+
case "":
|
|
39109
|
+
return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || tryExtension(".tsx" /* Tsx */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
|
|
39109
39110
|
default:
|
|
39110
|
-
return extensions &
|
|
39111
|
+
return extensions & 4 /* Declaration */ && !isDeclarationFileName(candidate + originalExtension) && tryExtension(`.d${originalExtension}.ts`) || void 0;
|
|
39111
39112
|
}
|
|
39112
39113
|
function tryExtension(ext, resolvedUsingTsExtension) {
|
|
39113
39114
|
const path = tryFile(candidate + ext, onlyRecordFailures, state);
|
|
@@ -40146,11 +40147,8 @@ ${lanes.join("\n")}
|
|
|
40146
40147
|
}
|
|
40147
40148
|
}
|
|
40148
40149
|
}
|
|
40149
|
-
function moduleResolutionSupportsResolvingTsExtensions(compilerOptions) {
|
|
40150
|
-
return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */;
|
|
40151
|
-
}
|
|
40152
40150
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
40153
|
-
return
|
|
40151
|
+
return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
|
|
40154
40152
|
}
|
|
40155
40153
|
function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) {
|
|
40156
40154
|
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
@@ -43916,6 +43914,8 @@ ${lanes.join("\n")}
|
|
|
43916
43914
|
}
|
|
43917
43915
|
if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
|
|
43918
43916
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
43917
|
+
} else if (!fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */]) && fileExtensionIsOneOf(fileName, [".ts" /* Ts */]) && stringContains(fileName, ".d.")) {
|
|
43918
|
+
return tryGetRealFileNameForNonJsDeclarationFileName(fileName);
|
|
43919
43919
|
}
|
|
43920
43920
|
switch (allowedEndings[0]) {
|
|
43921
43921
|
case 0 /* Minimal */:
|
|
@@ -43939,6 +43939,14 @@ ${lanes.join("\n")}
|
|
|
43939
43939
|
return Debug.assertNever(allowedEndings[0]);
|
|
43940
43940
|
}
|
|
43941
43941
|
}
|
|
43942
|
+
function tryGetRealFileNameForNonJsDeclarationFileName(fileName) {
|
|
43943
|
+
const baseName = getBaseFileName(fileName);
|
|
43944
|
+
if (!endsWith(fileName, ".ts" /* Ts */) || !stringContains(baseName, ".d.") || fileExtensionIsOneOf(baseName, [".d.ts" /* Dts */]))
|
|
43945
|
+
return void 0;
|
|
43946
|
+
const noExtension = removeExtension(fileName, ".ts" /* Ts */);
|
|
43947
|
+
const ext = noExtension.substring(noExtension.lastIndexOf("."));
|
|
43948
|
+
return noExtension.substring(0, noExtension.indexOf(".d.")) + ext;
|
|
43949
|
+
}
|
|
43942
43950
|
function getJSExtensionForFile(fileName, options) {
|
|
43943
43951
|
var _a2;
|
|
43944
43952
|
return (_a2 = tryGetJSExtensionForFile(fileName, options)) != null ? _a2 : Debug.fail(`Extension ${extensionFromPath(fileName)} is unsupported:: FileName:: ${fileName}`);
|
|
@@ -43999,6 +44007,7 @@ ${lanes.join("\n")}
|
|
|
43999
44007
|
getNodeModulesPackageName: () => getNodeModulesPackageName,
|
|
44000
44008
|
tryGetJSExtensionForFile: () => tryGetJSExtensionForFile,
|
|
44001
44009
|
tryGetModuleSpecifiersFromCache: () => tryGetModuleSpecifiersFromCache,
|
|
44010
|
+
tryGetRealFileNameForNonJsDeclarationFileName: () => tryGetRealFileNameForNonJsDeclarationFileName,
|
|
44002
44011
|
updateModuleSpecifier: () => updateModuleSpecifier
|
|
44003
44012
|
});
|
|
44004
44013
|
var init_ts_moduleSpecifiers = __esm({
|
|
@@ -46266,7 +46275,7 @@ ${lanes.join("\n")}
|
|
|
46266
46275
|
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
|
|
46267
46276
|
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
|
46268
46277
|
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
46269
|
-
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
46278
|
+
if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
|
|
46270
46279
|
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
46271
46280
|
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
46272
46281
|
const exportAssignment = exportEqualsSymbol.valueDeclaration;
|
|
@@ -47061,7 +47070,7 @@ ${lanes.join("\n")}
|
|
|
47061
47070
|
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
47062
47071
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
47063
47072
|
const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode);
|
|
47064
|
-
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
47073
|
+
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
47065
47074
|
const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
47066
47075
|
if (sourceFile) {
|
|
47067
47076
|
if (resolutionDiagnostic) {
|
|
@@ -51015,7 +51024,9 @@ ${lanes.join("\n")}
|
|
|
51015
51024
|
case 267 /* NamespaceExportDeclaration */:
|
|
51016
51025
|
addResult(factory.createNamespaceExportDeclaration(idText(node.name)), 0 /* None */);
|
|
51017
51026
|
break;
|
|
51018
|
-
case 270 /* ImportClause */:
|
|
51027
|
+
case 270 /* ImportClause */: {
|
|
51028
|
+
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
51029
|
+
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
|
|
51019
51030
|
addResult(factory.createImportDeclaration(
|
|
51020
51031
|
/*modifiers*/
|
|
51021
51032
|
void 0,
|
|
@@ -51026,15 +51037,14 @@ ${lanes.join("\n")}
|
|
|
51026
51037
|
/*namedBindings*/
|
|
51027
51038
|
void 0
|
|
51028
51039
|
),
|
|
51029
|
-
|
|
51030
|
-
|
|
51031
|
-
// In such cases, the `target` refers to the module itself already
|
|
51032
|
-
factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
|
|
51033
|
-
/*assertClause*/
|
|
51034
|
-
void 0
|
|
51040
|
+
specifier2,
|
|
51041
|
+
node.parent.assertClause
|
|
51035
51042
|
), 0 /* None */);
|
|
51036
51043
|
break;
|
|
51037
|
-
|
|
51044
|
+
}
|
|
51045
|
+
case 271 /* NamespaceImport */: {
|
|
51046
|
+
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
51047
|
+
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
|
|
51038
51048
|
addResult(factory.createImportDeclaration(
|
|
51039
51049
|
/*modifiers*/
|
|
51040
51050
|
void 0,
|
|
@@ -51045,11 +51055,11 @@ ${lanes.join("\n")}
|
|
|
51045
51055
|
void 0,
|
|
51046
51056
|
factory.createNamespaceImport(factory.createIdentifier(localName))
|
|
51047
51057
|
),
|
|
51048
|
-
|
|
51049
|
-
|
|
51050
|
-
void 0
|
|
51058
|
+
specifier2,
|
|
51059
|
+
node.parent.parent.assertClause
|
|
51051
51060
|
), 0 /* None */);
|
|
51052
51061
|
break;
|
|
51062
|
+
}
|
|
51053
51063
|
case 277 /* NamespaceExport */:
|
|
51054
51064
|
addResult(factory.createExportDeclaration(
|
|
51055
51065
|
/*modifiers*/
|
|
@@ -51060,7 +51070,9 @@ ${lanes.join("\n")}
|
|
|
51060
51070
|
factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))
|
|
51061
51071
|
), 0 /* None */);
|
|
51062
51072
|
break;
|
|
51063
|
-
case 273 /* ImportSpecifier */:
|
|
51073
|
+
case 273 /* ImportSpecifier */: {
|
|
51074
|
+
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
51075
|
+
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
|
|
51064
51076
|
addResult(factory.createImportDeclaration(
|
|
51065
51077
|
/*modifiers*/
|
|
51066
51078
|
void 0,
|
|
@@ -51078,11 +51090,11 @@ ${lanes.join("\n")}
|
|
|
51078
51090
|
)
|
|
51079
51091
|
])
|
|
51080
51092
|
),
|
|
51081
|
-
|
|
51082
|
-
|
|
51083
|
-
void 0
|
|
51093
|
+
specifier2,
|
|
51094
|
+
node.parent.parent.parent.assertClause
|
|
51084
51095
|
), 0 /* None */);
|
|
51085
51096
|
break;
|
|
51097
|
+
}
|
|
51086
51098
|
case 278 /* ExportSpecifier */:
|
|
51087
51099
|
const specifier = node.parent.parent.moduleSpecifier;
|
|
51088
51100
|
serializeExportSpecifier(
|
|
@@ -73736,7 +73748,7 @@ ${lanes.join("\n")}
|
|
|
73736
73748
|
return getRegularTypeOfObjectLiteral(rightType);
|
|
73737
73749
|
}
|
|
73738
73750
|
case 27 /* CommaToken */:
|
|
73739
|
-
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !
|
|
73751
|
+
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isIndirectCall(left.parent)) {
|
|
73740
73752
|
const sf = getSourceFileOfNode(left);
|
|
73741
73753
|
const sourceText = sf.text;
|
|
73742
73754
|
const start = skipTrivia(sourceText, left.pos);
|
|
@@ -73778,8 +73790,8 @@ ${lanes.join("\n")}
|
|
|
73778
73790
|
}
|
|
73779
73791
|
}
|
|
73780
73792
|
}
|
|
73781
|
-
function
|
|
73782
|
-
return node.kind ===
|
|
73793
|
+
function isIndirectCall(node) {
|
|
73794
|
+
return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && (isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
73783
73795
|
}
|
|
73784
73796
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
73785
73797
|
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
|
|
@@ -74343,15 +74355,16 @@ ${lanes.join("\n")}
|
|
|
74343
74355
|
}
|
|
74344
74356
|
}
|
|
74345
74357
|
expr = skipParentheses(node);
|
|
74358
|
+
if (isAwaitExpression(expr)) {
|
|
74359
|
+
const type = getQuickTypeOfExpression(expr.expression);
|
|
74360
|
+
return type ? getAwaitedType(type) : void 0;
|
|
74361
|
+
}
|
|
74346
74362
|
if (isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !isRequireCall(
|
|
74347
74363
|
expr,
|
|
74348
74364
|
/*checkArgumentIsStringLiteralLike*/
|
|
74349
74365
|
true
|
|
74350
74366
|
) && !isSymbolOrSymbolForCall(expr)) {
|
|
74351
|
-
|
|
74352
|
-
if (type) {
|
|
74353
|
-
return type;
|
|
74354
|
-
}
|
|
74367
|
+
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
|
|
74355
74368
|
} else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
|
74356
74369
|
return getTypeFromTypeNode(expr.type);
|
|
74357
74370
|
} else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) {
|
|
@@ -79518,12 +79531,12 @@ ${lanes.join("\n")}
|
|
|
79518
79531
|
if (node.flags & 16777216 /* Ambient */ && !isEntityNameExpression(node.expression)) {
|
|
79519
79532
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
79520
79533
|
}
|
|
79521
|
-
if (node.isExportEquals
|
|
79522
|
-
if (moduleKind >= 5 /* ES2015 */ && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */) {
|
|
79534
|
+
if (node.isExportEquals) {
|
|
79535
|
+
if (moduleKind >= 5 /* ES2015 */ && (node.flags & 16777216 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 16777216 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
|
|
79523
79536
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
79524
|
-
} else if (moduleKind === 4 /* System */) {
|
|
79537
|
+
} else if (moduleKind === 4 /* System */ && !(node.flags & 16777216 /* Ambient */)) {
|
|
79525
79538
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
79526
|
-
} else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */) {
|
|
79539
|
+
} else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && !(node.flags & 16777216 /* Ambient */)) {
|
|
79527
79540
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_bundler_Consider_using_export_default_or_another_module_format_instead);
|
|
79528
79541
|
}
|
|
79529
79542
|
}
|
|
@@ -113486,7 +113499,7 @@ ${lanes.join("\n")}
|
|
|
113486
113499
|
currentNodeModulesDepth++;
|
|
113487
113500
|
}
|
|
113488
113501
|
const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
|
|
113489
|
-
const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
113502
|
+
const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution, file) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
113490
113503
|
if (elideImport) {
|
|
113491
113504
|
modulesWithElidedImports.set(file.path, true);
|
|
113492
113505
|
} else if (shouldAddFile) {
|
|
@@ -113829,7 +113842,7 @@ ${lanes.join("\n")}
|
|
|
113829
113842
|
if (options.preserveValueImports && getEmitModuleKind(options) < 5 /* ES2015 */) {
|
|
113830
113843
|
createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later);
|
|
113831
113844
|
}
|
|
113832
|
-
if (options.allowImportingTsExtensions && !(
|
|
113845
|
+
if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly)) {
|
|
113833
113846
|
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_bundler_and_either_noEmit_or_emitDeclarationOnly_is_set);
|
|
113834
113847
|
}
|
|
113835
113848
|
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
@@ -114480,19 +114493,27 @@ ${lanes.join("\n")}
|
|
|
114480
114493
|
const passedInRef = ref ? ref : hostOrRef;
|
|
114481
114494
|
return resolveConfigFileProjectName(passedInRef.path);
|
|
114482
114495
|
}
|
|
114483
|
-
function getResolutionDiagnostic(options, { extension }) {
|
|
114496
|
+
function getResolutionDiagnostic(options, { extension }, { isDeclarationFile }) {
|
|
114484
114497
|
switch (extension) {
|
|
114485
114498
|
case ".ts" /* Ts */:
|
|
114486
114499
|
case ".d.ts" /* Dts */:
|
|
114500
|
+
case ".mts" /* Mts */:
|
|
114501
|
+
case ".d.mts" /* Dmts */:
|
|
114502
|
+
case ".cts" /* Cts */:
|
|
114503
|
+
case ".d.cts" /* Dcts */:
|
|
114487
114504
|
return void 0;
|
|
114488
114505
|
case ".tsx" /* Tsx */:
|
|
114489
114506
|
return needJsx();
|
|
114490
114507
|
case ".jsx" /* Jsx */:
|
|
114491
114508
|
return needJsx() || needAllowJs();
|
|
114492
114509
|
case ".js" /* Js */:
|
|
114510
|
+
case ".mjs" /* Mjs */:
|
|
114511
|
+
case ".cjs" /* Cjs */:
|
|
114493
114512
|
return needAllowJs();
|
|
114494
114513
|
case ".json" /* Json */:
|
|
114495
114514
|
return needResolveJsonModule();
|
|
114515
|
+
default:
|
|
114516
|
+
return needAllowArbitraryExtensions();
|
|
114496
114517
|
}
|
|
114497
114518
|
function needJsx() {
|
|
114498
114519
|
return options.jsx ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
|
|
@@ -114503,6 +114524,9 @@ ${lanes.join("\n")}
|
|
|
114503
114524
|
function needResolveJsonModule() {
|
|
114504
114525
|
return getResolveJsonModule(options) ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
|
|
114505
114526
|
}
|
|
114527
|
+
function needAllowArbitraryExtensions() {
|
|
114528
|
+
return isDeclarationFile || options.allowArbitraryExtensions ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set;
|
|
114529
|
+
}
|
|
114506
114530
|
}
|
|
114507
114531
|
function getModuleNames({ imports, moduleAugmentations }) {
|
|
114508
114532
|
const res = imports.map((i) => i);
|
|
@@ -144528,7 +144552,7 @@ ${lanes.join("\n")}
|
|
|
144528
144552
|
break;
|
|
144529
144553
|
case 291 /* JsxExpression */:
|
|
144530
144554
|
case 290 /* JsxSpreadAttribute */:
|
|
144531
|
-
if (previousToken.kind === 19 /* CloseBraceToken */
|
|
144555
|
+
if (previousToken.kind === 19 /* CloseBraceToken */ || (previousToken.kind === 79 /* Identifier */ || previousToken.parent.kind === 288 /* JsxAttribute */)) {
|
|
144532
144556
|
isJsxIdentifierExpected = true;
|
|
144533
144557
|
}
|
|
144534
144558
|
break;
|
|
@@ -146674,6 +146698,10 @@ ${lanes.join("\n")}
|
|
|
146674
146698
|
return result;
|
|
146675
146699
|
}
|
|
146676
146700
|
function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions) {
|
|
146701
|
+
const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
|
|
146702
|
+
if (nonJsResult) {
|
|
146703
|
+
return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
|
|
146704
|
+
}
|
|
146677
146705
|
if (extensionOptions.referenceKind === 0 /* Filename */) {
|
|
146678
146706
|
return { name, extension: tryGetExtensionFromPath2(name) };
|
|
146679
146707
|
}
|
|
@@ -147619,7 +147647,7 @@ ${lanes.join("\n")}
|
|
|
147619
147647
|
if (symbol.declarations) {
|
|
147620
147648
|
for (const declaration of symbol.declarations) {
|
|
147621
147649
|
if (isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) {
|
|
147622
|
-
return checker.getExportSpecifierLocalTargetSymbol(declaration);
|
|
147650
|
+
return checker.getExportSpecifierLocalTargetSymbol(declaration) || symbol;
|
|
147623
147651
|
} else if (isPropertyAccessExpression(declaration) && isModuleExportsAccessExpression(declaration.expression) && !isPrivateIdentifier(declaration.name)) {
|
|
147624
147652
|
return checker.getSymbolAtLocation(declaration);
|
|
147625
147653
|
} else if (isShorthandPropertyAssignment(declaration) && isBinaryExpression(declaration.parent.parent) && getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) {
|
|
@@ -176831,7 +176859,6 @@ ${e.message}`;
|
|
|
176831
176859
|
moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
|
|
176832
176860
|
moduleResolutionOptionDeclarations: () => moduleResolutionOptionDeclarations,
|
|
176833
176861
|
moduleResolutionSupportsPackageJsonExportsAndImports: () => moduleResolutionSupportsPackageJsonExportsAndImports,
|
|
176834
|
-
moduleResolutionSupportsResolvingTsExtensions: () => moduleResolutionSupportsResolvingTsExtensions,
|
|
176835
176862
|
moduleResolutionUsesNodeModules: () => moduleResolutionUsesNodeModules,
|
|
176836
176863
|
moduleSpecifiers: () => ts_moduleSpecifiers_exports,
|
|
176837
176864
|
moveEmitHelpers: () => moveEmitHelpers,
|
|
@@ -179472,7 +179499,6 @@ ${e.message}`;
|
|
|
179472
179499
|
moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
|
|
179473
179500
|
moduleResolutionOptionDeclarations: () => moduleResolutionOptionDeclarations,
|
|
179474
179501
|
moduleResolutionSupportsPackageJsonExportsAndImports: () => moduleResolutionSupportsPackageJsonExportsAndImports,
|
|
179475
|
-
moduleResolutionSupportsResolvingTsExtensions: () => moduleResolutionSupportsResolvingTsExtensions,
|
|
179476
179502
|
moduleResolutionUsesNodeModules: () => moduleResolutionUsesNodeModules,
|
|
179477
179503
|
moduleSpecifiers: () => ts_moduleSpecifiers_exports,
|
|
179478
179504
|
moveEmitHelpers: () => moveEmitHelpers,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -3083,6 +3083,7 @@ declare namespace ts {
|
|
|
3083
3083
|
interface CompilerOptions {
|
|
3084
3084
|
allowImportingTsExtensions?: boolean;
|
|
3085
3085
|
allowJs?: boolean;
|
|
3086
|
+
allowArbitraryExtensions?: boolean;
|
|
3086
3087
|
allowSyntheticDefaultImports?: boolean;
|
|
3087
3088
|
allowUmdGlobalAccess?: boolean;
|
|
3088
3089
|
allowUnreachableCode?: boolean;
|
|
@@ -3346,7 +3347,7 @@ declare namespace ts {
|
|
|
3346
3347
|
* Extension of resolvedFileName. This must match what's at the end of resolvedFileName.
|
|
3347
3348
|
* This is optional for backwards-compatibility, but will be added if not provided.
|
|
3348
3349
|
*/
|
|
3349
|
-
extension:
|
|
3350
|
+
extension: string;
|
|
3350
3351
|
packageId?: PackageId;
|
|
3351
3352
|
}
|
|
3352
3353
|
/**
|
|
@@ -5277,7 +5278,6 @@ declare namespace ts {
|
|
|
5277
5278
|
function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
|
|
5278
5279
|
function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
|
|
5279
5280
|
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
|
|
5280
|
-
function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean;
|
|
5281
5281
|
function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined;
|
|
5282
5282
|
interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, NonRelativeNameResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
|
|
5283
5283
|
}
|