typescript 4.7.1-rc → 4.7.4
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 +88 -40
- package/lib/tsserver.js +160 -74
- package/lib/tsserverlibrary.d.ts +26 -0
- package/lib/tsserverlibrary.js +160 -74
- package/lib/typescript.d.ts +26 -0
- package/lib/typescript.js +160 -74
- package/lib/typescriptServices.d.ts +26 -0
- package/lib/typescriptServices.js +160 -74
- package/lib/typingsInstaller.js +108 -44
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = "
|
|
103
|
+
ts.version = "4.7.4";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8389,7 +8389,7 @@ var ts;
|
|
|
8389
8389
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8390
8390
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8391
8391
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8392
|
-
|
|
8392
|
+
resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`."),
|
|
8393
8393
|
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8394
8394
|
resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."),
|
|
8395
8395
|
resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
|
|
@@ -8893,6 +8893,7 @@ var ts;
|
|
|
8893
8893
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8894
8894
|
Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
|
|
8895
8895
|
All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
|
|
8896
|
+
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8896
8897
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8897
8898
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.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}'."),
|
|
8898
8899
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.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}'."),
|
|
@@ -9000,7 +9001,7 @@ var ts;
|
|
|
9000
9001
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
9001
9002
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
9002
9003
|
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9003
|
-
|
|
9004
|
+
resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "'resolution-mode' assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9004
9005
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
9005
9006
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
9006
9007
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -16018,6 +16019,8 @@ var ts;
|
|
|
16018
16019
|
case 218 /* SyntaxKind.AwaitExpression */:
|
|
16019
16020
|
case 231 /* SyntaxKind.MetaProperty */:
|
|
16020
16021
|
return true;
|
|
16022
|
+
case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
16023
|
+
return !ts.isHeritageClause(node.parent);
|
|
16021
16024
|
case 161 /* SyntaxKind.QualifiedName */:
|
|
16022
16025
|
while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
|
|
16023
16026
|
node = node.parent;
|
|
@@ -16189,9 +16192,6 @@ var ts;
|
|
|
16189
16192
|
}
|
|
16190
16193
|
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
16191
16194
|
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
16192
|
-
if (node.kind === 203 /* SyntaxKind.BindingElement */) {
|
|
16193
|
-
node = node.parent.parent;
|
|
16194
|
-
}
|
|
16195
16195
|
return ts.isVariableDeclaration(node) &&
|
|
16196
16196
|
!!node.initializer &&
|
|
16197
16197
|
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
@@ -20013,8 +20013,9 @@ var ts;
|
|
|
20013
20013
|
*/
|
|
20014
20014
|
function isFileForcedToBeModuleByFormat(file) {
|
|
20015
20015
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20016
|
-
// for back compat purposes.
|
|
20017
|
-
|
|
20016
|
+
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20017
|
+
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20018
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20018
20019
|
}
|
|
20019
20020
|
function getSetExternalModuleIndicator(options) {
|
|
20020
20021
|
// TODO: Should this callback be cached?
|
|
@@ -20022,7 +20023,7 @@ var ts;
|
|
|
20022
20023
|
case ts.ModuleDetectionKind.Force:
|
|
20023
20024
|
// All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
|
|
20024
20025
|
return function (file) {
|
|
20025
|
-
file.externalModuleIndicator = !file.isDeclarationFile ||
|
|
20026
|
+
file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
|
|
20026
20027
|
};
|
|
20027
20028
|
case ts.ModuleDetectionKind.Legacy:
|
|
20028
20029
|
// Files are modules if they have imports, exports, or import.meta
|
|
@@ -20082,7 +20083,8 @@ var ts;
|
|
|
20082
20083
|
}
|
|
20083
20084
|
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
|
|
20084
20085
|
function getEmitModuleDetectionKind(options) {
|
|
20085
|
-
return options.moduleDetection ||
|
|
20086
|
+
return options.moduleDetection ||
|
|
20087
|
+
(getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
|
|
20086
20088
|
}
|
|
20087
20089
|
ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
|
|
20088
20090
|
function hasJsonModuleEmitEnabled(options) {
|
|
@@ -29062,6 +29064,10 @@ var ts;
|
|
|
29062
29064
|
return node.kind === 267 /* SyntaxKind.ImportClause */;
|
|
29063
29065
|
}
|
|
29064
29066
|
ts.isImportClause = isImportClause;
|
|
29067
|
+
function isImportTypeAssertionContainer(node) {
|
|
29068
|
+
return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */;
|
|
29069
|
+
}
|
|
29070
|
+
ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
|
|
29065
29071
|
function isAssertClause(node) {
|
|
29066
29072
|
return node.kind === 293 /* SyntaxKind.AssertClause */;
|
|
29067
29073
|
}
|
|
@@ -35418,10 +35424,11 @@ var ts;
|
|
|
35418
35424
|
}
|
|
35419
35425
|
nextToken();
|
|
35420
35426
|
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
|
35421
|
-
if (
|
|
35427
|
+
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
|
35422
35428
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35423
35429
|
return undefined;
|
|
35424
35430
|
}
|
|
35431
|
+
nextToken();
|
|
35425
35432
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35426
35433
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35427
35434
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -42006,7 +42013,7 @@ var ts;
|
|
|
42006
42013
|
}
|
|
42007
42014
|
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
42008
42015
|
return {
|
|
42009
|
-
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
42016
|
+
key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
|
|
42010
42017
|
flags: 1 /* WatchDirectoryFlags.Recursive */
|
|
42011
42018
|
};
|
|
42012
42019
|
}
|
|
@@ -43111,16 +43118,20 @@ var ts;
|
|
|
43111
43118
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43112
43119
|
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
43113
43120
|
}
|
|
43121
|
+
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43122
|
+
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43123
|
+
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43124
|
+
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43114
43125
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43115
43126
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43116
43127
|
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
43117
43128
|
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
43118
|
-
|
|
43129
|
+
var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
|
|
43130
|
+
if (compilerOptions.resolveJsonModule) {
|
|
43131
|
+
extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
|
|
43132
|
+
}
|
|
43133
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
|
|
43119
43134
|
}
|
|
43120
|
-
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43121
|
-
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43122
|
-
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43123
|
-
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43124
43135
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
43125
43136
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43126
43137
|
}
|
|
@@ -43803,13 +43814,36 @@ var ts;
|
|
|
43803
43814
|
}
|
|
43804
43815
|
return toSearchResult(/*value*/ undefined);
|
|
43805
43816
|
}
|
|
43817
|
+
/**
|
|
43818
|
+
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
43819
|
+
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
43820
|
+
*/
|
|
43821
|
+
function comparePatternKeys(a, b) {
|
|
43822
|
+
var aPatternIndex = a.indexOf("*");
|
|
43823
|
+
var bPatternIndex = b.indexOf("*");
|
|
43824
|
+
var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
43825
|
+
var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
43826
|
+
if (baseLenA > baseLenB)
|
|
43827
|
+
return -1;
|
|
43828
|
+
if (baseLenB > baseLenA)
|
|
43829
|
+
return 1;
|
|
43830
|
+
if (aPatternIndex === -1)
|
|
43831
|
+
return 1;
|
|
43832
|
+
if (bPatternIndex === -1)
|
|
43833
|
+
return -1;
|
|
43834
|
+
if (a.length > b.length)
|
|
43835
|
+
return -1;
|
|
43836
|
+
if (b.length > a.length)
|
|
43837
|
+
return 1;
|
|
43838
|
+
return 0;
|
|
43839
|
+
}
|
|
43806
43840
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
43807
43841
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
43808
43842
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
43809
43843
|
var target = lookupTable[moduleName];
|
|
43810
43844
|
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
43811
43845
|
}
|
|
43812
|
-
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }),
|
|
43846
|
+
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
43813
43847
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
43814
43848
|
var potentialTarget = expandingKeys_1[_i];
|
|
43815
43849
|
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
@@ -44128,8 +44162,8 @@ var ts;
|
|
|
44128
44162
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
44129
44163
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
44130
44164
|
if (!pathAndExtension && packageInfo
|
|
44131
|
-
|
|
44132
|
-
&& packageInfo.packageJsonContent.
|
|
44165
|
+
// eslint-disable-next-line no-null/no-null
|
|
44166
|
+
&& (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
|
|
44133
44167
|
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
44134
44168
|
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
44135
44169
|
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
@@ -46905,12 +46939,14 @@ var ts;
|
|
|
46905
46939
|
}
|
|
46906
46940
|
}
|
|
46907
46941
|
function setCommonJsModuleIndicator(node) {
|
|
46908
|
-
if (file.externalModuleIndicator) {
|
|
46942
|
+
if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
|
|
46909
46943
|
return false;
|
|
46910
46944
|
}
|
|
46911
46945
|
if (!file.commonJsModuleIndicator) {
|
|
46912
46946
|
file.commonJsModuleIndicator = node;
|
|
46913
|
-
|
|
46947
|
+
if (!file.externalModuleIndicator) {
|
|
46948
|
+
bindSourceFileAsExternalModule();
|
|
46949
|
+
}
|
|
46914
46950
|
}
|
|
46915
46951
|
return true;
|
|
46916
46952
|
}
|
|
@@ -47324,7 +47360,11 @@ var ts;
|
|
|
47324
47360
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
47325
47361
|
}
|
|
47326
47362
|
if (!ts.isBindingPattern(node.name)) {
|
|
47327
|
-
|
|
47363
|
+
var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent;
|
|
47364
|
+
if (ts.isInJSFile(node) &&
|
|
47365
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
|
|
47366
|
+
!ts.getJSDocTypeTag(node) &&
|
|
47367
|
+
!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
|
|
47328
47368
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
47329
47369
|
}
|
|
47330
47370
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -50151,7 +50191,8 @@ var ts;
|
|
|
50151
50191
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
50152
50192
|
|| node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
|
|
50153
50193
|
|| node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
50154
|
-
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50194
|
+
|| node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50195
|
+
|| node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
|
|
50155
50196
|
}
|
|
50156
50197
|
function isAliasableOrJsExpression(e) {
|
|
50157
50198
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -50244,7 +50285,7 @@ var ts;
|
|
|
50244
50285
|
return hasExportAssignmentSymbol(moduleSymbol);
|
|
50245
50286
|
}
|
|
50246
50287
|
// JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
|
|
50247
|
-
return
|
|
50288
|
+
return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
|
|
50248
50289
|
}
|
|
50249
50290
|
function getTargetOfImportClause(node, dontResolveAlias) {
|
|
50250
50291
|
var _a;
|
|
@@ -53359,6 +53400,7 @@ var ts;
|
|
|
53359
53400
|
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
53360
53401
|
}
|
|
53361
53402
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
53403
|
+
var _a, _b, _c, _d;
|
|
53362
53404
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
53363
53405
|
var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
|
|
53364
53406
|
if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
@@ -53376,6 +53418,7 @@ var ts;
|
|
|
53376
53418
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53377
53419
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
|
|
53378
53420
|
])));
|
|
53421
|
+
(_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
53379
53422
|
}
|
|
53380
53423
|
}
|
|
53381
53424
|
if (!specifier) {
|
|
@@ -53395,6 +53438,7 @@ var ts;
|
|
|
53395
53438
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53396
53439
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
|
|
53397
53440
|
])));
|
|
53441
|
+
(_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
53398
53442
|
}
|
|
53399
53443
|
}
|
|
53400
53444
|
if (!assertion) {
|
|
@@ -58883,7 +58927,7 @@ var ts;
|
|
|
58883
58927
|
var objectType;
|
|
58884
58928
|
return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
|
|
58885
58929
|
!isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
|
|
58886
|
-
!objectType.
|
|
58930
|
+
!(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType);
|
|
58887
58931
|
}
|
|
58888
58932
|
/**
|
|
58889
58933
|
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
|
@@ -58896,9 +58940,9 @@ var ts;
|
|
|
58896
58940
|
t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) :
|
|
58897
58941
|
t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType :
|
|
58898
58942
|
t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType :
|
|
58899
|
-
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(
|
|
58943
|
+
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() :
|
|
58900
58944
|
t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType :
|
|
58901
|
-
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(
|
|
58945
|
+
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() :
|
|
58902
58946
|
t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType :
|
|
58903
58947
|
t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType :
|
|
58904
58948
|
t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType :
|
|
@@ -60473,8 +60517,8 @@ var ts;
|
|
|
60473
60517
|
function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
|
|
60474
60518
|
return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
|
|
60475
60519
|
}
|
|
60476
|
-
function getGlobalESSymbolType(
|
|
60477
|
-
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60520
|
+
function getGlobalESSymbolType() {
|
|
60521
|
+
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60478
60522
|
}
|
|
60479
60523
|
function getGlobalPromiseType(reportErrors) {
|
|
60480
60524
|
return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
|
|
@@ -60538,8 +60582,8 @@ var ts;
|
|
|
60538
60582
|
deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
|
|
60539
60583
|
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
|
|
60540
60584
|
}
|
|
60541
|
-
function getGlobalBigIntType(
|
|
60542
|
-
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60585
|
+
function getGlobalBigIntType() {
|
|
60586
|
+
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60543
60587
|
}
|
|
60544
60588
|
/**
|
|
60545
60589
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
@@ -64691,7 +64735,7 @@ var ts;
|
|
|
64691
64735
|
if ((globalStringType === source && stringType === target) ||
|
|
64692
64736
|
(globalNumberType === source && numberType === target) ||
|
|
64693
64737
|
(globalBooleanType === source && booleanType === target) ||
|
|
64694
|
-
(getGlobalESSymbolType(
|
|
64738
|
+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
|
|
64695
64739
|
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
|
|
64696
64740
|
}
|
|
64697
64741
|
}
|
|
@@ -80634,8 +80678,11 @@ var ts;
|
|
|
80634
80678
|
if (node.assertions) {
|
|
80635
80679
|
var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
|
|
80636
80680
|
if (override) {
|
|
80681
|
+
if (!ts.isNightly()) {
|
|
80682
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
80683
|
+
}
|
|
80637
80684
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
80638
|
-
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.
|
|
80685
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
80639
80686
|
}
|
|
80640
80687
|
}
|
|
80641
80688
|
}
|
|
@@ -82338,7 +82385,7 @@ var ts;
|
|
|
82338
82385
|
}
|
|
82339
82386
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
82340
82387
|
var symbol = getSymbolOfNode(node);
|
|
82341
|
-
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
82388
|
+
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) {
|
|
82342
82389
|
checkAliasSymbol(node);
|
|
82343
82390
|
return;
|
|
82344
82391
|
}
|
|
@@ -82503,7 +82550,7 @@ var ts;
|
|
|
82503
82550
|
var childSymbol = getSymbolAtLocation(childNode);
|
|
82504
82551
|
if (childSymbol && childSymbol === testedSymbol) {
|
|
82505
82552
|
// If the test was a simple identifier, the above check is sufficient
|
|
82506
|
-
if (ts.isIdentifier(expr)) {
|
|
82553
|
+
if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
|
|
82507
82554
|
return true;
|
|
82508
82555
|
}
|
|
82509
82556
|
// Otherwise we need to ensure the symbol is called on the same target
|
|
@@ -85006,10 +85053,10 @@ var ts;
|
|
|
85006
85053
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
85007
85054
|
if (validForTypeAssertions && override) {
|
|
85008
85055
|
if (!ts.isNightly()) {
|
|
85009
|
-
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85056
|
+
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
85010
85057
|
}
|
|
85011
85058
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
85012
|
-
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85059
|
+
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
85013
85060
|
}
|
|
85014
85061
|
return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
|
|
85015
85062
|
}
|
|
@@ -107861,7 +107908,8 @@ var ts;
|
|
|
107861
107908
|
trackReferencedAmbientModule: trackReferencedAmbientModule,
|
|
107862
107909
|
trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
|
|
107863
107910
|
reportNonlocalAugmentation: reportNonlocalAugmentation,
|
|
107864
|
-
reportNonSerializableProperty: reportNonSerializableProperty
|
|
107911
|
+
reportNonSerializableProperty: reportNonSerializableProperty,
|
|
107912
|
+
reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
|
|
107865
107913
|
};
|
|
107866
107914
|
var errorNameNode;
|
|
107867
107915
|
var errorFallbackNode;
|
|
@@ -107988,6 +108036,11 @@ var ts;
|
|
|
107988
108036
|
context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
|
|
107989
108037
|
}
|
|
107990
108038
|
}
|
|
108039
|
+
function reportImportTypeNodeResolutionModeOverride() {
|
|
108040
|
+
if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
|
|
108041
|
+
context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108042
|
+
}
|
|
108043
|
+
}
|
|
107991
108044
|
function transformDeclarationsForJS(sourceFile, bundled) {
|
|
107992
108045
|
var oldDiag = getSymbolAccessibilityDiagnostic;
|
|
107993
108046
|
getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
|
|
@@ -108438,7 +108491,7 @@ var ts;
|
|
|
108438
108491
|
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108439
108492
|
if (mode !== undefined) {
|
|
108440
108493
|
if (!ts.isNightly()) {
|
|
108441
|
-
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.
|
|
108494
|
+
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108442
108495
|
}
|
|
108443
108496
|
return assertClause;
|
|
108444
108497
|
}
|
|
@@ -115945,12 +115998,14 @@ var ts;
|
|
|
115945
115998
|
}
|
|
115946
115999
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
115947
116000
|
;
|
|
115948
|
-
|
|
116001
|
+
/**
|
|
116002
|
+
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
116003
|
+
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
116004
|
+
*/
|
|
115949
116005
|
function getModeForFileReference(ref, containingFileMode) {
|
|
115950
116006
|
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
115951
116007
|
}
|
|
115952
116008
|
ts.getModeForFileReference = getModeForFileReference;
|
|
115953
|
-
/* @internal */
|
|
115954
116009
|
function getModeForResolutionAtIndex(file, index) {
|
|
115955
116010
|
if (file.impliedNodeFormat === undefined)
|
|
115956
116011
|
return undefined;
|
|
@@ -115971,7 +116026,15 @@ var ts;
|
|
|
115971
116026
|
return false;
|
|
115972
116027
|
}
|
|
115973
116028
|
ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
|
|
115974
|
-
|
|
116029
|
+
/**
|
|
116030
|
+
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
|
116031
|
+
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
|
116032
|
+
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
|
116033
|
+
* `moduleResolution` is `node16`+.
|
|
116034
|
+
* @param file The file the import or import-like reference is contained within
|
|
116035
|
+
* @param usage The module reference string
|
|
116036
|
+
* @returns The final resolution mode of the import
|
|
116037
|
+
*/
|
|
115975
116038
|
function getModeForUsageLocation(file, usage) {
|
|
115976
116039
|
var _a, _b;
|
|
115977
116040
|
if (file.impliedNodeFormat === undefined)
|
|
@@ -118205,7 +118268,7 @@ var ts;
|
|
|
118205
118268
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
118206
118269
|
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
118207
118270
|
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118208
|
-
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.
|
|
118271
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
|
118209
118272
|
}
|
|
118210
118273
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
118211
118274
|
}
|
|
@@ -123498,6 +123561,7 @@ var ts;
|
|
|
123498
123561
|
}
|
|
123499
123562
|
function reloadFileNamesFromConfigFile() {
|
|
123500
123563
|
writeLog("Reloading new file names and options");
|
|
123564
|
+
reloadLevel = ts.ConfigFileProgramReloadLevel.None;
|
|
123501
123565
|
rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
|
123502
123566
|
if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
|
|
123503
123567
|
hasChangedConfigFileParsingErrors = true;
|
|
@@ -131402,10 +131466,9 @@ var ts;
|
|
|
131402
131466
|
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
|
131403
131467
|
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
|
131404
131468
|
})(GlobalsSearch || (GlobalsSearch = {}));
|
|
131405
|
-
function resolvingModuleSpecifiers(logPrefix, host,
|
|
131469
|
+
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
|
131406
131470
|
var _a, _b, _c;
|
|
131407
131471
|
var start = ts.timestamp();
|
|
131408
|
-
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
131409
131472
|
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
|
131410
131473
|
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
|
131411
131474
|
// relative path into node_modules), and we want to filter those completions out entirely.
|
|
@@ -131430,7 +131493,7 @@ var ts;
|
|
|
131430
131493
|
return result;
|
|
131431
131494
|
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
|
131432
131495
|
if (isFromAmbientModule) {
|
|
131433
|
-
var result_1 =
|
|
131496
|
+
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
|
131434
131497
|
if (result_1) {
|
|
131435
131498
|
ambientCount++;
|
|
131436
131499
|
}
|
|
@@ -131439,7 +131502,7 @@ var ts;
|
|
|
131439
131502
|
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
|
131440
131503
|
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
|
131441
131504
|
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
|
131442
|
-
?
|
|
131505
|
+
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
|
131443
131506
|
: undefined;
|
|
131444
131507
|
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
|
131445
131508
|
skippedAny = true;
|
|
@@ -131544,7 +131607,7 @@ var ts;
|
|
|
131544
131607
|
return undefined;
|
|
131545
131608
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
131546
131609
|
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
131547
|
-
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program,
|
|
131610
|
+
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
131548
131611
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
131549
131612
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
131550
131613
|
var _a;
|
|
@@ -132875,6 +132938,7 @@ var ts;
|
|
|
132875
132938
|
var hasUnresolvedAutoImports = false;
|
|
132876
132939
|
// This also gets mutated in nested-functions after the return
|
|
132877
132940
|
var symbols = [];
|
|
132941
|
+
var importSpecifierResolver;
|
|
132878
132942
|
var symbolToOriginInfoMap = [];
|
|
132879
132943
|
var symbolToSortTextMap = [];
|
|
132880
132944
|
var seenPropertySymbols = new ts.Map();
|
|
@@ -133096,14 +133160,14 @@ var ts;
|
|
|
133096
133160
|
}
|
|
133097
133161
|
else {
|
|
133098
133162
|
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
|
133099
|
-
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
|
133163
|
+
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
|
133100
133164
|
exportKind: 0 /* ExportKind.Named */,
|
|
133101
133165
|
moduleFileName: fileName,
|
|
133102
133166
|
isFromPackageJson: false,
|
|
133103
133167
|
moduleSymbol: moduleSymbol,
|
|
133104
133168
|
symbol: firstAccessibleSymbol,
|
|
133105
133169
|
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
|
133106
|
-
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)
|
|
133170
|
+
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
|
133107
133171
|
if (moduleSpecifier) {
|
|
133108
133172
|
var origin = {
|
|
133109
133173
|
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
|
@@ -133359,7 +133423,7 @@ var ts;
|
|
|
133359
133423
|
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
133360
133424
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
133361
133425
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
133362
|
-
resolvingModuleSpecifiers("collectAutoImports", host, program,
|
|
133426
|
+
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133363
133427
|
exportInfo.search(sourceFile.path,
|
|
133364
133428
|
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
133365
133429
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
@@ -136072,7 +136136,7 @@ var ts;
|
|
|
136072
136136
|
ts.Debug.assert(parent.name === node);
|
|
136073
136137
|
return true;
|
|
136074
136138
|
case 203 /* SyntaxKind.BindingElement */:
|
|
136075
|
-
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
|
|
136139
|
+
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
|
|
136076
136140
|
default:
|
|
136077
136141
|
return false;
|
|
136078
136142
|
}
|
|
@@ -137537,7 +137601,7 @@ var ts;
|
|
|
137537
137601
|
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
|
137538
137602
|
if (ts.isInJSFile(referenceLocation)
|
|
137539
137603
|
&& referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */
|
|
137540
|
-
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
|
|
137604
|
+
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
|
|
137541
137605
|
referenceSymbol = referenceLocation.parent.symbol;
|
|
137542
137606
|
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
|
|
137543
137607
|
// this case, just skip it, since the bound identifiers are not an alias of the import.
|
|
@@ -152390,6 +152454,18 @@ var ts;
|
|
|
152390
152454
|
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
|
152391
152455
|
}
|
|
152392
152456
|
}
|
|
152457
|
+
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
|
152458
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
|
152459
|
+
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
|
152460
|
+
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
|
152461
|
+
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
|
152462
|
+
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
|
152463
|
+
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
152464
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
|
152465
|
+
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
152466
|
+
}
|
|
152467
|
+
}
|
|
152468
|
+
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
|
152393
152469
|
// Sorted with the preferred fix coming first.
|
|
152394
152470
|
var ImportFixKind;
|
|
152395
152471
|
(function (ImportFixKind) {
|
|
@@ -152490,18 +152566,12 @@ var ts;
|
|
|
152490
152566
|
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
152491
152567
|
}
|
|
152492
152568
|
}
|
|
152493
|
-
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
|
152494
|
-
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
|
152495
|
-
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
152496
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
152497
|
-
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
152498
|
-
}
|
|
152499
|
-
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
152500
152569
|
function getImportFixes(exportInfos, useNamespaceInfo,
|
|
152501
152570
|
/** undefined only for missing JSX namespace */
|
|
152502
|
-
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
|
152571
|
+
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
|
152572
|
+
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
|
152503
152573
|
var checker = program.getTypeChecker();
|
|
152504
|
-
var existingImports = ts.flatMap(exportInfos,
|
|
152574
|
+
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
|
152505
152575
|
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
|
152506
152576
|
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
|
152507
152577
|
if (addToExisting) {
|
|
@@ -152629,21 +152699,37 @@ var ts;
|
|
|
152629
152699
|
};
|
|
152630
152700
|
});
|
|
152631
152701
|
}
|
|
152632
|
-
function
|
|
152633
|
-
var
|
|
152634
|
-
|
|
152635
|
-
|
|
152636
|
-
return ts.emptyArray;
|
|
152637
|
-
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
152638
|
-
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
|
152702
|
+
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
|
152703
|
+
var importMap;
|
|
152704
|
+
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
|
152705
|
+
var moduleSpecifier = _a[_i];
|
|
152639
152706
|
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
|
152640
152707
|
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
|
152641
|
-
|
|
152708
|
+
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
|
152709
|
+
if (moduleSymbol) {
|
|
152710
|
+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
|
152711
|
+
}
|
|
152712
|
+
}
|
|
152713
|
+
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
|
152714
|
+
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
|
152715
|
+
if (moduleSymbol) {
|
|
152716
|
+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
|
152717
|
+
}
|
|
152642
152718
|
}
|
|
152643
|
-
|
|
152644
|
-
|
|
152719
|
+
}
|
|
152720
|
+
return {
|
|
152721
|
+
getImportsForExportInfo: function (_a) {
|
|
152722
|
+
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
|
152723
|
+
// Can't use an es6 import for a type in JS.
|
|
152724
|
+
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
|
152725
|
+
return ts.emptyArray;
|
|
152726
|
+
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
|
152727
|
+
if (!matchingDeclarations)
|
|
152728
|
+
return ts.emptyArray;
|
|
152729
|
+
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
152730
|
+
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
|
152645
152731
|
}
|
|
152646
|
-
}
|
|
152732
|
+
};
|
|
152647
152733
|
}
|
|
152648
152734
|
function shouldUseRequire(sourceFile, program) {
|
|
152649
152735
|
// 1. TypeScript files don't use require variable declarations
|