@typescript-deploys/pr-build 5.0.0-pr-51865-14 → 5.0.0-pr-51669-12
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 +414 -216
- package/lib/tsserver.js +563 -296
- package/lib/tsserverlibrary.d.ts +15 -1
- package/lib/tsserverlibrary.js +553 -296
- package/lib/typescript.d.ts +15 -1
- package/lib/typescript.js +542 -295
- package/lib/typingsInstaller.js +163 -28
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -23,7 +23,7 @@ var __export = (target, all) => {
|
|
|
23
23
|
|
|
24
24
|
// src/compiler/corePublic.ts
|
|
25
25
|
var versionMajorMinor = "5.0";
|
|
26
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
26
|
+
var version = `${versionMajorMinor}.0-insiders.20221213`;
|
|
27
27
|
|
|
28
28
|
// src/compiler/core.ts
|
|
29
29
|
var emptyArray = [];
|
|
@@ -3715,6 +3715,7 @@ var ModuleResolutionKind = /* @__PURE__ */ ((ModuleResolutionKind2) => {
|
|
|
3715
3715
|
ModuleResolutionKind2[ModuleResolutionKind2["NodeJs"] = 2] = "NodeJs";
|
|
3716
3716
|
ModuleResolutionKind2[ModuleResolutionKind2["Node16"] = 3] = "Node16";
|
|
3717
3717
|
ModuleResolutionKind2[ModuleResolutionKind2["NodeNext"] = 99] = "NodeNext";
|
|
3718
|
+
ModuleResolutionKind2[ModuleResolutionKind2["Hybrid"] = 100] = "Hybrid";
|
|
3718
3719
|
return ModuleResolutionKind2;
|
|
3719
3720
|
})(ModuleResolutionKind || {});
|
|
3720
3721
|
var ModuleKind = /* @__PURE__ */ ((ModuleKind2) => {
|
|
@@ -5804,7 +5805,6 @@ var Diagnostics = {
|
|
|
5804
5805
|
_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, 1 /* Error */, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"),
|
|
5805
5806
|
accessor_modifier_can_only_appear_on_a_property_declaration: diag(1275, 1 /* Error */, "accessor_modifier_can_only_appear_on_a_property_declaration_1275", "'accessor' modifier can only appear on a property declaration."),
|
|
5806
5807
|
An_accessor_property_cannot_be_declared_optional: diag(1276, 1 /* Error */, "An_accessor_property_cannot_be_declared_optional_1276", "An 'accessor' property cannot be declared optional."),
|
|
5807
|
-
_0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class: diag(1277, 1 /* Error */, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class_1277", "'{0}' modifier can only appear on a type parameter of a function, method or class"),
|
|
5808
5808
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
5809
5809
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
5810
5810
|
The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
|
|
@@ -6466,6 +6466,7 @@ var Diagnostics = {
|
|
|
6466
6466
|
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, 1 /* Error */, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
6467
6467
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
6468
6468
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
6469
|
+
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
6469
6470
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6470
6471
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6471
6472
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -6630,6 +6631,11 @@ var Diagnostics = {
|
|
|
6630
6631
|
Compiler_option_0_may_only_be_used_with_build: diag(5093, 1 /* Error */, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."),
|
|
6631
6632
|
Compiler_option_0_may_not_be_used_with_build: diag(5094, 1 /* Error */, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."),
|
|
6632
6633
|
Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later: diag(5095, 1 /* Error */, "Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later_5095", "Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later."),
|
|
6634
|
+
Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_hybrid_and_either_noEmit_or_emitDeclarationOnly_is_set: diag(5096, 1 /* Error */, "Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_hybrid_and_either_5096", "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set."),
|
|
6635
|
+
An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled: diag(5097, 1 /* Error */, "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097", "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled."),
|
|
6636
|
+
Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid: diag(5098, 1 /* Error */, "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid_5098", "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'."),
|
|
6637
|
+
Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_hybrid_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(5099, 1 /* Error */, "Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_hybrid_Consider_using_import_Asteri_5099", `Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.`),
|
|
6638
|
+
Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_hybrid_Consider_using_export_default_or_another_module_format_instead: diag(5100, 1 /* Error */, "Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_hybrid_Consider_using_export_defaul_5100", "Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead."),
|
|
6633
6639
|
Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6e3, 3 /* Message */, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."),
|
|
6634
6640
|
Concatenate_and_emit_output_to_single_file: diag(6001, 3 /* Message */, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."),
|
|
6635
6641
|
Generates_corresponding_d_ts_file: diag(6002, 3 /* Message */, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
|
|
@@ -6685,7 +6691,6 @@ var Diagnostics = {
|
|
|
6685
6691
|
Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, 1 /* Error */, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."),
|
|
6686
6692
|
Enables_experimental_support_for_ES7_decorators: diag(6065, 3 /* Message */, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
|
|
6687
6693
|
Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, 3 /* Message */, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."),
|
|
6688
|
-
Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: diag(6069, 3 /* Message */, "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)."),
|
|
6689
6694
|
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: diag(6070, 3 /* Message */, "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", "Initializes a TypeScript project and creates a tsconfig.json file."),
|
|
6690
6695
|
Successfully_created_a_tsconfig_json_file: diag(6071, 3 /* Message */, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
|
|
6691
6696
|
Suppress_excess_property_checks_for_object_literals: diag(6072, 3 /* Message */, "Suppress_excess_property_checks_for_object_literals_6072", "Suppress excess property checks for object literals."),
|
|
@@ -6929,6 +6934,11 @@ var Diagnostics = {
|
|
|
6929
6934
|
Using_0_subpath_1_with_target_2: diag(6404, 3 /* Message */, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."),
|
|
6930
6935
|
Saw_non_matching_condition_0: diag(6405, 3 /* Message */, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
|
|
6931
6936
|
Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions: diag(6406, 3 /* Message */, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions_6406", "Project '{0}' is out of date because buildinfo file '{1}' indicates there is change in compilerOptions"),
|
|
6937
|
+
Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEmit_or_emitDeclarationOnly_to_be_set: diag(6407, 3 /* Message */, "Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEm_6407", "Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set."),
|
|
6938
|
+
Use_the_package_json_exports_field_when_resolving_package_imports: diag(6408, 3 /* Message */, "Use_the_package_json_exports_field_when_resolving_package_imports_6408", "Use the package.json 'exports' field when resolving package imports."),
|
|
6939
|
+
Use_the_package_json_imports_field_when_resolving_imports: diag(6409, 3 /* Message */, "Use_the_package_json_imports_field_when_resolving_imports_6409", "Use the package.json 'imports' field when resolving imports."),
|
|
6940
|
+
Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports: diag(6410, 3 /* Message */, "Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports_6410", "Conditions to set in addition to the resolver-specific defaults when resolving imports."),
|
|
6941
|
+
true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false: diag(6411, 3 /* Message */, "true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false_6411", "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'hybrid'; otherwise `false`."),
|
|
6932
6942
|
The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, 3 /* Message */, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
|
|
6933
6943
|
The_expected_type_comes_from_this_index_signature: diag(6501, 3 /* Message */, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
|
|
6934
6944
|
The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, 3 /* Message */, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
|
|
@@ -12102,12 +12112,18 @@ function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
|
|
|
12102
12112
|
const arg = args[0];
|
|
12103
12113
|
return !requireStringLiteralLikeArgument || isStringLiteralLike(arg);
|
|
12104
12114
|
}
|
|
12115
|
+
function isVariableDeclarationInitializedToRequire(node) {
|
|
12116
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, false);
|
|
12117
|
+
}
|
|
12105
12118
|
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
|
|
12106
12119
|
return isVariableDeclarationInitializedWithRequireHelper(node, true);
|
|
12107
12120
|
}
|
|
12108
12121
|
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
12109
12122
|
return isVariableDeclaration(node) && !!node.initializer && isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, true);
|
|
12110
12123
|
}
|
|
12124
|
+
function isRequireVariableStatement(node) {
|
|
12125
|
+
return isVariableStatement(node) && node.declarationList.declarations.length > 0 && every(node.declarationList.declarations, (decl) => isVariableDeclarationInitializedToRequire(decl));
|
|
12126
|
+
}
|
|
12111
12127
|
function isSingleOrDoubleQuote(charCode) {
|
|
12112
12128
|
return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
|
|
12113
12129
|
}
|
|
@@ -14669,6 +14685,9 @@ function getEmitScriptTarget(compilerOptions) {
|
|
|
14669
14685
|
function getEmitModuleKind(compilerOptions) {
|
|
14670
14686
|
return typeof compilerOptions.module === "number" ? compilerOptions.module : getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? 5 /* ES2015 */ : 1 /* CommonJS */;
|
|
14671
14687
|
}
|
|
14688
|
+
function emitModuleKindIsNonNodeESM(moduleKind) {
|
|
14689
|
+
return moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */;
|
|
14690
|
+
}
|
|
14672
14691
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
14673
14692
|
let moduleResolution = compilerOptions.moduleResolution;
|
|
14674
14693
|
if (moduleResolution === void 0) {
|
|
@@ -14728,8 +14747,19 @@ function getESModuleInterop(compilerOptions) {
|
|
|
14728
14747
|
return void 0;
|
|
14729
14748
|
}
|
|
14730
14749
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
14731
|
-
|
|
14732
|
-
|
|
14750
|
+
if (compilerOptions.allowSyntheticDefaultImports !== void 0) {
|
|
14751
|
+
return compilerOptions.allowSyntheticDefaultImports;
|
|
14752
|
+
}
|
|
14753
|
+
return getESModuleInterop(compilerOptions) || getEmitModuleKind(compilerOptions) === 4 /* System */ || getEmitModuleResolutionKind(compilerOptions) === 100 /* Hybrid */;
|
|
14754
|
+
}
|
|
14755
|
+
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
|
|
14756
|
+
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Hybrid */;
|
|
14757
|
+
}
|
|
14758
|
+
function getResolveJsonModule(compilerOptions) {
|
|
14759
|
+
if (compilerOptions.resolveJsonModule !== void 0) {
|
|
14760
|
+
return compilerOptions.resolveJsonModule;
|
|
14761
|
+
}
|
|
14762
|
+
return getEmitModuleResolutionKind(compilerOptions) === 100 /* Hybrid */;
|
|
14733
14763
|
}
|
|
14734
14764
|
function getEmitDeclarations(compilerOptions) {
|
|
14735
14765
|
return !!(compilerOptions.declaration || compilerOptions.composite);
|
|
@@ -15083,7 +15113,7 @@ function getSupportedExtensions(options, extraFileExtensions) {
|
|
|
15083
15113
|
return extensions;
|
|
15084
15114
|
}
|
|
15085
15115
|
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
|
|
15086
|
-
if (!options || !options
|
|
15116
|
+
if (!options || !getResolveJsonModule(options))
|
|
15087
15117
|
return supportedExtensions;
|
|
15088
15118
|
if (supportedExtensions === allSupportedExtensions)
|
|
15089
15119
|
return allSupportedExtensionsWithJson;
|
|
@@ -15100,6 +15130,59 @@ function hasJSFileExtension(fileName) {
|
|
|
15100
15130
|
function hasTSFileExtension(fileName) {
|
|
15101
15131
|
return some(supportedTSExtensionsFlat, (extension) => fileExtensionIs(fileName, extension));
|
|
15102
15132
|
}
|
|
15133
|
+
function usesExtensionsOnImports({ imports }, hasExtension2 = or(hasJSFileExtension, hasTSFileExtension)) {
|
|
15134
|
+
return firstDefined(imports, ({ text }) => pathIsRelative(text) ? hasExtension2(text) : void 0) || false;
|
|
15135
|
+
}
|
|
15136
|
+
function getModuleSpecifierEndingPreference(preference, resolutionMode, compilerOptions, sourceFile) {
|
|
15137
|
+
if (preference === "js" || resolutionMode === 99 /* ESNext */) {
|
|
15138
|
+
if (!shouldAllowImportingTsExtension(compilerOptions)) {
|
|
15139
|
+
return 2 /* JsExtension */;
|
|
15140
|
+
}
|
|
15141
|
+
return inferPreference() !== 2 /* JsExtension */ ? 3 /* TsExtension */ : 2 /* JsExtension */;
|
|
15142
|
+
}
|
|
15143
|
+
if (preference === "minimal") {
|
|
15144
|
+
return 0 /* Minimal */;
|
|
15145
|
+
}
|
|
15146
|
+
if (preference === "index") {
|
|
15147
|
+
return 1 /* Index */;
|
|
15148
|
+
}
|
|
15149
|
+
if (!shouldAllowImportingTsExtension(compilerOptions)) {
|
|
15150
|
+
return usesExtensionsOnImports(sourceFile) ? 2 /* JsExtension */ : 0 /* Minimal */;
|
|
15151
|
+
}
|
|
15152
|
+
return inferPreference();
|
|
15153
|
+
function inferPreference() {
|
|
15154
|
+
let usesJsExtensions = false;
|
|
15155
|
+
const specifiers = sourceFile.imports.length ? sourceFile.imports.map((i) => i.text) : isSourceFileJS(sourceFile) ? getRequiresAtTopOfFile(sourceFile).map((r) => r.arguments[0].text) : emptyArray;
|
|
15156
|
+
for (const specifier of specifiers) {
|
|
15157
|
+
if (pathIsRelative(specifier)) {
|
|
15158
|
+
if (hasTSFileExtension(specifier)) {
|
|
15159
|
+
return 3 /* TsExtension */;
|
|
15160
|
+
}
|
|
15161
|
+
if (hasJSFileExtension(specifier)) {
|
|
15162
|
+
usesJsExtensions = true;
|
|
15163
|
+
}
|
|
15164
|
+
}
|
|
15165
|
+
}
|
|
15166
|
+
return usesJsExtensions ? 2 /* JsExtension */ : 0 /* Minimal */;
|
|
15167
|
+
}
|
|
15168
|
+
}
|
|
15169
|
+
function getRequiresAtTopOfFile(sourceFile) {
|
|
15170
|
+
let nonRequireStatementCount = 0;
|
|
15171
|
+
let requires;
|
|
15172
|
+
for (const statement of sourceFile.statements) {
|
|
15173
|
+
if (nonRequireStatementCount > 3) {
|
|
15174
|
+
break;
|
|
15175
|
+
}
|
|
15176
|
+
if (isRequireVariableStatement(statement)) {
|
|
15177
|
+
requires = concatenate(requires, statement.declarationList.declarations.map((d) => d.initializer));
|
|
15178
|
+
} else if (isExpressionStatement(statement) && isRequireCall(statement.expression, true)) {
|
|
15179
|
+
requires = append(requires, statement.expression);
|
|
15180
|
+
} else {
|
|
15181
|
+
nonRequireStatementCount++;
|
|
15182
|
+
}
|
|
15183
|
+
}
|
|
15184
|
+
return requires || emptyArray;
|
|
15185
|
+
}
|
|
15103
15186
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
15104
15187
|
if (!fileName)
|
|
15105
15188
|
return false;
|
|
@@ -24381,7 +24464,7 @@ var Parser;
|
|
|
24381
24464
|
case ParsingContext.ArrayBindingElements:
|
|
24382
24465
|
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
|
24383
24466
|
case ParsingContext.TypeParameters:
|
|
24384
|
-
return token() === 101 /* InKeyword */ ||
|
|
24467
|
+
return token() === 101 /* InKeyword */ || isIdentifier2();
|
|
24385
24468
|
case ParsingContext.ArrayLiteralMembers:
|
|
24386
24469
|
switch (token()) {
|
|
24387
24470
|
case 27 /* CommaToken */:
|
|
@@ -25086,7 +25169,7 @@ var Parser;
|
|
|
25086
25169
|
}
|
|
25087
25170
|
function parseTypeParameter() {
|
|
25088
25171
|
const pos = getNodePos();
|
|
25089
|
-
const modifiers = parseModifiers(
|
|
25172
|
+
const modifiers = parseModifiers();
|
|
25090
25173
|
const name = parseIdentifier();
|
|
25091
25174
|
let constraint;
|
|
25092
25175
|
let expression;
|
|
@@ -27803,10 +27886,10 @@ var Parser;
|
|
|
27803
27886
|
setTextRangePosEnd(decoratorsAndModifiers, decorators.pos, modifiers.end);
|
|
27804
27887
|
return decoratorsAndModifiers;
|
|
27805
27888
|
}
|
|
27806
|
-
function parseModifiers(
|
|
27889
|
+
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
27807
27890
|
const pos = getNodePos();
|
|
27808
27891
|
let list, modifier, hasSeenStatic = false;
|
|
27809
|
-
while (modifier = tryParseModifier(
|
|
27892
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
27810
27893
|
if (modifier.kind === 124 /* StaticKeyword */)
|
|
27811
27894
|
hasSeenStatic = true;
|
|
27812
27895
|
list = append(list, modifier);
|
|
@@ -30522,7 +30605,8 @@ var commandOptionsWithoutBuild = [
|
|
|
30522
30605
|
node: 2 /* NodeJs */,
|
|
30523
30606
|
classic: 1 /* Classic */,
|
|
30524
30607
|
node16: 3 /* Node16 */,
|
|
30525
|
-
nodenext: 99 /* NodeNext
|
|
30608
|
+
nodenext: 99 /* NodeNext */,
|
|
30609
|
+
hybrid: 100 /* Hybrid */
|
|
30526
30610
|
})),
|
|
30527
30611
|
affectsModuleResolution: true,
|
|
30528
30612
|
paramType: Diagnostics.STRATEGY,
|
|
@@ -30635,6 +30719,41 @@ var commandOptionsWithoutBuild = [
|
|
|
30635
30719
|
category: Diagnostics.Modules,
|
|
30636
30720
|
description: Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module
|
|
30637
30721
|
},
|
|
30722
|
+
{
|
|
30723
|
+
name: "allowImportingTsExtensions",
|
|
30724
|
+
type: "boolean",
|
|
30725
|
+
affectsModuleResolution: true,
|
|
30726
|
+
category: Diagnostics.Modules,
|
|
30727
|
+
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
|
|
30728
|
+
defaultValueDescription: false
|
|
30729
|
+
},
|
|
30730
|
+
{
|
|
30731
|
+
name: "resolvePackageJsonExports",
|
|
30732
|
+
type: "boolean",
|
|
30733
|
+
affectsModuleResolution: true,
|
|
30734
|
+
category: Diagnostics.Modules,
|
|
30735
|
+
description: Diagnostics.Use_the_package_json_exports_field_when_resolving_package_imports,
|
|
30736
|
+
defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false
|
|
30737
|
+
},
|
|
30738
|
+
{
|
|
30739
|
+
name: "resolvePackageJsonImports",
|
|
30740
|
+
type: "boolean",
|
|
30741
|
+
affectsModuleResolution: true,
|
|
30742
|
+
category: Diagnostics.Modules,
|
|
30743
|
+
description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports,
|
|
30744
|
+
defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false
|
|
30745
|
+
},
|
|
30746
|
+
{
|
|
30747
|
+
name: "customConditions",
|
|
30748
|
+
type: "list",
|
|
30749
|
+
element: {
|
|
30750
|
+
name: "condition",
|
|
30751
|
+
type: "string"
|
|
30752
|
+
},
|
|
30753
|
+
affectsModuleResolution: true,
|
|
30754
|
+
category: Diagnostics.Modules,
|
|
30755
|
+
description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports
|
|
30756
|
+
},
|
|
30638
30757
|
{
|
|
30639
30758
|
name: "sourceRoot",
|
|
30640
30759
|
type: "string",
|
|
@@ -32673,7 +32792,7 @@ function withPackageId(packageInfo, r) {
|
|
|
32673
32792
|
};
|
|
32674
32793
|
}
|
|
32675
32794
|
}
|
|
32676
|
-
return r && { path: r.path, extension: r.ext, packageId };
|
|
32795
|
+
return r && { path: r.path, extension: r.ext, packageId, resolvedUsingTsExtension: r.resolvedUsingTsExtension };
|
|
32677
32796
|
}
|
|
32678
32797
|
function noPackageId(r) {
|
|
32679
32798
|
return withPackageId(void 0, r);
|
|
@@ -32681,7 +32800,7 @@ function noPackageId(r) {
|
|
|
32681
32800
|
function removeIgnoredPackageId(r) {
|
|
32682
32801
|
if (r) {
|
|
32683
32802
|
Debug.assert(r.packageId === void 0);
|
|
32684
|
-
return { path: r.path, ext: r.extension };
|
|
32803
|
+
return { path: r.path, ext: r.extension, resolvedUsingTsExtension: r.resolvedUsingTsExtension };
|
|
32685
32804
|
}
|
|
32686
32805
|
}
|
|
32687
32806
|
function formatExtensions(extensions) {
|
|
@@ -32711,7 +32830,14 @@ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibra
|
|
|
32711
32830
|
return resultFromCache;
|
|
32712
32831
|
}
|
|
32713
32832
|
return {
|
|
32714
|
-
resolvedModule: resolved && {
|
|
32833
|
+
resolvedModule: resolved && {
|
|
32834
|
+
resolvedFileName: resolved.path,
|
|
32835
|
+
originalPath: resolved.originalPath === true ? void 0 : resolved.originalPath,
|
|
32836
|
+
extension: resolved.extension,
|
|
32837
|
+
isExternalLibraryImport,
|
|
32838
|
+
packageId: resolved.packageId,
|
|
32839
|
+
resolvedUsingTsExtension: !!resolved.resolvedUsingTsExtension
|
|
32840
|
+
},
|
|
32715
32841
|
failedLookupLocations: initializeResolutionField(failedLookupLocations),
|
|
32716
32842
|
affectingLocations: initializeResolutionField(affectingLocations),
|
|
32717
32843
|
resolutionDiagnostics: initializeResolutionField(diagnostics)
|
|
@@ -32897,11 +33023,11 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
32897
33023
|
}
|
|
32898
33024
|
const failedLookupLocations = [];
|
|
32899
33025
|
const affectingLocations = [];
|
|
32900
|
-
let features =
|
|
33026
|
+
let features = getNodeResolutionFeatures(options);
|
|
32901
33027
|
if (resolutionMode === 99 /* ESNext */ && (getEmitModuleResolutionKind(options) === 3 /* Node16 */ || getEmitModuleResolutionKind(options) === 99 /* NodeNext */)) {
|
|
32902
33028
|
features |= NodeResolutionFeatures.EsmMode;
|
|
32903
33029
|
}
|
|
32904
|
-
const conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode
|
|
33030
|
+
const conditions = features & NodeResolutionFeatures.Exports ? getConditions(options, !!(features & NodeResolutionFeatures.EsmMode)) : [];
|
|
32905
33031
|
const diagnostics = [];
|
|
32906
33032
|
const moduleResolutionState = {
|
|
32907
33033
|
compilerOptions: options,
|
|
@@ -33009,8 +33135,37 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
33009
33135
|
}
|
|
33010
33136
|
}
|
|
33011
33137
|
}
|
|
33012
|
-
function
|
|
33013
|
-
|
|
33138
|
+
function getNodeResolutionFeatures(options) {
|
|
33139
|
+
let features = NodeResolutionFeatures.None;
|
|
33140
|
+
switch (getEmitModuleResolutionKind(options)) {
|
|
33141
|
+
case 3 /* Node16 */:
|
|
33142
|
+
features = NodeResolutionFeatures.Node16Default;
|
|
33143
|
+
break;
|
|
33144
|
+
case 99 /* NodeNext */:
|
|
33145
|
+
features = NodeResolutionFeatures.NodeNextDefault;
|
|
33146
|
+
break;
|
|
33147
|
+
case 100 /* Hybrid */:
|
|
33148
|
+
features = NodeResolutionFeatures.HybridDefault;
|
|
33149
|
+
break;
|
|
33150
|
+
}
|
|
33151
|
+
if (options.resolvePackageJsonExports) {
|
|
33152
|
+
features |= NodeResolutionFeatures.Exports;
|
|
33153
|
+
} else if (options.resolvePackageJsonExports === false) {
|
|
33154
|
+
features &= ~NodeResolutionFeatures.Exports;
|
|
33155
|
+
}
|
|
33156
|
+
if (options.resolvePackageJsonImports) {
|
|
33157
|
+
features |= NodeResolutionFeatures.Imports;
|
|
33158
|
+
} else if (options.resolvePackageJsonImports === false) {
|
|
33159
|
+
features &= ~NodeResolutionFeatures.Imports;
|
|
33160
|
+
}
|
|
33161
|
+
return features;
|
|
33162
|
+
}
|
|
33163
|
+
function getConditions(options, esmMode) {
|
|
33164
|
+
const conditions = esmMode || getEmitModuleResolutionKind(options) === 100 /* Hybrid */ ? ["node", "import"] : ["node", "require"];
|
|
33165
|
+
if (!options.noDtsResolution) {
|
|
33166
|
+
conditions.push("types");
|
|
33167
|
+
}
|
|
33168
|
+
return concatenate(conditions, options.customConditions);
|
|
33014
33169
|
}
|
|
33015
33170
|
function getAutomaticTypeDirectiveNames(options, host) {
|
|
33016
33171
|
if (options.types) {
|
|
@@ -33411,6 +33566,9 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
|
|
|
33411
33566
|
case 1 /* Classic */:
|
|
33412
33567
|
result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
33413
33568
|
break;
|
|
33569
|
+
case 100 /* Hybrid */:
|
|
33570
|
+
result = hybridModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
33571
|
+
break;
|
|
33414
33572
|
default:
|
|
33415
33573
|
return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
|
|
33416
33574
|
}
|
|
@@ -33549,6 +33707,7 @@ var NodeResolutionFeatures = /* @__PURE__ */ ((NodeResolutionFeatures2) => {
|
|
|
33549
33707
|
NodeResolutionFeatures2[NodeResolutionFeatures2["AllFeatures"] = 30] = "AllFeatures";
|
|
33550
33708
|
NodeResolutionFeatures2[NodeResolutionFeatures2["Node16Default"] = 30] = "Node16Default";
|
|
33551
33709
|
NodeResolutionFeatures2[NodeResolutionFeatures2["NodeNextDefault"] = 30 /* AllFeatures */] = "NodeNextDefault";
|
|
33710
|
+
NodeResolutionFeatures2[NodeResolutionFeatures2["HybridDefault"] = 30] = "HybridDefault";
|
|
33552
33711
|
NodeResolutionFeatures2[NodeResolutionFeatures2["EsmMode"] = 32] = "EsmMode";
|
|
33553
33712
|
return NodeResolutionFeatures2;
|
|
33554
33713
|
})(NodeResolutionFeatures || {});
|
|
@@ -33580,7 +33739,7 @@ function nodeNextModuleNameResolverWorker(features, moduleName, containingFile,
|
|
|
33580
33739
|
const containingDirectory = getDirectoryPath(containingFile);
|
|
33581
33740
|
const esmMode = resolutionMode === 99 /* ESNext */ ? 32 /* EsmMode */ : 0;
|
|
33582
33741
|
let extensions = compilerOptions.noDtsResolution ? 3 /* ImplementationFiles */ : 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */;
|
|
33583
|
-
if (compilerOptions
|
|
33742
|
+
if (getResolveJsonModule(compilerOptions)) {
|
|
33584
33743
|
extensions |= 8 /* Json */;
|
|
33585
33744
|
}
|
|
33586
33745
|
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, false, redirectedReference);
|
|
@@ -33598,16 +33757,24 @@ function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
|
33598
33757
|
void 0
|
|
33599
33758
|
);
|
|
33600
33759
|
}
|
|
33760
|
+
function hybridModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
33761
|
+
const containingDirectory = getDirectoryPath(containingFile);
|
|
33762
|
+
let extensions = compilerOptions.noDtsResolution ? 3 /* ImplementationFiles */ : 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */;
|
|
33763
|
+
if (getResolveJsonModule(compilerOptions)) {
|
|
33764
|
+
extensions |= 8 /* Json */;
|
|
33765
|
+
}
|
|
33766
|
+
return nodeModuleNameResolverWorker(getNodeResolutionFeatures(compilerOptions), moduleName, containingDirectory, compilerOptions, host, cache, extensions, false, redirectedReference);
|
|
33767
|
+
}
|
|
33601
33768
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, isConfigLookup) {
|
|
33602
33769
|
let extensions;
|
|
33603
33770
|
if (isConfigLookup) {
|
|
33604
33771
|
extensions = 8 /* Json */;
|
|
33605
33772
|
} else if (compilerOptions.noDtsResolution) {
|
|
33606
33773
|
extensions = 3 /* ImplementationFiles */;
|
|
33607
|
-
if (compilerOptions
|
|
33774
|
+
if (getResolveJsonModule(compilerOptions))
|
|
33608
33775
|
extensions |= 8 /* Json */;
|
|
33609
33776
|
} else {
|
|
33610
|
-
extensions = compilerOptions
|
|
33777
|
+
extensions = getResolveJsonModule(compilerOptions) ? 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */ | 8 /* Json */ : 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */;
|
|
33611
33778
|
}
|
|
33612
33779
|
return nodeModuleNameResolverWorker(0 /* None */, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, !!isConfigLookup, redirectedReference);
|
|
33613
33780
|
}
|
|
@@ -33616,10 +33783,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
33616
33783
|
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
33617
33784
|
const failedLookupLocations = [];
|
|
33618
33785
|
const affectingLocations = [];
|
|
33619
|
-
const conditions = features & 32 /* EsmMode */
|
|
33620
|
-
if (compilerOptions.noDtsResolution) {
|
|
33621
|
-
conditions.pop();
|
|
33622
|
-
}
|
|
33786
|
+
const conditions = getConditions(compilerOptions, !!(features & 32 /* EsmMode */));
|
|
33623
33787
|
const diagnostics = [];
|
|
33624
33788
|
const state = {
|
|
33625
33789
|
compilerOptions,
|
|
@@ -33780,7 +33944,7 @@ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
|
|
|
33780
33944
|
}
|
|
33781
33945
|
}
|
|
33782
33946
|
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
33783
|
-
if (hasJSFileExtension(candidate) || extensions & 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */)) {
|
|
33947
|
+
if (hasJSFileExtension(candidate) || extensions & 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */) || extensions & (1 /* TypeScript */ | 4 /* Declaration */) && moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) {
|
|
33784
33948
|
const extensionless = removeFileExtension(candidate);
|
|
33785
33949
|
const extension = candidate.substring(extensionless.length);
|
|
33786
33950
|
if (state.traceEnabled) {
|
|
@@ -33792,7 +33956,7 @@ function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecor
|
|
|
33792
33956
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
33793
33957
|
if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
|
|
33794
33958
|
const result = tryFile(candidate, onlyRecordFailures, state);
|
|
33795
|
-
return result !== void 0 ? { path: candidate, ext: tryExtractTSExtension(candidate) } : void 0;
|
|
33959
|
+
return result !== void 0 ? { path: candidate, ext: tryExtractTSExtension(candidate), resolvedUsingTsExtension: void 0 } : void 0;
|
|
33796
33960
|
}
|
|
33797
33961
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
33798
33962
|
}
|
|
@@ -33827,12 +33991,18 @@ function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecor
|
|
|
33827
33991
|
return result;
|
|
33828
33992
|
}
|
|
33829
33993
|
return void 0;
|
|
33994
|
+
case ".ts" /* Ts */:
|
|
33995
|
+
case ".tsx" /* Tsx */:
|
|
33996
|
+
case ".d.ts" /* Dts */:
|
|
33997
|
+
if (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && extensionIsOk(extensions, originalExtension)) {
|
|
33998
|
+
return tryExtension(originalExtension, true);
|
|
33999
|
+
}
|
|
33830
34000
|
default:
|
|
33831
34001
|
return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
|
|
33832
34002
|
}
|
|
33833
|
-
function tryExtension(ext) {
|
|
34003
|
+
function tryExtension(ext, resolvedUsingTsExtension) {
|
|
33834
34004
|
const path = tryFile(candidate + ext, onlyRecordFailures, state);
|
|
33835
|
-
return path === void 0 ? void 0 : { path, ext };
|
|
34005
|
+
return path === void 0 ? void 0 : { path, ext, resolvedUsingTsExtension };
|
|
33836
34006
|
}
|
|
33837
34007
|
}
|
|
33838
34008
|
function tryFile(fileName, onlyRecordFailures, state) {
|
|
@@ -33988,9 +34158,9 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
|
|
|
33988
34158
|
return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
|
|
33989
34159
|
}
|
|
33990
34160
|
}
|
|
33991
|
-
function resolvedIfExtensionMatches(extensions, path) {
|
|
34161
|
+
function resolvedIfExtensionMatches(extensions, path, resolvedUsingTsExtension) {
|
|
33992
34162
|
const ext = tryGetExtensionFromPath2(path);
|
|
33993
|
-
return ext !== void 0 && extensionIsOk(extensions, ext) ? { path, ext } : void 0;
|
|
34163
|
+
return ext !== void 0 && extensionIsOk(extensions, ext) ? { path, ext, resolvedUsingTsExtension } : void 0;
|
|
33994
34164
|
}
|
|
33995
34165
|
function extensionIsOk(extensions, extension) {
|
|
33996
34166
|
return extensions & 2 /* JavaScript */ && (extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */) || extensions & 1 /* TypeScript */ && (extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */) || extensions & 4 /* Declaration */ && (extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */) || extensions & 8 /* Json */ && extension === ".json" /* Json */ || false;
|
|
@@ -34156,7 +34326,13 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
34156
34326
|
traceIfEnabled(state, Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
|
|
34157
34327
|
traceIfEnabled(state, Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
|
|
34158
34328
|
const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, extensions, false, redirectedReference);
|
|
34159
|
-
return toSearchResult(result.resolvedModule ? {
|
|
34329
|
+
return toSearchResult(result.resolvedModule ? {
|
|
34330
|
+
path: result.resolvedModule.resolvedFileName,
|
|
34331
|
+
extension: result.resolvedModule.extension,
|
|
34332
|
+
packageId: result.resolvedModule.packageId,
|
|
34333
|
+
originalPath: result.resolvedModule.originalPath,
|
|
34334
|
+
resolvedUsingTsExtension: result.resolvedModule.resolvedUsingTsExtension
|
|
34335
|
+
} : void 0);
|
|
34160
34336
|
}
|
|
34161
34337
|
if (state.traceEnabled) {
|
|
34162
34338
|
trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
@@ -34451,7 +34627,7 @@ function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, p
|
|
|
34451
34627
|
if (extension !== void 0) {
|
|
34452
34628
|
const path2 = tryFile(candidate, onlyRecordFailures, state);
|
|
34453
34629
|
if (path2 !== void 0) {
|
|
34454
|
-
return noPackageId({ path: path2, ext: extension });
|
|
34630
|
+
return noPackageId({ path: path2, ext: extension, resolvedUsingTsExtension: void 0 });
|
|
34455
34631
|
}
|
|
34456
34632
|
}
|
|
34457
34633
|
return loader(extensions, candidate, onlyRecordFailures || !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);
|
|
@@ -34496,7 +34672,15 @@ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containing
|
|
|
34496
34672
|
trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
34497
34673
|
}
|
|
34498
34674
|
state.resultFromCache = result;
|
|
34499
|
-
return {
|
|
34675
|
+
return {
|
|
34676
|
+
value: result.resolvedModule && {
|
|
34677
|
+
path: result.resolvedModule.resolvedFileName,
|
|
34678
|
+
originalPath: result.resolvedModule.originalPath || true,
|
|
34679
|
+
extension: result.resolvedModule.extension,
|
|
34680
|
+
packageId: result.resolvedModule.packageId,
|
|
34681
|
+
resolvedUsingTsExtension: result.resolvedModule.resolvedUsingTsExtension
|
|
34682
|
+
}
|
|
34683
|
+
};
|
|
34500
34684
|
}
|
|
34501
34685
|
}
|
|
34502
34686
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
@@ -34553,6 +34737,12 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
34553
34737
|
}
|
|
34554
34738
|
}
|
|
34555
34739
|
}
|
|
34740
|
+
function moduleResolutionSupportsResolvingTsExtensions(compilerOptions) {
|
|
34741
|
+
return getEmitModuleResolutionKind(compilerOptions) === 100 /* Hybrid */;
|
|
34742
|
+
}
|
|
34743
|
+
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
34744
|
+
return moduleResolutionSupportsResolvingTsExtensions(compilerOptions) && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
|
|
34745
|
+
}
|
|
34556
34746
|
function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) {
|
|
34557
34747
|
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
34558
34748
|
if (traceEnabled) {
|
|
@@ -37089,7 +37279,7 @@ function createBinder() {
|
|
|
37089
37279
|
}
|
|
37090
37280
|
if (!isBindingPattern(node.name)) {
|
|
37091
37281
|
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
|
|
37092
|
-
if (isInJSFile(node) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
|
|
37282
|
+
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Hybrid */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
|
|
37093
37283
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
37094
37284
|
} else if (isBlockOrCatchScoped(node)) {
|
|
37095
37285
|
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
|
|
@@ -37416,44 +37606,51 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
|
|
|
37416
37606
|
}
|
|
37417
37607
|
|
|
37418
37608
|
// src/compiler/moduleSpecifiers.ts
|
|
37419
|
-
function getPreferences(
|
|
37609
|
+
function getPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
|
37610
|
+
const preferredEnding = getPreferredEnding();
|
|
37420
37611
|
return {
|
|
37421
|
-
relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */,
|
|
37422
|
-
|
|
37612
|
+
relativePreference: oldImportSpecifier !== void 0 ? isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */ : importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */,
|
|
37613
|
+
getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
|
|
37614
|
+
if ((syntaxImpliedNodeFormat != null ? syntaxImpliedNodeFormat : importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
|
|
37615
|
+
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
|
37616
|
+
return [3 /* TsExtension */, 2 /* JsExtension */];
|
|
37617
|
+
}
|
|
37618
|
+
return [2 /* JsExtension */];
|
|
37619
|
+
}
|
|
37620
|
+
if (getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */) {
|
|
37621
|
+
return [1 /* Index */, 2 /* JsExtension */];
|
|
37622
|
+
}
|
|
37623
|
+
switch (preferredEnding) {
|
|
37624
|
+
case 2 /* JsExtension */:
|
|
37625
|
+
return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
37626
|
+
case 3 /* TsExtension */:
|
|
37627
|
+
return [3 /* TsExtension */, 0 /* Minimal */, 2 /* JsExtension */, 1 /* Index */];
|
|
37628
|
+
case 1 /* Index */:
|
|
37629
|
+
return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
37630
|
+
case 0 /* Minimal */:
|
|
37631
|
+
return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
37632
|
+
default:
|
|
37633
|
+
Debug.assertNever(preferredEnding);
|
|
37634
|
+
}
|
|
37635
|
+
}
|
|
37423
37636
|
};
|
|
37424
|
-
function
|
|
37425
|
-
|
|
37426
|
-
|
|
37427
|
-
return 0 /* Minimal */;
|
|
37428
|
-
case "index":
|
|
37429
|
-
return 1 /* Index */;
|
|
37430
|
-
case "js":
|
|
37637
|
+
function getPreferredEnding() {
|
|
37638
|
+
if (oldImportSpecifier !== void 0) {
|
|
37639
|
+
if (hasJSFileExtension(oldImportSpecifier))
|
|
37431
37640
|
return 2 /* JsExtension */;
|
|
37432
|
-
|
|
37433
|
-
return
|
|
37641
|
+
if (endsWith(oldImportSpecifier, "/index"))
|
|
37642
|
+
return 1 /* Index */;
|
|
37434
37643
|
}
|
|
37644
|
+
return getModuleSpecifierEndingPreference(
|
|
37645
|
+
importModuleSpecifierEnding,
|
|
37646
|
+
importingSourceFile.impliedNodeFormat,
|
|
37647
|
+
compilerOptions,
|
|
37648
|
+
importingSourceFile
|
|
37649
|
+
);
|
|
37435
37650
|
}
|
|
37436
37651
|
}
|
|
37437
|
-
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
37438
|
-
var _a2;
|
|
37439
|
-
if (getEmitModuleResolutionKind(compilerOptions) !== 3 /* Node16 */ && getEmitModuleResolutionKind(compilerOptions) !== 99 /* NodeNext */) {
|
|
37440
|
-
return false;
|
|
37441
|
-
}
|
|
37442
|
-
return getImpliedNodeFormatForFile(importingSourceFileName, (_a2 = host.getPackageJsonInfoCache) == null ? void 0 : _a2.call(host), getModuleResolutionHost(host), compilerOptions) !== 1 /* CommonJS */;
|
|
37443
|
-
}
|
|
37444
|
-
function getModuleResolutionHost(host) {
|
|
37445
|
-
var _a2;
|
|
37446
|
-
return {
|
|
37447
|
-
fileExists: host.fileExists,
|
|
37448
|
-
readFile: Debug.checkDefined(host.readFile),
|
|
37449
|
-
directoryExists: host.directoryExists,
|
|
37450
|
-
getCurrentDirectory: host.getCurrentDirectory,
|
|
37451
|
-
realpath: host.realpath,
|
|
37452
|
-
useCaseSensitiveFileNames: (_a2 = host.useCaseSensitiveFileNames) == null ? void 0 : _a2.call(host)
|
|
37453
|
-
};
|
|
37454
|
-
}
|
|
37455
37652
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, options = {}) {
|
|
37456
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getPreferences(
|
|
37653
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getPreferences({}, compilerOptions, importingSourceFile), {}, options);
|
|
37457
37654
|
}
|
|
37458
37655
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, preferences, userPreferences, options = {}) {
|
|
37459
37656
|
const info = getInfo(importingSourceFileName, host);
|
|
@@ -37505,7 +37702,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
|
|
37505
37702
|
}
|
|
37506
37703
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}) {
|
|
37507
37704
|
const info = getInfo(importingSourceFile.path, host);
|
|
37508
|
-
const preferences = getPreferences(
|
|
37705
|
+
const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
37509
37706
|
const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
|
|
37510
37707
|
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
|
37511
37708
|
(reason) => {
|
|
@@ -37561,13 +37758,14 @@ function getInfo(importingSourceFileName, host) {
|
|
|
37561
37758
|
const sourceDirectory = getDirectoryPath(importingSourceFileName);
|
|
37562
37759
|
return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
|
|
37563
37760
|
}
|
|
37564
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, {
|
|
37761
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }, pathsOnly) {
|
|
37565
37762
|
const { baseUrl, paths, rootDirs } = compilerOptions;
|
|
37566
37763
|
if (pathsOnly && !paths) {
|
|
37567
37764
|
return void 0;
|
|
37568
37765
|
}
|
|
37569
37766
|
const { sourceDirectory, getCanonicalFileName } = info;
|
|
37570
|
-
const
|
|
37767
|
+
const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
|
|
37768
|
+
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
|
|
37571
37769
|
if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
|
|
37572
37770
|
return pathsOnly ? void 0 : relativePath;
|
|
37573
37771
|
}
|
|
@@ -37576,11 +37774,11 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
37576
37774
|
if (!relativeToBaseUrl) {
|
|
37577
37775
|
return pathsOnly ? void 0 : relativePath;
|
|
37578
37776
|
}
|
|
37579
|
-
const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths,
|
|
37777
|
+
const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions);
|
|
37580
37778
|
if (pathsOnly) {
|
|
37581
37779
|
return fromPaths;
|
|
37582
37780
|
}
|
|
37583
|
-
const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ?
|
|
37781
|
+
const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths;
|
|
37584
37782
|
if (!maybeNonRelative) {
|
|
37585
37783
|
return relativePath;
|
|
37586
37784
|
}
|
|
@@ -37612,9 +37810,6 @@ function countPathComponents(path) {
|
|
|
37612
37810
|
}
|
|
37613
37811
|
return count;
|
|
37614
37812
|
}
|
|
37615
|
-
function usesJsExtensionOnImports({ imports }) {
|
|
37616
|
-
return firstDefined(imports, ({ text }) => pathIsRelative(text) ? hasJSFileExtension(text) : void 0) || false;
|
|
37617
|
-
}
|
|
37618
37813
|
function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
|
|
37619
37814
|
return compareBooleans(b.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b.path);
|
|
37620
37815
|
}
|
|
@@ -37764,21 +37959,6 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
|
|
|
37764
37959
|
return ambientModuleDeclare.name.text;
|
|
37765
37960
|
}
|
|
37766
37961
|
}
|
|
37767
|
-
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
37768
|
-
if (getEmitModuleResolutionKind(compilerOptions) >= 3 /* Node16 */ && importMode === 99 /* ESNext */) {
|
|
37769
|
-
return [2 /* JsExtension */];
|
|
37770
|
-
}
|
|
37771
|
-
switch (preferredEnding) {
|
|
37772
|
-
case 2 /* JsExtension */:
|
|
37773
|
-
return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
37774
|
-
case 1 /* Index */:
|
|
37775
|
-
return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
37776
|
-
case 0 /* Minimal */:
|
|
37777
|
-
return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
37778
|
-
default:
|
|
37779
|
-
Debug.assertNever(preferredEnding);
|
|
37780
|
-
}
|
|
37781
|
-
}
|
|
37782
37962
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
37783
37963
|
for (const key in paths) {
|
|
37784
37964
|
for (const patternText2 of paths[key]) {
|
|
@@ -37786,7 +37966,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
|
|
|
37786
37966
|
const indexOfStar = pattern.indexOf("*");
|
|
37787
37967
|
const candidates = allowedEndings.map((ending) => ({
|
|
37788
37968
|
ending,
|
|
37789
|
-
value:
|
|
37969
|
+
value: processEnding(relativeToBaseUrl, [ending], compilerOptions)
|
|
37790
37970
|
}));
|
|
37791
37971
|
if (tryGetExtensionFromPath2(pattern)) {
|
|
37792
37972
|
candidates.push({ ending: void 0, value: relativeToBaseUrl });
|
|
@@ -37806,7 +37986,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
|
|
|
37806
37986
|
}
|
|
37807
37987
|
}
|
|
37808
37988
|
function validateEnding({ ending, value }) {
|
|
37809
|
-
return ending !== 0 /* Minimal */ || value ===
|
|
37989
|
+
return ending !== 0 /* Minimal */ || value === processEnding(relativeToBaseUrl, [ending], compilerOptions, host);
|
|
37810
37990
|
}
|
|
37811
37991
|
}
|
|
37812
37992
|
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode = 0 /* Exact */) {
|
|
@@ -37862,7 +38042,7 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
|
|
|
37862
38042
|
}
|
|
37863
38043
|
return void 0;
|
|
37864
38044
|
}
|
|
37865
|
-
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName,
|
|
38045
|
+
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) {
|
|
37866
38046
|
const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
37867
38047
|
if (normalizedTargetPaths === void 0) {
|
|
37868
38048
|
return void 0;
|
|
@@ -37875,7 +38055,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
|
|
|
37875
38055
|
if (!shortest) {
|
|
37876
38056
|
return void 0;
|
|
37877
38057
|
}
|
|
37878
|
-
return
|
|
38058
|
+
return processEnding(shortest, allowedEndings, compilerOptions);
|
|
37879
38059
|
}
|
|
37880
38060
|
function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
37881
38061
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -37885,7 +38065,8 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
37885
38065
|
if (!parts) {
|
|
37886
38066
|
return void 0;
|
|
37887
38067
|
}
|
|
37888
|
-
const preferences = getPreferences(
|
|
38068
|
+
const preferences = getPreferences(userPreferences, options, importingSourceFile);
|
|
38069
|
+
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
|
37889
38070
|
let moduleSpecifier = path;
|
|
37890
38071
|
let isPackageRootPath = false;
|
|
37891
38072
|
if (!packageNameOnly) {
|
|
@@ -37910,7 +38091,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
37910
38091
|
moduleFileName = moduleFileToTry;
|
|
37911
38092
|
packageRootIndex = path.indexOf(directorySeparator, packageRootIndex + 1);
|
|
37912
38093
|
if (packageRootIndex === -1) {
|
|
37913
|
-
moduleSpecifier =
|
|
38094
|
+
moduleSpecifier = processEnding(moduleFileName, allowedEndings, options, host);
|
|
37914
38095
|
break;
|
|
37915
38096
|
}
|
|
37916
38097
|
}
|
|
@@ -37953,7 +38134,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
37953
38134
|
const fromPaths = tryGetModuleNameFromPaths(
|
|
37954
38135
|
subModuleName,
|
|
37955
38136
|
versionPaths.paths,
|
|
37956
|
-
|
|
38137
|
+
allowedEndings,
|
|
37957
38138
|
host,
|
|
37958
38139
|
options
|
|
37959
38140
|
);
|
|
@@ -37996,15 +38177,18 @@ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
|
37996
38177
|
return relativePath !== void 0 && isPathRelativeToParent(relativePath) ? void 0 : relativePath;
|
|
37997
38178
|
});
|
|
37998
38179
|
}
|
|
37999
|
-
function
|
|
38000
|
-
if (fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
38180
|
+
function processEnding(fileName, allowedEndings, options, host) {
|
|
38181
|
+
if (fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
|
|
38001
38182
|
return fileName;
|
|
38183
|
+
}
|
|
38002
38184
|
const noExtension = removeFileExtension(fileName);
|
|
38003
|
-
if (fileName === noExtension)
|
|
38185
|
+
if (fileName === noExtension) {
|
|
38004
38186
|
return fileName;
|
|
38005
|
-
|
|
38187
|
+
}
|
|
38188
|
+
if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
|
|
38006
38189
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
38007
|
-
|
|
38190
|
+
}
|
|
38191
|
+
switch (allowedEndings[0]) {
|
|
38008
38192
|
case 0 /* Minimal */:
|
|
38009
38193
|
const withoutIndex = removeSuffix(noExtension, "/index");
|
|
38010
38194
|
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
@@ -38015,8 +38199,15 @@ function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
|
38015
38199
|
return noExtension;
|
|
38016
38200
|
case 2 /* JsExtension */:
|
|
38017
38201
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
38202
|
+
case 3 /* TsExtension */:
|
|
38203
|
+
if (isDeclarationFileName(fileName)) {
|
|
38204
|
+
const extensionlessPriority = allowedEndings.findIndex((e) => e === 0 /* Minimal */ || e === 1 /* Index */);
|
|
38205
|
+
const jsPriority = allowedEndings.indexOf(2 /* JsExtension */);
|
|
38206
|
+
return extensionlessPriority !== -1 && extensionlessPriority < jsPriority ? noExtension : noExtension + getJSExtensionForFile(fileName, options);
|
|
38207
|
+
}
|
|
38208
|
+
return fileName;
|
|
38018
38209
|
default:
|
|
38019
|
-
return Debug.assertNever(
|
|
38210
|
+
return Debug.assertNever(allowedEndings[0]);
|
|
38020
38211
|
}
|
|
38021
38212
|
}
|
|
38022
38213
|
function getJSExtensionForFile(fileName, options) {
|
|
@@ -38825,11 +39016,6 @@ function createTypeChecker(host) {
|
|
|
38825
39016
|
let lastFlowNode;
|
|
38826
39017
|
let lastFlowNodeReachable;
|
|
38827
39018
|
let flowTypeCache;
|
|
38828
|
-
const contextualTypeNodes = [];
|
|
38829
|
-
const contextualTypes = [];
|
|
38830
|
-
let contextualTypeCount = 0;
|
|
38831
|
-
let currentInferenceNode;
|
|
38832
|
-
let currentInferenceContext;
|
|
38833
39019
|
const emptyStringType = getStringLiteralType("");
|
|
38834
39020
|
const zeroType = getNumberLiteralType(0);
|
|
38835
39021
|
const zeroBigIntType = getBigIntLiteralType({ negative: false, base10Value: "0" });
|
|
@@ -40679,7 +40865,7 @@ function createTypeChecker(host) {
|
|
|
40679
40865
|
} else if (namespace === unknownSymbol) {
|
|
40680
40866
|
return namespace;
|
|
40681
40867
|
}
|
|
40682
|
-
if (namespace.valueDeclaration && isInJSFile(namespace.valueDeclaration) && isVariableDeclaration(namespace.valueDeclaration) && namespace.valueDeclaration.initializer && isCommonJsRequire(namespace.valueDeclaration.initializer)) {
|
|
40868
|
+
if (namespace.valueDeclaration && isInJSFile(namespace.valueDeclaration) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Hybrid */ && isVariableDeclaration(namespace.valueDeclaration) && namespace.valueDeclaration.initializer && isCommonJsRequire(namespace.valueDeclaration.initializer)) {
|
|
40683
40869
|
const moduleName = namespace.valueDeclaration.initializer.arguments[0];
|
|
40684
40870
|
const moduleSym = resolveExternalModuleName(moduleName, moduleName);
|
|
40685
40871
|
if (moduleSym) {
|
|
@@ -40802,7 +40988,7 @@ function createTypeChecker(host) {
|
|
|
40802
40988
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
|
|
40803
40989
|
}
|
|
40804
40990
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
40805
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
40991
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
40806
40992
|
if (startsWith(moduleReference, "@types/")) {
|
|
40807
40993
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
40808
40994
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -40815,6 +41001,7 @@ function createTypeChecker(host) {
|
|
|
40815
41001
|
const currentSourceFile = getSourceFileOfNode(location);
|
|
40816
41002
|
const contextSpecifier = isStringLiteralLike(location) ? location : ((_a2 = findAncestor(location, isImportCall)) == null ? void 0 : _a2.arguments[0]) || ((_b = findAncestor(location, isImportDeclaration)) == null ? void 0 : _b.moduleSpecifier) || ((_c = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _c.moduleReference.expression) || ((_d = findAncestor(location, isExportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : void 0) == null ? void 0 : _e.name) || ((_f = isLiteralImportTypeNode(location) ? location : void 0) == null ? void 0 : _f.argument.literal);
|
|
40817
41003
|
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
41004
|
+
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
40818
41005
|
const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode);
|
|
40819
41006
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
40820
41007
|
const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -40822,14 +41009,27 @@ function createTypeChecker(host) {
|
|
|
40822
41009
|
if (resolutionDiagnostic) {
|
|
40823
41010
|
error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
40824
41011
|
}
|
|
41012
|
+
if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) {
|
|
41013
|
+
const importOrExport = ((_g = findAncestor(location, isImportDeclaration)) == null ? void 0 : _g.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
41014
|
+
if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
|
|
41015
|
+
error(
|
|
41016
|
+
errorNode,
|
|
41017
|
+
Diagnostics.A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead,
|
|
41018
|
+
getSuggestedImportSource(Debug.checkDefined(tryExtractTSExtension(moduleReference)))
|
|
41019
|
+
);
|
|
41020
|
+
}
|
|
41021
|
+
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
41022
|
+
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
41023
|
+
error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
41024
|
+
}
|
|
40825
41025
|
if (sourceFile.symbol) {
|
|
40826
41026
|
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
40827
41027
|
errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
|
|
40828
41028
|
}
|
|
40829
|
-
if (
|
|
41029
|
+
if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
|
|
40830
41030
|
const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
|
|
40831
41031
|
const overrideClauseHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
|
|
40832
|
-
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (
|
|
41032
|
+
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_h = overrideClauseHost.assertions) == null ? void 0 : _h.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
40833
41033
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
40834
41034
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
40835
41035
|
error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
@@ -40916,21 +41116,14 @@ function createTypeChecker(host) {
|
|
|
40916
41116
|
} else {
|
|
40917
41117
|
const tsExtension = tryExtractTSExtension(moduleReference);
|
|
40918
41118
|
const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
|
|
40919
|
-
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
40920
41119
|
const resolutionIsNode16OrNext = moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */;
|
|
40921
41120
|
if (tsExtension) {
|
|
40922
|
-
|
|
40923
|
-
|
|
40924
|
-
let replacedImportSource = importSourceWithoutExtension;
|
|
40925
|
-
if (moduleKind >= 5 /* ES2015 */) {
|
|
40926
|
-
replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js";
|
|
40927
|
-
}
|
|
40928
|
-
error(errorNode, diag2, tsExtension, replacedImportSource);
|
|
40929
|
-
} else if (!compilerOptions.resolveJsonModule && fileExtensionIs(moduleReference, ".json" /* Json */) && getEmitModuleResolutionKind(compilerOptions) !== 1 /* Classic */ && hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
41121
|
+
errorOnTSExtensionImport(tsExtension);
|
|
41122
|
+
} else if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json" /* Json */) && moduleResolutionKind !== 1 /* Classic */ && hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
40930
41123
|
error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
40931
41124
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
40932
41125
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
40933
|
-
const suggestedExt = (
|
|
41126
|
+
const suggestedExt = (_i = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _i[1];
|
|
40934
41127
|
if (suggestedExt) {
|
|
40935
41128
|
error(
|
|
40936
41129
|
errorNode,
|
|
@@ -40946,6 +41139,17 @@ function createTypeChecker(host) {
|
|
|
40946
41139
|
}
|
|
40947
41140
|
}
|
|
40948
41141
|
return void 0;
|
|
41142
|
+
function errorOnTSExtensionImport(tsExtension) {
|
|
41143
|
+
const diag2 = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
|
|
41144
|
+
error(errorNode, diag2, tsExtension, getSuggestedImportSource(tsExtension));
|
|
41145
|
+
}
|
|
41146
|
+
function getSuggestedImportSource(tsExtension) {
|
|
41147
|
+
const importSourceWithoutExtension = removeExtension(moduleReference, tsExtension);
|
|
41148
|
+
if (emitModuleKindIsNonNodeESM(moduleKind) || mode === 99 /* ESNext */) {
|
|
41149
|
+
return importSourceWithoutExtension + (tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js");
|
|
41150
|
+
}
|
|
41151
|
+
return importSourceWithoutExtension;
|
|
41152
|
+
}
|
|
40949
41153
|
}
|
|
40950
41154
|
function errorOnImplicitAnyModule(isError, errorNode, { packageId, resolvedFileName }, moduleReference) {
|
|
40951
41155
|
const errorInfo = !isExternalModuleNameRelative(moduleReference) && packageId ? typesPackageExists(packageId.name) ? chainDiagnosticMessages(
|
|
@@ -47439,10 +47643,6 @@ function createTypeChecker(host) {
|
|
|
47439
47643
|
function getConstraintOfTypeParameter(typeParameter) {
|
|
47440
47644
|
return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : void 0;
|
|
47441
47645
|
}
|
|
47442
|
-
function isConstTypeVariable(type) {
|
|
47443
|
-
var _a2;
|
|
47444
|
-
return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
|
|
47445
|
-
}
|
|
47446
47646
|
function getConstraintOfIndexedAccess(type) {
|
|
47447
47647
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
47448
47648
|
}
|
|
@@ -51849,10 +52049,12 @@ function createTypeChecker(host) {
|
|
|
51849
52049
|
}
|
|
51850
52050
|
}
|
|
51851
52051
|
function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
|
|
51852
|
-
|
|
51853
|
-
|
|
51854
|
-
|
|
51855
|
-
|
|
52052
|
+
next.contextualType = sourcePropType;
|
|
52053
|
+
try {
|
|
52054
|
+
return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType);
|
|
52055
|
+
} finally {
|
|
52056
|
+
next.contextualType = void 0;
|
|
52057
|
+
}
|
|
51856
52058
|
}
|
|
51857
52059
|
function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
|
|
51858
52060
|
let reportedError = false;
|
|
@@ -52051,13 +52253,18 @@ function createTypeChecker(host) {
|
|
|
52051
52253
|
if (isTupleLikeType(source)) {
|
|
52052
52254
|
return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
|
|
52053
52255
|
}
|
|
52054
|
-
|
|
52055
|
-
|
|
52056
|
-
|
|
52057
|
-
|
|
52058
|
-
|
|
52256
|
+
const oldContext = node.contextualType;
|
|
52257
|
+
node.contextualType = target;
|
|
52258
|
+
try {
|
|
52259
|
+
const tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, true);
|
|
52260
|
+
node.contextualType = oldContext;
|
|
52261
|
+
if (isTupleLikeType(tupleizedType)) {
|
|
52262
|
+
return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
|
|
52263
|
+
}
|
|
52264
|
+
return false;
|
|
52265
|
+
} finally {
|
|
52266
|
+
node.contextualType = oldContext;
|
|
52059
52267
|
}
|
|
52060
|
-
return false;
|
|
52061
52268
|
}
|
|
52062
52269
|
function* generateObjectLiteralElements(node) {
|
|
52063
52270
|
if (!length(node.properties))
|
|
@@ -55941,7 +56148,7 @@ function createTypeChecker(host) {
|
|
|
55941
56148
|
}
|
|
55942
56149
|
function getCovariantInference(inference, signature) {
|
|
55943
56150
|
const candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
|
|
55944
|
-
const primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter)
|
|
56151
|
+
const primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
|
|
55945
56152
|
const widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
|
|
55946
56153
|
const baseCandidates = primitiveConstraint ? sameMap(candidates, getRegularTypeOfLiteralType) : widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) : candidates;
|
|
55947
56154
|
const unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates);
|
|
@@ -58993,9 +59200,8 @@ function createTypeChecker(host) {
|
|
|
58993
59200
|
if (node.flags & 33554432 /* InWithStatement */) {
|
|
58994
59201
|
return void 0;
|
|
58995
59202
|
}
|
|
58996
|
-
|
|
58997
|
-
|
|
58998
|
-
return cached;
|
|
59203
|
+
if (node.contextualType) {
|
|
59204
|
+
return node.contextualType;
|
|
58999
59205
|
}
|
|
59000
59206
|
const { parent } = node;
|
|
59001
59207
|
switch (parent.kind) {
|
|
@@ -59017,7 +59223,7 @@ function createTypeChecker(host) {
|
|
|
59017
59223
|
return getContextualTypeForArgument(parent, node);
|
|
59018
59224
|
case 213 /* TypeAssertionExpression */:
|
|
59019
59225
|
case 231 /* AsExpression */:
|
|
59020
|
-
return isConstTypeReference(parent.type) ?
|
|
59226
|
+
return isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type);
|
|
59021
59227
|
case 223 /* BinaryExpression */:
|
|
59022
59228
|
return getContextualTypeForBinaryOperand(node, contextFlags);
|
|
59023
59229
|
case 299 /* PropertyAssignment */:
|
|
@@ -59037,7 +59243,7 @@ function createTypeChecker(host) {
|
|
|
59037
59243
|
return getContextualTypeForSubstitutionExpression(parent.parent, node);
|
|
59038
59244
|
case 214 /* ParenthesizedExpression */: {
|
|
59039
59245
|
const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : void 0;
|
|
59040
|
-
return !tag ? getContextualType(parent, contextFlags) : isJSDocTypeTag(tag) && isConstTypeReference(tag.typeExpression.type) ?
|
|
59246
|
+
return !tag ? getContextualType(parent, contextFlags) : isJSDocTypeTag(tag) && isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type);
|
|
59041
59247
|
}
|
|
59042
59248
|
case 232 /* NonNullExpression */:
|
|
59043
59249
|
return getContextualType(parent, contextFlags);
|
|
@@ -59055,32 +59261,17 @@ function createTypeChecker(host) {
|
|
|
59055
59261
|
return getContextualJsxElementAttributesType(parent, contextFlags);
|
|
59056
59262
|
}
|
|
59057
59263
|
return void 0;
|
|
59058
|
-
|
|
59059
|
-
|
|
59060
|
-
contextualTypeNodes[contextualTypeCount] = node;
|
|
59061
|
-
contextualTypes[contextualTypeCount] = type;
|
|
59062
|
-
contextualTypeCount++;
|
|
59063
|
-
}
|
|
59064
|
-
function popContextualType() {
|
|
59065
|
-
contextualTypeCount--;
|
|
59066
|
-
}
|
|
59067
|
-
function getCachedContextualType(node) {
|
|
59068
|
-
for (let i = contextualTypeCount - 1; i >= 0; i--) {
|
|
59069
|
-
if (node === contextualTypeNodes[i]) {
|
|
59070
|
-
return contextualTypes[i];
|
|
59071
|
-
}
|
|
59264
|
+
function tryFindWhenConstTypeReference(node2) {
|
|
59265
|
+
return getContextualType(node2, contextFlags);
|
|
59072
59266
|
}
|
|
59073
|
-
return void 0;
|
|
59074
59267
|
}
|
|
59075
59268
|
function getInferenceContext(node) {
|
|
59076
|
-
|
|
59269
|
+
const ancestor = findAncestor(node, (n) => !!n.inferenceContext);
|
|
59270
|
+
return ancestor && ancestor.inferenceContext;
|
|
59077
59271
|
}
|
|
59078
59272
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
59079
|
-
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
59080
|
-
|
|
59081
|
-
if (cached) {
|
|
59082
|
-
return cached;
|
|
59083
|
-
}
|
|
59273
|
+
if (isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) {
|
|
59274
|
+
return node.parent.contextualType;
|
|
59084
59275
|
}
|
|
59085
59276
|
return getContextualTypeForArgumentAtIndex(node, 0);
|
|
59086
59277
|
}
|
|
@@ -59336,11 +59527,9 @@ function createTypeChecker(host) {
|
|
|
59336
59527
|
const elementCount = elements.length;
|
|
59337
59528
|
const elementTypes = [];
|
|
59338
59529
|
const elementFlags = [];
|
|
59339
|
-
|
|
59530
|
+
const contextualType = getApparentTypeOfContextualType(node, void 0);
|
|
59340
59531
|
const inDestructuringPattern = isAssignmentTarget(node);
|
|
59341
59532
|
const inConstContext = isConstContext(node);
|
|
59342
|
-
const contextualType = getApparentTypeOfContextualType(node, void 0);
|
|
59343
|
-
const inTupleContext = !!contextualType && someType(contextualType, isTupleLikeType);
|
|
59344
59533
|
let hasOmittedExpression = false;
|
|
59345
59534
|
for (let i = 0; i < elementCount; i++) {
|
|
59346
59535
|
const e = elements[i];
|
|
@@ -59365,21 +59554,21 @@ function createTypeChecker(host) {
|
|
|
59365
59554
|
elementTypes.push(undefinedOrMissingType);
|
|
59366
59555
|
elementFlags.push(2 /* Optional */);
|
|
59367
59556
|
} else {
|
|
59368
|
-
const
|
|
59557
|
+
const elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
|
|
59558
|
+
const type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
|
|
59369
59559
|
elementTypes.push(addOptionality(type, true, hasOmittedExpression));
|
|
59370
59560
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
59371
|
-
if (
|
|
59561
|
+
if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
59372
59562
|
const inferenceContext = getInferenceContext(node);
|
|
59373
59563
|
Debug.assert(inferenceContext);
|
|
59374
59564
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
59375
59565
|
}
|
|
59376
59566
|
}
|
|
59377
59567
|
}
|
|
59378
|
-
popContextualType();
|
|
59379
59568
|
if (inDestructuringPattern) {
|
|
59380
59569
|
return createTupleType(elementTypes, elementFlags);
|
|
59381
59570
|
}
|
|
59382
|
-
if (forceTuple || inConstContext ||
|
|
59571
|
+
if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) {
|
|
59383
59572
|
return createArrayLiteralType(createTupleType(elementTypes, elementFlags, inConstContext));
|
|
59384
59573
|
}
|
|
59385
59574
|
return createArrayLiteralType(createArrayType(elementTypes.length ? getUnionType(sameMap(elementTypes, (t, i) => elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t), 2 /* Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
|
|
@@ -59472,7 +59661,6 @@ function createTypeChecker(host) {
|
|
|
59472
59661
|
let propertiesTable = createSymbolTable();
|
|
59473
59662
|
let propertiesArray = [];
|
|
59474
59663
|
let spread = emptyObjectType;
|
|
59475
|
-
pushContextualType(node, getContextualType(node, void 0));
|
|
59476
59664
|
const contextualType = getApparentTypeOfContextualType(node, void 0);
|
|
59477
59665
|
const contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === 203 /* ObjectBindingPattern */ || contextualType.pattern.kind === 207 /* ObjectLiteralExpression */);
|
|
59478
59666
|
const inConstContext = isConstContext(node);
|
|
@@ -59594,7 +59782,6 @@ function createTypeChecker(host) {
|
|
|
59594
59782
|
}
|
|
59595
59783
|
propertiesArray.push(member);
|
|
59596
59784
|
}
|
|
59597
|
-
popContextualType();
|
|
59598
59785
|
if (contextualTypeHasPattern) {
|
|
59599
59786
|
const rootPatternParent = findAncestor(
|
|
59600
59787
|
contextualType.pattern.parent,
|
|
@@ -61182,7 +61369,6 @@ function createTypeChecker(host) {
|
|
|
61182
61369
|
const types = [];
|
|
61183
61370
|
const flags = [];
|
|
61184
61371
|
const names = [];
|
|
61185
|
-
const inConstContext = isConstTypeVariable(restType);
|
|
61186
61372
|
for (let i = index; i < argCount; i++) {
|
|
61187
61373
|
const arg = args[i];
|
|
61188
61374
|
if (isSpreadArgument(arg)) {
|
|
@@ -61197,7 +61383,7 @@ function createTypeChecker(host) {
|
|
|
61197
61383
|
} else {
|
|
61198
61384
|
const contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
|
|
61199
61385
|
const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
|
|
61200
|
-
const hasPrimitiveContextualType =
|
|
61386
|
+
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
|
|
61201
61387
|
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
|
|
61202
61388
|
flags.push(1 /* Required */);
|
|
61203
61389
|
}
|
|
@@ -61205,7 +61391,7 @@ function createTypeChecker(host) {
|
|
|
61205
61391
|
names.push(arg.tupleNameSource);
|
|
61206
61392
|
}
|
|
61207
61393
|
}
|
|
61208
|
-
return createTupleType(types, flags,
|
|
61394
|
+
return createTupleType(types, flags, false, length(names) === length(types) ? names : void 0);
|
|
61209
61395
|
}
|
|
61210
61396
|
function checkTypeArguments(signature, typeArgumentNodes, reportErrors2, headMessage) {
|
|
61211
61397
|
const isJavascript = isInJSFile(signature.declaration);
|
|
@@ -62466,7 +62652,7 @@ function createTypeChecker(host) {
|
|
|
62466
62652
|
return anyType;
|
|
62467
62653
|
}
|
|
62468
62654
|
}
|
|
62469
|
-
if (isInJSFile(node) && isCommonJsRequire(node)) {
|
|
62655
|
+
if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Hybrid */ && isCommonJsRequire(node)) {
|
|
62470
62656
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
62471
62657
|
}
|
|
62472
62658
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -64582,21 +64768,22 @@ function createTypeChecker(host) {
|
|
|
64582
64768
|
return node;
|
|
64583
64769
|
}
|
|
64584
64770
|
function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
|
|
64585
|
-
const
|
|
64586
|
-
|
|
64587
|
-
const
|
|
64588
|
-
|
|
64589
|
-
|
|
64590
|
-
|
|
64591
|
-
|
|
64592
|
-
|
|
64593
|
-
|
|
64594
|
-
|
|
64595
|
-
|
|
64596
|
-
|
|
64597
|
-
|
|
64598
|
-
|
|
64599
|
-
|
|
64771
|
+
const context = getContextNode(node);
|
|
64772
|
+
const saveContextualType = context.contextualType;
|
|
64773
|
+
const saveInferenceContext = context.inferenceContext;
|
|
64774
|
+
try {
|
|
64775
|
+
context.contextualType = contextualType;
|
|
64776
|
+
context.inferenceContext = inferenceContext;
|
|
64777
|
+
const type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
|
|
64778
|
+
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
64779
|
+
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
64780
|
+
}
|
|
64781
|
+
const result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, void 0)) ? getRegularTypeOfLiteralType(type) : type;
|
|
64782
|
+
return result;
|
|
64783
|
+
} finally {
|
|
64784
|
+
context.contextualType = saveContextualType;
|
|
64785
|
+
context.inferenceContext = saveInferenceContext;
|
|
64786
|
+
}
|
|
64600
64787
|
}
|
|
64601
64788
|
function checkExpressionCached(node, checkMode) {
|
|
64602
64789
|
if (checkMode) {
|
|
@@ -64668,15 +64855,11 @@ function createTypeChecker(host) {
|
|
|
64668
64855
|
}
|
|
64669
64856
|
function isConstContext(node) {
|
|
64670
64857
|
const parent = node.parent;
|
|
64671
|
-
return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) ||
|
|
64672
|
-
}
|
|
64673
|
-
function isConstTypeParameterContext(node) {
|
|
64674
|
-
const contextualType = getContextualType(node, 0 /* None */);
|
|
64675
|
-
return !!contextualType && someType(contextualType, isConstTypeVariable);
|
|
64858
|
+
return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || (isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) || (isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
|
|
64676
64859
|
}
|
|
64677
|
-
function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
|
|
64860
|
+
function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
|
|
64678
64861
|
const type = checkExpression(node, checkMode, forceTuple);
|
|
64679
|
-
return isConstContext(node) || isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(getContextualType(node, void 0), node, void 0));
|
|
64862
|
+
return isConstContext(node) || isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, void 0) : contextualType, node, void 0));
|
|
64680
64863
|
}
|
|
64681
64864
|
function checkPropertyAssignment(node, checkMode) {
|
|
64682
64865
|
if (node.name.kind === 164 /* ComputedPropertyName */) {
|
|
@@ -64860,10 +65043,14 @@ function createTypeChecker(host) {
|
|
|
64860
65043
|
if (links.contextFreeType) {
|
|
64861
65044
|
return links.contextFreeType;
|
|
64862
65045
|
}
|
|
64863
|
-
|
|
64864
|
-
|
|
64865
|
-
|
|
64866
|
-
|
|
65046
|
+
const saveContextualType = node.contextualType;
|
|
65047
|
+
node.contextualType = anyType;
|
|
65048
|
+
try {
|
|
65049
|
+
const type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */);
|
|
65050
|
+
return type;
|
|
65051
|
+
} finally {
|
|
65052
|
+
node.contextualType = saveContextualType;
|
|
65053
|
+
}
|
|
64867
65054
|
}
|
|
64868
65055
|
function checkExpression(node, checkMode, forceTuple) {
|
|
64869
65056
|
var _a2, _b;
|
|
@@ -69516,6 +69703,8 @@ function createTypeChecker(host) {
|
|
|
69516
69703
|
} else {
|
|
69517
69704
|
if (moduleKind >= 5 /* ES2015 */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
|
|
69518
69705
|
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
|
69706
|
+
} else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Hybrid */) {
|
|
69707
|
+
grammarErrorOnNode(node, Diagnostics.Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_hybrid_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
|
69519
69708
|
}
|
|
69520
69709
|
}
|
|
69521
69710
|
}
|
|
@@ -69683,6 +69872,8 @@ function createTypeChecker(host) {
|
|
|
69683
69872
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
69684
69873
|
} else if (moduleKind === 4 /* System */) {
|
|
69685
69874
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
69875
|
+
} else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Hybrid */) {
|
|
69876
|
+
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_hybrid_Consider_using_export_default_or_another_module_format_instead);
|
|
69686
69877
|
}
|
|
69687
69878
|
}
|
|
69688
69879
|
}
|
|
@@ -70546,7 +70737,7 @@ function createTypeChecker(host) {
|
|
|
70546
70737
|
return void 0;
|
|
70547
70738
|
case 10 /* StringLiteral */:
|
|
70548
70739
|
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
70549
|
-
if (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node || (node.parent.kind === 269 /* ImportDeclaration */ || node.parent.kind === 275 /* ExportDeclaration */) && node.parent.moduleSpecifier === node || (isInJSFile(node) && isRequireCall(node.parent, false) || isImportCall(node.parent)) || isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent) {
|
|
70740
|
+
if (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node || (node.parent.kind === 269 /* ImportDeclaration */ || node.parent.kind === 275 /* ExportDeclaration */) && node.parent.moduleSpecifier === node || (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Hybrid */ && isRequireCall(node.parent, false) || isImportCall(node.parent)) || isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent) {
|
|
70550
70741
|
return resolveExternalModuleName(node, node, ignoreErrors);
|
|
70551
70742
|
}
|
|
70552
70743
|
if (isCallExpression(parent) && isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
|
|
@@ -71601,19 +71792,16 @@ function createTypeChecker(host) {
|
|
|
71601
71792
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_index_signature, tokenToString(modifier.kind));
|
|
71602
71793
|
}
|
|
71603
71794
|
}
|
|
71604
|
-
if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 145 /* OutKeyword */
|
|
71795
|
+
if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 145 /* OutKeyword */) {
|
|
71605
71796
|
if (node.kind === 165 /* TypeParameter */) {
|
|
71606
71797
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, tokenToString(modifier.kind));
|
|
71607
71798
|
}
|
|
71608
71799
|
}
|
|
71609
71800
|
switch (modifier.kind) {
|
|
71610
71801
|
case 85 /* ConstKeyword */:
|
|
71611
|
-
if (node.kind !== 263 /* EnumDeclaration */
|
|
71802
|
+
if (node.kind !== 263 /* EnumDeclaration */) {
|
|
71612
71803
|
return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(85 /* ConstKeyword */));
|
|
71613
71804
|
}
|
|
71614
|
-
if (node.kind === 165 /* TypeParameter */ && !(isFunctionLikeDeclaration(node.parent) || isClassDeclaration(node.parent))) {
|
|
71615
|
-
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class, tokenToString(modifier.kind));
|
|
71616
|
-
}
|
|
71617
71805
|
break;
|
|
71618
71806
|
case 161 /* OverrideKeyword */:
|
|
71619
71807
|
if (flags & 16384 /* Override */) {
|
|
@@ -97663,10 +97851,6 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
|
|
|
97663
97851
|
function getConfigFileParsingDiagnostics(configFileParseResult) {
|
|
97664
97852
|
return configFileParseResult.options.configFile ? [...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] : configFileParseResult.errors;
|
|
97665
97853
|
}
|
|
97666
|
-
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
97667
|
-
const result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
|
97668
|
-
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
97669
|
-
}
|
|
97670
97854
|
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
97671
97855
|
switch (getEmitModuleResolutionKind(options)) {
|
|
97672
97856
|
case 3 /* Node16 */:
|
|
@@ -99097,7 +99281,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
99097
99281
|
for (const node of file.statements) {
|
|
99098
99282
|
collectModuleReferences(node, false);
|
|
99099
99283
|
}
|
|
99100
|
-
|
|
99284
|
+
const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Hybrid */;
|
|
99285
|
+
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
|
|
99101
99286
|
collectDynamicImportOrRequireCalls(file);
|
|
99102
99287
|
}
|
|
99103
99288
|
file.imports = imports || emptyArray;
|
|
@@ -99138,7 +99323,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
99138
99323
|
const r = /import|require/g;
|
|
99139
99324
|
while (r.exec(file2.text) !== null) {
|
|
99140
99325
|
const node = getNodeAtPosition(file2, r.lastIndex);
|
|
99141
|
-
if (
|
|
99326
|
+
if (shouldProcessRequires && isRequireCall(node, true)) {
|
|
99142
99327
|
setParentRecursive(node, false);
|
|
99143
99328
|
imports = append(imports, node.arguments[0]);
|
|
99144
99329
|
} else if (isImportCall(node) && node.arguments.length >= 1 && isStringLiteralLike(node.arguments[0])) {
|
|
@@ -99854,8 +100039,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
99854
100039
|
programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
|
|
99855
100040
|
}
|
|
99856
100041
|
}
|
|
99857
|
-
if (options
|
|
99858
|
-
if (getEmitModuleResolutionKind(options) !== 2 /* NodeJs */ && getEmitModuleResolutionKind(options) !== 3 /* Node16 */ && getEmitModuleResolutionKind(options) !== 99 /* NodeNext */) {
|
|
100042
|
+
if (getResolveJsonModule(options)) {
|
|
100043
|
+
if (getEmitModuleResolutionKind(options) !== 2 /* NodeJs */ && getEmitModuleResolutionKind(options) !== 3 /* Node16 */ && getEmitModuleResolutionKind(options) !== 99 /* NodeNext */ && getEmitModuleResolutionKind(options) !== 100 /* Hybrid */) {
|
|
99859
100044
|
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
99860
100045
|
} else if (!hasJsonModuleEmitEnabled(options)) {
|
|
99861
100046
|
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
|
|
@@ -99921,6 +100106,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
99921
100106
|
if (options.preserveValueImports && getEmitModuleKind(options) < 5 /* ES2015 */) {
|
|
99922
100107
|
createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later);
|
|
99923
100108
|
}
|
|
100109
|
+
if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) {
|
|
100110
|
+
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_hybrid_and_either_noEmit_or_emitDeclarationOnly_is_set);
|
|
100111
|
+
}
|
|
100112
|
+
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
100113
|
+
if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
100114
|
+
createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports");
|
|
100115
|
+
}
|
|
100116
|
+
if (options.resolvePackageJsonImports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
100117
|
+
createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonImports");
|
|
100118
|
+
}
|
|
100119
|
+
if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
100120
|
+
createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "customConditions");
|
|
100121
|
+
}
|
|
99924
100122
|
if (!options.noEmit && !options.suppressOutputPathCheck) {
|
|
99925
100123
|
const emitHost = getEmitHost();
|
|
99926
100124
|
const emitFilesSeen = /* @__PURE__ */ new Set();
|
|
@@ -100474,7 +100672,7 @@ function getResolutionDiagnostic(options, { extension }) {
|
|
|
100474
100672
|
return getAllowJSCompilerOption(options) || !getStrictOptionValue(options, "noImplicitAny") ? void 0 : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type;
|
|
100475
100673
|
}
|
|
100476
100674
|
function needResolveJsonModule() {
|
|
100477
|
-
return options
|
|
100675
|
+
return getResolveJsonModule(options) ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
|
|
100478
100676
|
}
|
|
100479
100677
|
}
|
|
100480
100678
|
function getModuleNames({ imports, moduleAugmentations }) {
|