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/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = "
|
|
297
|
+
ts.version = "4.7.4";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8583,7 +8583,7 @@ var ts;
|
|
|
8583
8583
|
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."),
|
|
8584
8584
|
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"),
|
|
8585
8585
|
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"),
|
|
8586
|
-
|
|
8586
|
+
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`."),
|
|
8587
8587
|
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`."),
|
|
8588
8588
|
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."),
|
|
8589
8589
|
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."),
|
|
@@ -9087,6 +9087,7 @@ var ts;
|
|
|
9087
9087
|
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."),
|
|
9088
9088
|
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."),
|
|
9089
9089
|
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."),
|
|
9090
|
+
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'."),
|
|
9090
9091
|
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}'."),
|
|
9091
9092
|
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}'."),
|
|
9092
9093
|
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}'."),
|
|
@@ -9194,7 +9195,7 @@ var ts;
|
|
|
9194
9195
|
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}'."),
|
|
9195
9196
|
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}'?"),
|
|
9196
9197
|
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'."),
|
|
9197
|
-
|
|
9198
|
+
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'."),
|
|
9198
9199
|
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."),
|
|
9199
9200
|
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."),
|
|
9200
9201
|
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}'."),
|
|
@@ -16212,6 +16213,8 @@ var ts;
|
|
|
16212
16213
|
case 218 /* SyntaxKind.AwaitExpression */:
|
|
16213
16214
|
case 231 /* SyntaxKind.MetaProperty */:
|
|
16214
16215
|
return true;
|
|
16216
|
+
case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
16217
|
+
return !ts.isHeritageClause(node.parent);
|
|
16215
16218
|
case 161 /* SyntaxKind.QualifiedName */:
|
|
16216
16219
|
while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
|
|
16217
16220
|
node = node.parent;
|
|
@@ -16383,9 +16386,6 @@ var ts;
|
|
|
16383
16386
|
}
|
|
16384
16387
|
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
16385
16388
|
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
16386
|
-
if (node.kind === 203 /* SyntaxKind.BindingElement */) {
|
|
16387
|
-
node = node.parent.parent;
|
|
16388
|
-
}
|
|
16389
16389
|
return ts.isVariableDeclaration(node) &&
|
|
16390
16390
|
!!node.initializer &&
|
|
16391
16391
|
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
@@ -20207,8 +20207,9 @@ var ts;
|
|
|
20207
20207
|
*/
|
|
20208
20208
|
function isFileForcedToBeModuleByFormat(file) {
|
|
20209
20209
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20210
|
-
// for back compat purposes.
|
|
20211
|
-
|
|
20210
|
+
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20211
|
+
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20212
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20212
20213
|
}
|
|
20213
20214
|
function getSetExternalModuleIndicator(options) {
|
|
20214
20215
|
// TODO: Should this callback be cached?
|
|
@@ -20216,7 +20217,7 @@ var ts;
|
|
|
20216
20217
|
case ts.ModuleDetectionKind.Force:
|
|
20217
20218
|
// All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
|
|
20218
20219
|
return function (file) {
|
|
20219
|
-
file.externalModuleIndicator = !file.isDeclarationFile ||
|
|
20220
|
+
file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
|
|
20220
20221
|
};
|
|
20221
20222
|
case ts.ModuleDetectionKind.Legacy:
|
|
20222
20223
|
// Files are modules if they have imports, exports, or import.meta
|
|
@@ -20276,7 +20277,8 @@ var ts;
|
|
|
20276
20277
|
}
|
|
20277
20278
|
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
|
|
20278
20279
|
function getEmitModuleDetectionKind(options) {
|
|
20279
|
-
return options.moduleDetection ||
|
|
20280
|
+
return options.moduleDetection ||
|
|
20281
|
+
(getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
|
|
20280
20282
|
}
|
|
20281
20283
|
ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
|
|
20282
20284
|
function hasJsonModuleEmitEnabled(options) {
|
|
@@ -29256,6 +29258,10 @@ var ts;
|
|
|
29256
29258
|
return node.kind === 267 /* SyntaxKind.ImportClause */;
|
|
29257
29259
|
}
|
|
29258
29260
|
ts.isImportClause = isImportClause;
|
|
29261
|
+
function isImportTypeAssertionContainer(node) {
|
|
29262
|
+
return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */;
|
|
29263
|
+
}
|
|
29264
|
+
ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
|
|
29259
29265
|
function isAssertClause(node) {
|
|
29260
29266
|
return node.kind === 293 /* SyntaxKind.AssertClause */;
|
|
29261
29267
|
}
|
|
@@ -35612,10 +35618,11 @@ var ts;
|
|
|
35612
35618
|
}
|
|
35613
35619
|
nextToken();
|
|
35614
35620
|
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
|
35615
|
-
if (
|
|
35621
|
+
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
|
35616
35622
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35617
35623
|
return undefined;
|
|
35618
35624
|
}
|
|
35625
|
+
nextToken();
|
|
35619
35626
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35620
35627
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35621
35628
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -42200,7 +42207,7 @@ var ts;
|
|
|
42200
42207
|
}
|
|
42201
42208
|
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
42202
42209
|
return {
|
|
42203
|
-
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
42210
|
+
key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
|
|
42204
42211
|
flags: 1 /* WatchDirectoryFlags.Recursive */
|
|
42205
42212
|
};
|
|
42206
42213
|
}
|
|
@@ -43305,16 +43312,20 @@ var ts;
|
|
|
43305
43312
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43306
43313
|
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
43307
43314
|
}
|
|
43315
|
+
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43316
|
+
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43317
|
+
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43318
|
+
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43308
43319
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43309
43320
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43310
43321
|
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
43311
43322
|
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
43312
|
-
|
|
43323
|
+
var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
|
|
43324
|
+
if (compilerOptions.resolveJsonModule) {
|
|
43325
|
+
extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
|
|
43326
|
+
}
|
|
43327
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
|
|
43313
43328
|
}
|
|
43314
|
-
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43315
|
-
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43316
|
-
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43317
|
-
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43318
43329
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
43319
43330
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43320
43331
|
}
|
|
@@ -43997,13 +44008,36 @@ var ts;
|
|
|
43997
44008
|
}
|
|
43998
44009
|
return toSearchResult(/*value*/ undefined);
|
|
43999
44010
|
}
|
|
44011
|
+
/**
|
|
44012
|
+
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
44013
|
+
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
44014
|
+
*/
|
|
44015
|
+
function comparePatternKeys(a, b) {
|
|
44016
|
+
var aPatternIndex = a.indexOf("*");
|
|
44017
|
+
var bPatternIndex = b.indexOf("*");
|
|
44018
|
+
var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
44019
|
+
var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
44020
|
+
if (baseLenA > baseLenB)
|
|
44021
|
+
return -1;
|
|
44022
|
+
if (baseLenB > baseLenA)
|
|
44023
|
+
return 1;
|
|
44024
|
+
if (aPatternIndex === -1)
|
|
44025
|
+
return 1;
|
|
44026
|
+
if (bPatternIndex === -1)
|
|
44027
|
+
return -1;
|
|
44028
|
+
if (a.length > b.length)
|
|
44029
|
+
return -1;
|
|
44030
|
+
if (b.length > a.length)
|
|
44031
|
+
return 1;
|
|
44032
|
+
return 0;
|
|
44033
|
+
}
|
|
44000
44034
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
44001
44035
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44002
44036
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
44003
44037
|
var target = lookupTable[moduleName];
|
|
44004
44038
|
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
44005
44039
|
}
|
|
44006
|
-
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }),
|
|
44040
|
+
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
44007
44041
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
44008
44042
|
var potentialTarget = expandingKeys_1[_i];
|
|
44009
44043
|
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
@@ -44322,8 +44356,8 @@ var ts;
|
|
|
44322
44356
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
44323
44357
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
44324
44358
|
if (!pathAndExtension && packageInfo
|
|
44325
|
-
|
|
44326
|
-
&& packageInfo.packageJsonContent.
|
|
44359
|
+
// eslint-disable-next-line no-null/no-null
|
|
44360
|
+
&& (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
|
|
44327
44361
|
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
44328
44362
|
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
44329
44363
|
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
@@ -47099,12 +47133,14 @@ var ts;
|
|
|
47099
47133
|
}
|
|
47100
47134
|
}
|
|
47101
47135
|
function setCommonJsModuleIndicator(node) {
|
|
47102
|
-
if (file.externalModuleIndicator) {
|
|
47136
|
+
if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
|
|
47103
47137
|
return false;
|
|
47104
47138
|
}
|
|
47105
47139
|
if (!file.commonJsModuleIndicator) {
|
|
47106
47140
|
file.commonJsModuleIndicator = node;
|
|
47107
|
-
|
|
47141
|
+
if (!file.externalModuleIndicator) {
|
|
47142
|
+
bindSourceFileAsExternalModule();
|
|
47143
|
+
}
|
|
47108
47144
|
}
|
|
47109
47145
|
return true;
|
|
47110
47146
|
}
|
|
@@ -47518,7 +47554,11 @@ var ts;
|
|
|
47518
47554
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
47519
47555
|
}
|
|
47520
47556
|
if (!ts.isBindingPattern(node.name)) {
|
|
47521
|
-
|
|
47557
|
+
var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent;
|
|
47558
|
+
if (ts.isInJSFile(node) &&
|
|
47559
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
|
|
47560
|
+
!ts.getJSDocTypeTag(node) &&
|
|
47561
|
+
!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
|
|
47522
47562
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
47523
47563
|
}
|
|
47524
47564
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -50345,7 +50385,8 @@ var ts;
|
|
|
50345
50385
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
50346
50386
|
|| node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
|
|
50347
50387
|
|| node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
50348
|
-
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50388
|
+
|| node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50389
|
+
|| node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
|
|
50349
50390
|
}
|
|
50350
50391
|
function isAliasableOrJsExpression(e) {
|
|
50351
50392
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -50438,7 +50479,7 @@ var ts;
|
|
|
50438
50479
|
return hasExportAssignmentSymbol(moduleSymbol);
|
|
50439
50480
|
}
|
|
50440
50481
|
// 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
|
|
50441
|
-
return
|
|
50482
|
+
return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
|
|
50442
50483
|
}
|
|
50443
50484
|
function getTargetOfImportClause(node, dontResolveAlias) {
|
|
50444
50485
|
var _a;
|
|
@@ -53553,6 +53594,7 @@ var ts;
|
|
|
53553
53594
|
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
53554
53595
|
}
|
|
53555
53596
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
53597
|
+
var _a, _b, _c, _d;
|
|
53556
53598
|
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
|
|
53557
53599
|
var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
|
|
53558
53600
|
if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
@@ -53570,6 +53612,7 @@ var ts;
|
|
|
53570
53612
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53571
53613
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
|
|
53572
53614
|
])));
|
|
53615
|
+
(_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
53573
53616
|
}
|
|
53574
53617
|
}
|
|
53575
53618
|
if (!specifier) {
|
|
@@ -53589,6 +53632,7 @@ var ts;
|
|
|
53589
53632
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53590
53633
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
|
|
53591
53634
|
])));
|
|
53635
|
+
(_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
53592
53636
|
}
|
|
53593
53637
|
}
|
|
53594
53638
|
if (!assertion) {
|
|
@@ -59077,7 +59121,7 @@ var ts;
|
|
|
59077
59121
|
var objectType;
|
|
59078
59122
|
return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
|
|
59079
59123
|
!isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
|
|
59080
|
-
!objectType.
|
|
59124
|
+
!(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType);
|
|
59081
59125
|
}
|
|
59082
59126
|
/**
|
|
59083
59127
|
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
|
@@ -59090,9 +59134,9 @@ var ts;
|
|
|
59090
59134
|
t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) :
|
|
59091
59135
|
t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType :
|
|
59092
59136
|
t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType :
|
|
59093
|
-
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(
|
|
59137
|
+
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() :
|
|
59094
59138
|
t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType :
|
|
59095
|
-
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(
|
|
59139
|
+
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() :
|
|
59096
59140
|
t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType :
|
|
59097
59141
|
t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType :
|
|
59098
59142
|
t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType :
|
|
@@ -60667,8 +60711,8 @@ var ts;
|
|
|
60667
60711
|
function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
|
|
60668
60712
|
return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
|
|
60669
60713
|
}
|
|
60670
|
-
function getGlobalESSymbolType(
|
|
60671
|
-
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60714
|
+
function getGlobalESSymbolType() {
|
|
60715
|
+
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60672
60716
|
}
|
|
60673
60717
|
function getGlobalPromiseType(reportErrors) {
|
|
60674
60718
|
return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
|
|
@@ -60732,8 +60776,8 @@ var ts;
|
|
|
60732
60776
|
deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
|
|
60733
60777
|
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
|
|
60734
60778
|
}
|
|
60735
|
-
function getGlobalBigIntType(
|
|
60736
|
-
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60779
|
+
function getGlobalBigIntType() {
|
|
60780
|
+
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60737
60781
|
}
|
|
60738
60782
|
/**
|
|
60739
60783
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
@@ -64885,7 +64929,7 @@ var ts;
|
|
|
64885
64929
|
if ((globalStringType === source && stringType === target) ||
|
|
64886
64930
|
(globalNumberType === source && numberType === target) ||
|
|
64887
64931
|
(globalBooleanType === source && booleanType === target) ||
|
|
64888
|
-
(getGlobalESSymbolType(
|
|
64932
|
+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
|
|
64889
64933
|
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
|
|
64890
64934
|
}
|
|
64891
64935
|
}
|
|
@@ -80828,8 +80872,11 @@ var ts;
|
|
|
80828
80872
|
if (node.assertions) {
|
|
80829
80873
|
var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
|
|
80830
80874
|
if (override) {
|
|
80875
|
+
if (!ts.isNightly()) {
|
|
80876
|
+
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);
|
|
80877
|
+
}
|
|
80831
80878
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
80832
|
-
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.
|
|
80879
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
80833
80880
|
}
|
|
80834
80881
|
}
|
|
80835
80882
|
}
|
|
@@ -82532,7 +82579,7 @@ var ts;
|
|
|
82532
82579
|
}
|
|
82533
82580
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
82534
82581
|
var symbol = getSymbolOfNode(node);
|
|
82535
|
-
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
82582
|
+
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) {
|
|
82536
82583
|
checkAliasSymbol(node);
|
|
82537
82584
|
return;
|
|
82538
82585
|
}
|
|
@@ -82697,7 +82744,7 @@ var ts;
|
|
|
82697
82744
|
var childSymbol = getSymbolAtLocation(childNode);
|
|
82698
82745
|
if (childSymbol && childSymbol === testedSymbol) {
|
|
82699
82746
|
// If the test was a simple identifier, the above check is sufficient
|
|
82700
|
-
if (ts.isIdentifier(expr)) {
|
|
82747
|
+
if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
|
|
82701
82748
|
return true;
|
|
82702
82749
|
}
|
|
82703
82750
|
// Otherwise we need to ensure the symbol is called on the same target
|
|
@@ -85200,10 +85247,10 @@ var ts;
|
|
|
85200
85247
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
85201
85248
|
if (validForTypeAssertions && override) {
|
|
85202
85249
|
if (!ts.isNightly()) {
|
|
85203
|
-
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85250
|
+
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);
|
|
85204
85251
|
}
|
|
85205
85252
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
85206
|
-
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85253
|
+
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
85207
85254
|
}
|
|
85208
85255
|
return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
|
|
85209
85256
|
}
|
|
@@ -108055,7 +108102,8 @@ var ts;
|
|
|
108055
108102
|
trackReferencedAmbientModule: trackReferencedAmbientModule,
|
|
108056
108103
|
trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
|
|
108057
108104
|
reportNonlocalAugmentation: reportNonlocalAugmentation,
|
|
108058
|
-
reportNonSerializableProperty: reportNonSerializableProperty
|
|
108105
|
+
reportNonSerializableProperty: reportNonSerializableProperty,
|
|
108106
|
+
reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
|
|
108059
108107
|
};
|
|
108060
108108
|
var errorNameNode;
|
|
108061
108109
|
var errorFallbackNode;
|
|
@@ -108182,6 +108230,11 @@ var ts;
|
|
|
108182
108230
|
context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
|
|
108183
108231
|
}
|
|
108184
108232
|
}
|
|
108233
|
+
function reportImportTypeNodeResolutionModeOverride() {
|
|
108234
|
+
if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
|
|
108235
|
+
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));
|
|
108236
|
+
}
|
|
108237
|
+
}
|
|
108185
108238
|
function transformDeclarationsForJS(sourceFile, bundled) {
|
|
108186
108239
|
var oldDiag = getSymbolAccessibilityDiagnostic;
|
|
108187
108240
|
getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
|
|
@@ -108632,7 +108685,7 @@ var ts;
|
|
|
108632
108685
|
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108633
108686
|
if (mode !== undefined) {
|
|
108634
108687
|
if (!ts.isNightly()) {
|
|
108635
|
-
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.
|
|
108688
|
+
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));
|
|
108636
108689
|
}
|
|
108637
108690
|
return assertClause;
|
|
108638
108691
|
}
|
|
@@ -116139,12 +116192,14 @@ var ts;
|
|
|
116139
116192
|
}
|
|
116140
116193
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
116141
116194
|
;
|
|
116142
|
-
|
|
116195
|
+
/**
|
|
116196
|
+
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
116197
|
+
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
116198
|
+
*/
|
|
116143
116199
|
function getModeForFileReference(ref, containingFileMode) {
|
|
116144
116200
|
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
116145
116201
|
}
|
|
116146
116202
|
ts.getModeForFileReference = getModeForFileReference;
|
|
116147
|
-
/* @internal */
|
|
116148
116203
|
function getModeForResolutionAtIndex(file, index) {
|
|
116149
116204
|
if (file.impliedNodeFormat === undefined)
|
|
116150
116205
|
return undefined;
|
|
@@ -116165,7 +116220,15 @@ var ts;
|
|
|
116165
116220
|
return false;
|
|
116166
116221
|
}
|
|
116167
116222
|
ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
|
|
116168
|
-
|
|
116223
|
+
/**
|
|
116224
|
+
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
|
116225
|
+
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
|
116226
|
+
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
|
116227
|
+
* `moduleResolution` is `node16`+.
|
|
116228
|
+
* @param file The file the import or import-like reference is contained within
|
|
116229
|
+
* @param usage The module reference string
|
|
116230
|
+
* @returns The final resolution mode of the import
|
|
116231
|
+
*/
|
|
116169
116232
|
function getModeForUsageLocation(file, usage) {
|
|
116170
116233
|
var _a, _b;
|
|
116171
116234
|
if (file.impliedNodeFormat === undefined)
|
|
@@ -118399,7 +118462,7 @@ var ts;
|
|
|
118399
118462
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
118400
118463
|
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
118401
118464
|
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118402
|
-
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.
|
|
118465
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
|
118403
118466
|
}
|
|
118404
118467
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
118405
118468
|
}
|
|
@@ -123692,6 +123755,7 @@ var ts;
|
|
|
123692
123755
|
}
|
|
123693
123756
|
function reloadFileNamesFromConfigFile() {
|
|
123694
123757
|
writeLog("Reloading new file names and options");
|
|
123758
|
+
reloadLevel = ts.ConfigFileProgramReloadLevel.None;
|
|
123695
123759
|
rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
|
123696
123760
|
if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
|
|
123697
123761
|
hasChangedConfigFileParsingErrors = true;
|
|
@@ -132013,10 +132077,9 @@ var ts;
|
|
|
132013
132077
|
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
|
132014
132078
|
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
|
132015
132079
|
})(GlobalsSearch || (GlobalsSearch = {}));
|
|
132016
|
-
function resolvingModuleSpecifiers(logPrefix, host,
|
|
132080
|
+
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
|
132017
132081
|
var _a, _b, _c;
|
|
132018
132082
|
var start = ts.timestamp();
|
|
132019
|
-
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
132020
132083
|
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
|
132021
132084
|
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
|
132022
132085
|
// relative path into node_modules), and we want to filter those completions out entirely.
|
|
@@ -132041,7 +132104,7 @@ var ts;
|
|
|
132041
132104
|
return result;
|
|
132042
132105
|
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
|
132043
132106
|
if (isFromAmbientModule) {
|
|
132044
|
-
var result_1 =
|
|
132107
|
+
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
|
132045
132108
|
if (result_1) {
|
|
132046
132109
|
ambientCount++;
|
|
132047
132110
|
}
|
|
@@ -132050,7 +132113,7 @@ var ts;
|
|
|
132050
132113
|
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
|
132051
132114
|
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
|
132052
132115
|
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
|
132053
|
-
?
|
|
132116
|
+
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
|
132054
132117
|
: undefined;
|
|
132055
132118
|
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
|
132056
132119
|
skippedAny = true;
|
|
@@ -132155,7 +132218,7 @@ var ts;
|
|
|
132155
132218
|
return undefined;
|
|
132156
132219
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
132157
132220
|
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
132158
|
-
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program,
|
|
132221
|
+
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
132159
132222
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
132160
132223
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
132161
132224
|
var _a;
|
|
@@ -133486,6 +133549,7 @@ var ts;
|
|
|
133486
133549
|
var hasUnresolvedAutoImports = false;
|
|
133487
133550
|
// This also gets mutated in nested-functions after the return
|
|
133488
133551
|
var symbols = [];
|
|
133552
|
+
var importSpecifierResolver;
|
|
133489
133553
|
var symbolToOriginInfoMap = [];
|
|
133490
133554
|
var symbolToSortTextMap = [];
|
|
133491
133555
|
var seenPropertySymbols = new ts.Map();
|
|
@@ -133707,14 +133771,14 @@ var ts;
|
|
|
133707
133771
|
}
|
|
133708
133772
|
else {
|
|
133709
133773
|
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
|
133710
|
-
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
|
133774
|
+
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
|
133711
133775
|
exportKind: 0 /* ExportKind.Named */,
|
|
133712
133776
|
moduleFileName: fileName,
|
|
133713
133777
|
isFromPackageJson: false,
|
|
133714
133778
|
moduleSymbol: moduleSymbol,
|
|
133715
133779
|
symbol: firstAccessibleSymbol,
|
|
133716
133780
|
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
|
133717
|
-
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)
|
|
133781
|
+
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
|
133718
133782
|
if (moduleSpecifier) {
|
|
133719
133783
|
var origin = {
|
|
133720
133784
|
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
|
@@ -133970,7 +134034,7 @@ var ts;
|
|
|
133970
134034
|
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
133971
134035
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
133972
134036
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
133973
|
-
resolvingModuleSpecifiers("collectAutoImports", host, program,
|
|
134037
|
+
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133974
134038
|
exportInfo.search(sourceFile.path,
|
|
133975
134039
|
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
133976
134040
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
@@ -136683,7 +136747,7 @@ var ts;
|
|
|
136683
136747
|
ts.Debug.assert(parent.name === node);
|
|
136684
136748
|
return true;
|
|
136685
136749
|
case 203 /* SyntaxKind.BindingElement */:
|
|
136686
|
-
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
|
|
136750
|
+
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
|
|
136687
136751
|
default:
|
|
136688
136752
|
return false;
|
|
136689
136753
|
}
|
|
@@ -138148,7 +138212,7 @@ var ts;
|
|
|
138148
138212
|
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
|
138149
138213
|
if (ts.isInJSFile(referenceLocation)
|
|
138150
138214
|
&& referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */
|
|
138151
|
-
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
|
|
138215
|
+
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
|
|
138152
138216
|
referenceSymbol = referenceLocation.parent.symbol;
|
|
138153
138217
|
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
|
|
138154
138218
|
// this case, just skip it, since the bound identifiers are not an alias of the import.
|
|
@@ -153001,6 +153065,18 @@ var ts;
|
|
|
153001
153065
|
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
|
153002
153066
|
}
|
|
153003
153067
|
}
|
|
153068
|
+
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
|
153069
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
|
153070
|
+
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
|
153071
|
+
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
|
153072
|
+
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
|
153073
|
+
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
|
153074
|
+
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
153075
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
|
153076
|
+
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
153077
|
+
}
|
|
153078
|
+
}
|
|
153079
|
+
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
|
153004
153080
|
// Sorted with the preferred fix coming first.
|
|
153005
153081
|
var ImportFixKind;
|
|
153006
153082
|
(function (ImportFixKind) {
|
|
@@ -153101,18 +153177,12 @@ var ts;
|
|
|
153101
153177
|
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
153102
153178
|
}
|
|
153103
153179
|
}
|
|
153104
|
-
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
|
153105
|
-
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
|
153106
|
-
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
153107
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
153108
|
-
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
153109
|
-
}
|
|
153110
|
-
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
153111
153180
|
function getImportFixes(exportInfos, useNamespaceInfo,
|
|
153112
153181
|
/** undefined only for missing JSX namespace */
|
|
153113
|
-
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
|
153182
|
+
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
|
153183
|
+
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
|
153114
153184
|
var checker = program.getTypeChecker();
|
|
153115
|
-
var existingImports = ts.flatMap(exportInfos,
|
|
153185
|
+
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
|
153116
153186
|
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
|
153117
153187
|
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
|
153118
153188
|
if (addToExisting) {
|
|
@@ -153240,21 +153310,37 @@ var ts;
|
|
|
153240
153310
|
};
|
|
153241
153311
|
});
|
|
153242
153312
|
}
|
|
153243
|
-
function
|
|
153244
|
-
var
|
|
153245
|
-
|
|
153246
|
-
|
|
153247
|
-
return ts.emptyArray;
|
|
153248
|
-
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
153249
|
-
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
|
153313
|
+
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
|
153314
|
+
var importMap;
|
|
153315
|
+
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
|
153316
|
+
var moduleSpecifier = _a[_i];
|
|
153250
153317
|
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
|
153251
153318
|
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
|
153252
|
-
|
|
153319
|
+
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
|
153320
|
+
if (moduleSymbol) {
|
|
153321
|
+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
|
153322
|
+
}
|
|
153323
|
+
}
|
|
153324
|
+
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
|
153325
|
+
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
|
153326
|
+
if (moduleSymbol) {
|
|
153327
|
+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
|
153328
|
+
}
|
|
153253
153329
|
}
|
|
153254
|
-
|
|
153255
|
-
|
|
153330
|
+
}
|
|
153331
|
+
return {
|
|
153332
|
+
getImportsForExportInfo: function (_a) {
|
|
153333
|
+
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
|
153334
|
+
// Can't use an es6 import for a type in JS.
|
|
153335
|
+
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
|
153336
|
+
return ts.emptyArray;
|
|
153337
|
+
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
|
153338
|
+
if (!matchingDeclarations)
|
|
153339
|
+
return ts.emptyArray;
|
|
153340
|
+
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
153341
|
+
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
|
153256
153342
|
}
|
|
153257
|
-
}
|
|
153343
|
+
};
|
|
153258
153344
|
}
|
|
153259
153345
|
function shouldUseRequire(sourceFile, program) {
|
|
153260
153346
|
// 1. TypeScript files don't use require variable declarations
|