typescript 4.6.0-dev.20220127 → 4.6.0-dev.20220131
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/cs/diagnosticMessages.generated.json +22 -8
- package/lib/de/diagnosticMessages.generated.json +22 -8
- package/lib/es/diagnosticMessages.generated.json +22 -8
- package/lib/fr/diagnosticMessages.generated.json +5 -4
- package/lib/it/diagnosticMessages.generated.json +22 -8
- package/lib/ja/diagnosticMessages.generated.json +22 -8
- package/lib/ko/diagnosticMessages.generated.json +5 -4
- package/lib/lib.dom.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +2 -0
- package/lib/pt-br/diagnosticMessages.generated.json +22 -8
- package/lib/ru/diagnosticMessages.generated.json +5 -4
- package/lib/tr/diagnosticMessages.generated.json +5 -4
- package/lib/tsc.js +59 -71
- package/lib/tsserver.js +196 -119
- package/lib/tsserverlibrary.js +196 -119
- package/lib/typescript.js +196 -119
- package/lib/typescriptServices.js +196 -119
- package/lib/typingsInstaller.js +70 -82
- package/lib/zh-cn/diagnosticMessages.generated.json +22 -8
- package/lib/zh-tw/diagnosticMessages.generated.json +22 -8
- 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 = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220131";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8049,7 +8049,7 @@ var ts;
|
|
|
8049
8049
|
}
|
|
8050
8050
|
})(ts || (ts = {}));
|
|
8051
8051
|
// <auto-generated />
|
|
8052
|
-
// generated from './
|
|
8052
|
+
// generated from './diagnosticMessages.json' in 'src/compiler'
|
|
8053
8053
|
/* @internal */
|
|
8054
8054
|
var ts;
|
|
8055
8055
|
(function (ts) {
|
|
@@ -9637,9 +9637,8 @@ var ts;
|
|
|
9637
9637
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
9638
9638
|
Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
|
|
9639
9639
|
Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
|
|
9640
|
-
|
|
9640
|
+
Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
|
|
9641
9641
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
9642
|
-
Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
|
|
9643
9642
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
9644
9643
|
Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
|
|
9645
9644
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
@@ -9656,8 +9655,6 @@ var ts;
|
|
|
9656
9655
|
Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
|
|
9657
9656
|
Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
|
|
9658
9657
|
Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
|
|
9659
|
-
Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
|
|
9660
|
-
Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
|
|
9661
9658
|
Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
|
|
9662
9659
|
Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
|
|
9663
9660
|
Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
|
|
@@ -9669,6 +9666,8 @@ var ts;
|
|
|
9669
9666
|
Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
|
|
9670
9667
|
Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
|
|
9671
9668
|
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9669
|
+
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9670
|
+
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9672
9671
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9673
9672
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9674
9673
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21067,6 +21066,59 @@ var ts;
|
|
|
21067
21066
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
21068
21067
|
}
|
|
21069
21068
|
ts.isThisTypeParameter = isThisTypeParameter;
|
|
21069
|
+
function getNodeModulePathParts(fullPath) {
|
|
21070
|
+
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
21071
|
+
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
21072
|
+
// Returns indices: ^ ^ ^ ^
|
|
21073
|
+
var topLevelNodeModulesIndex = 0;
|
|
21074
|
+
var topLevelPackageNameIndex = 0;
|
|
21075
|
+
var packageRootIndex = 0;
|
|
21076
|
+
var fileNameIndex = 0;
|
|
21077
|
+
var States;
|
|
21078
|
+
(function (States) {
|
|
21079
|
+
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
21080
|
+
States[States["NodeModules"] = 1] = "NodeModules";
|
|
21081
|
+
States[States["Scope"] = 2] = "Scope";
|
|
21082
|
+
States[States["PackageContent"] = 3] = "PackageContent";
|
|
21083
|
+
})(States || (States = {}));
|
|
21084
|
+
var partStart = 0;
|
|
21085
|
+
var partEnd = 0;
|
|
21086
|
+
var state = 0 /* BeforeNodeModules */;
|
|
21087
|
+
while (partEnd >= 0) {
|
|
21088
|
+
partStart = partEnd;
|
|
21089
|
+
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
21090
|
+
switch (state) {
|
|
21091
|
+
case 0 /* BeforeNodeModules */:
|
|
21092
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
21093
|
+
topLevelNodeModulesIndex = partStart;
|
|
21094
|
+
topLevelPackageNameIndex = partEnd;
|
|
21095
|
+
state = 1 /* NodeModules */;
|
|
21096
|
+
}
|
|
21097
|
+
break;
|
|
21098
|
+
case 1 /* NodeModules */:
|
|
21099
|
+
case 2 /* Scope */:
|
|
21100
|
+
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
21101
|
+
state = 2 /* Scope */;
|
|
21102
|
+
}
|
|
21103
|
+
else {
|
|
21104
|
+
packageRootIndex = partEnd;
|
|
21105
|
+
state = 3 /* PackageContent */;
|
|
21106
|
+
}
|
|
21107
|
+
break;
|
|
21108
|
+
case 3 /* PackageContent */:
|
|
21109
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
21110
|
+
state = 1 /* NodeModules */;
|
|
21111
|
+
}
|
|
21112
|
+
else {
|
|
21113
|
+
state = 3 /* PackageContent */;
|
|
21114
|
+
}
|
|
21115
|
+
break;
|
|
21116
|
+
}
|
|
21117
|
+
}
|
|
21118
|
+
fileNameIndex = partStart;
|
|
21119
|
+
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21120
|
+
}
|
|
21121
|
+
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
21070
21122
|
})(ts || (ts = {}));
|
|
21071
21123
|
/* @internal */
|
|
21072
21124
|
var ts;
|
|
@@ -48961,24 +49013,19 @@ var ts;
|
|
|
48961
49013
|
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
48962
49014
|
}
|
|
48963
49015
|
}
|
|
48964
|
-
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
|
|
48965
|
-
|
|
49016
|
+
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
49017
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
49018
|
+
if (typeOnlyDeclaration) {
|
|
49019
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
49020
|
+
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
49021
|
+
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49022
|
+
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
49023
|
+
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
49024
|
+
}
|
|
48966
49025
|
}
|
|
48967
49026
|
}
|
|
48968
49027
|
return result;
|
|
48969
49028
|
}
|
|
48970
|
-
function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
|
|
48971
|
-
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48972
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48973
|
-
if (typeOnlyDeclaration) {
|
|
48974
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48975
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48976
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48977
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48978
|
-
addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48979
|
-
}
|
|
48980
|
-
}
|
|
48981
|
-
}
|
|
48982
49029
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48983
49030
|
if (!typeOnlyDeclaration)
|
|
48984
49031
|
return diagnostic;
|
|
@@ -85875,7 +85922,7 @@ var ts;
|
|
|
85875
85922
|
if (quickResult !== undefined) {
|
|
85876
85923
|
return quickResult;
|
|
85877
85924
|
}
|
|
85878
|
-
var lastStatic, lastDeclare, lastAsync,
|
|
85925
|
+
var lastStatic, lastDeclare, lastAsync, lastOverride;
|
|
85879
85926
|
var flags = 0 /* None */;
|
|
85880
85927
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
85881
85928
|
var modifier = _a[_i];
|
|
@@ -85979,7 +86026,6 @@ var ts;
|
|
|
85979
86026
|
return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
|
|
85980
86027
|
}
|
|
85981
86028
|
flags |= 64 /* Readonly */;
|
|
85982
|
-
lastReadonly = modifier;
|
|
85983
86029
|
break;
|
|
85984
86030
|
case 93 /* ExportKeyword */:
|
|
85985
86031
|
if (flags & 1 /* Export */) {
|
|
@@ -86092,18 +86138,12 @@ var ts;
|
|
|
86092
86138
|
if (flags & 32 /* Static */) {
|
|
86093
86139
|
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
|
|
86094
86140
|
}
|
|
86095
|
-
if (flags & 128 /* Abstract */) {
|
|
86096
|
-
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
|
|
86097
|
-
}
|
|
86098
86141
|
if (flags & 16384 /* Override */) {
|
|
86099
86142
|
return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
|
|
86100
86143
|
}
|
|
86101
|
-
|
|
86144
|
+
if (flags & 256 /* Async */) {
|
|
86102
86145
|
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
|
|
86103
86146
|
}
|
|
86104
|
-
else if (flags & 64 /* Readonly */) {
|
|
86105
|
-
return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
|
|
86106
|
-
}
|
|
86107
86147
|
return false;
|
|
86108
86148
|
}
|
|
86109
86149
|
else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
|
|
@@ -120244,7 +120284,7 @@ var ts;
|
|
|
120244
120284
|
if (!host.fileExists || !host.readFile) {
|
|
120245
120285
|
return undefined;
|
|
120246
120286
|
}
|
|
120247
|
-
var parts = getNodeModulePathParts(path);
|
|
120287
|
+
var parts = ts.getNodeModulePathParts(path);
|
|
120248
120288
|
if (!parts) {
|
|
120249
120289
|
return undefined;
|
|
120250
120290
|
}
|
|
@@ -120367,58 +120407,6 @@ var ts;
|
|
|
120367
120407
|
}
|
|
120368
120408
|
}
|
|
120369
120409
|
}
|
|
120370
|
-
function getNodeModulePathParts(fullPath) {
|
|
120371
|
-
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
120372
|
-
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
120373
|
-
// Returns indices: ^ ^ ^ ^
|
|
120374
|
-
var topLevelNodeModulesIndex = 0;
|
|
120375
|
-
var topLevelPackageNameIndex = 0;
|
|
120376
|
-
var packageRootIndex = 0;
|
|
120377
|
-
var fileNameIndex = 0;
|
|
120378
|
-
var States;
|
|
120379
|
-
(function (States) {
|
|
120380
|
-
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
120381
|
-
States[States["NodeModules"] = 1] = "NodeModules";
|
|
120382
|
-
States[States["Scope"] = 2] = "Scope";
|
|
120383
|
-
States[States["PackageContent"] = 3] = "PackageContent";
|
|
120384
|
-
})(States || (States = {}));
|
|
120385
|
-
var partStart = 0;
|
|
120386
|
-
var partEnd = 0;
|
|
120387
|
-
var state = 0 /* BeforeNodeModules */;
|
|
120388
|
-
while (partEnd >= 0) {
|
|
120389
|
-
partStart = partEnd;
|
|
120390
|
-
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
120391
|
-
switch (state) {
|
|
120392
|
-
case 0 /* BeforeNodeModules */:
|
|
120393
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120394
|
-
topLevelNodeModulesIndex = partStart;
|
|
120395
|
-
topLevelPackageNameIndex = partEnd;
|
|
120396
|
-
state = 1 /* NodeModules */;
|
|
120397
|
-
}
|
|
120398
|
-
break;
|
|
120399
|
-
case 1 /* NodeModules */:
|
|
120400
|
-
case 2 /* Scope */:
|
|
120401
|
-
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
120402
|
-
state = 2 /* Scope */;
|
|
120403
|
-
}
|
|
120404
|
-
else {
|
|
120405
|
-
packageRootIndex = partEnd;
|
|
120406
|
-
state = 3 /* PackageContent */;
|
|
120407
|
-
}
|
|
120408
|
-
break;
|
|
120409
|
-
case 3 /* PackageContent */:
|
|
120410
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120411
|
-
state = 1 /* NodeModules */;
|
|
120412
|
-
}
|
|
120413
|
-
else {
|
|
120414
|
-
state = 3 /* PackageContent */;
|
|
120415
|
-
}
|
|
120416
|
-
break;
|
|
120417
|
-
}
|
|
120418
|
-
}
|
|
120419
|
-
fileNameIndex = partStart;
|
|
120420
|
-
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
120421
|
-
}
|
|
120422
120410
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120423
120411
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120424
120412
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
@@ -127305,6 +127293,17 @@ var ts;
|
|
|
127305
127293
|
var exportInfoId = 1;
|
|
127306
127294
|
var exportInfo = ts.createMultiMap();
|
|
127307
127295
|
var symbols = new ts.Map();
|
|
127296
|
+
/**
|
|
127297
|
+
* Key: node_modules package name (no @types).
|
|
127298
|
+
* Value: path to deepest node_modules folder seen that is
|
|
127299
|
+
* both visible to `usableByFileName` and contains the package.
|
|
127300
|
+
*
|
|
127301
|
+
* Later, we can see if a given SymbolExportInfo is shadowed by
|
|
127302
|
+
* a another installation of the same package in a deeper
|
|
127303
|
+
* node_modules folder by seeing if its path starts with the
|
|
127304
|
+
* value stored here.
|
|
127305
|
+
*/
|
|
127306
|
+
var packages = new ts.Map();
|
|
127308
127307
|
var usableByFileName;
|
|
127309
127308
|
var cache = {
|
|
127310
127309
|
isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
|
|
@@ -127319,6 +127318,27 @@ var ts;
|
|
|
127319
127318
|
cache.clear();
|
|
127320
127319
|
usableByFileName = importingFile;
|
|
127321
127320
|
}
|
|
127321
|
+
var packageName;
|
|
127322
|
+
if (moduleFile) {
|
|
127323
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
|
|
127324
|
+
if (nodeModulesPathParts) {
|
|
127325
|
+
var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
|
|
127326
|
+
packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
|
|
127327
|
+
if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
|
|
127328
|
+
var prevDeepestNodeModulesPath = packages.get(packageName);
|
|
127329
|
+
var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
|
|
127330
|
+
if (prevDeepestNodeModulesPath) {
|
|
127331
|
+
var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
|
|
127332
|
+
if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
|
|
127333
|
+
packages.set(packageName, nodeModulesPath);
|
|
127334
|
+
}
|
|
127335
|
+
}
|
|
127336
|
+
else {
|
|
127337
|
+
packages.set(packageName, nodeModulesPath);
|
|
127338
|
+
}
|
|
127339
|
+
}
|
|
127340
|
+
}
|
|
127341
|
+
}
|
|
127322
127342
|
var isDefault = exportKind === 1 /* Default */;
|
|
127323
127343
|
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127324
127344
|
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
|
|
@@ -127345,6 +127365,7 @@ var ts;
|
|
|
127345
127365
|
moduleName: moduleName,
|
|
127346
127366
|
moduleFile: moduleFile,
|
|
127347
127367
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
127368
|
+
packageName: packageName,
|
|
127348
127369
|
exportKind: exportKind,
|
|
127349
127370
|
targetFlags: target.flags,
|
|
127350
127371
|
isFromPackageJson: isFromPackageJson,
|
|
@@ -127364,13 +127385,16 @@ var ts;
|
|
|
127364
127385
|
exportInfo.forEach(function (info, key) {
|
|
127365
127386
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
127366
127387
|
var rehydrated = info.map(rehydrateCachedInfo);
|
|
127367
|
-
|
|
127368
|
-
|
|
127369
|
-
|
|
127370
|
-
|
|
127371
|
-
|
|
127372
|
-
|
|
127373
|
-
|
|
127388
|
+
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
|
|
127389
|
+
if (filtered.length) {
|
|
127390
|
+
action(filtered, function (preferCapitalized) {
|
|
127391
|
+
var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
|
|
127392
|
+
var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127393
|
+
return preferCapitalized
|
|
127394
|
+
? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
|
|
127395
|
+
: symbolName;
|
|
127396
|
+
}, !!ambientModuleName, key);
|
|
127397
|
+
}
|
|
127374
127398
|
});
|
|
127375
127399
|
},
|
|
127376
127400
|
releaseSymbols: function () {
|
|
@@ -127470,6 +127494,12 @@ var ts;
|
|
|
127470
127494
|
}
|
|
127471
127495
|
return true;
|
|
127472
127496
|
}
|
|
127497
|
+
function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
|
|
127498
|
+
if (!packageName || !info.moduleFileName)
|
|
127499
|
+
return true;
|
|
127500
|
+
var packageDeepestNodeModulesPath = packages.get(packageName);
|
|
127501
|
+
return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
|
|
127502
|
+
}
|
|
127473
127503
|
}
|
|
127474
127504
|
ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
|
|
127475
127505
|
function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
|
|
@@ -129780,7 +129810,7 @@ var ts;
|
|
|
129780
129810
|
}
|
|
129781
129811
|
switch (completionData.kind) {
|
|
129782
129812
|
case 0 /* Data */:
|
|
129783
|
-
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
|
|
129813
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
|
|
129784
129814
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
129785
129815
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
129786
129816
|
}
|
|
@@ -129900,7 +129930,7 @@ var ts;
|
|
|
129900
129930
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
129901
129931
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129902
129932
|
}
|
|
129903
|
-
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129933
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
129904
129934
|
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129905
129935
|
// Verify if the file is JSX language variant
|
|
129906
129936
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -129913,7 +129943,7 @@ var ts;
|
|
|
129913
129943
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129914
129944
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129915
129945
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129916
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129946
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129917
129947
|
}
|
|
129918
129948
|
else {
|
|
129919
129949
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
@@ -129923,16 +129953,23 @@ var ts;
|
|
|
129923
129953
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129924
129954
|
}
|
|
129925
129955
|
if (keywordFilters !== 0 /* None */) {
|
|
129926
|
-
var
|
|
129956
|
+
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129927
129957
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129928
129958
|
var keywordEntry = _a[_i];
|
|
129929
|
-
if (!
|
|
129959
|
+
if (!entryNames_1.has(keywordEntry.name)) {
|
|
129930
129960
|
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129931
129961
|
}
|
|
129932
129962
|
}
|
|
129933
129963
|
}
|
|
129934
|
-
|
|
129935
|
-
|
|
129964
|
+
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129965
|
+
for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
|
|
129966
|
+
var keywordEntry = _c[_b];
|
|
129967
|
+
if (!entryNames.has(keywordEntry.name)) {
|
|
129968
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129969
|
+
}
|
|
129970
|
+
}
|
|
129971
|
+
for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
|
|
129972
|
+
var literal = literals_1[_d];
|
|
129936
129973
|
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129937
129974
|
}
|
|
129938
129975
|
return {
|
|
@@ -132482,6 +132519,34 @@ var ts;
|
|
|
132482
132519
|
function keywordForNode(node) {
|
|
132483
132520
|
return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
|
|
132484
132521
|
}
|
|
132522
|
+
function getContextualKeywords(contextToken, position) {
|
|
132523
|
+
var entries = [];
|
|
132524
|
+
/**
|
|
132525
|
+
* An `AssertClause` can come after an import declaration:
|
|
132526
|
+
* import * from "foo" |
|
|
132527
|
+
* import "foo" |
|
|
132528
|
+
* or after a re-export declaration that has a module specifier:
|
|
132529
|
+
* export { foo } from "foo" |
|
|
132530
|
+
* Source: https://tc39.es/proposal-import-assertions/
|
|
132531
|
+
*/
|
|
132532
|
+
if (contextToken) {
|
|
132533
|
+
var file = contextToken.getSourceFile();
|
|
132534
|
+
var parent = contextToken.parent;
|
|
132535
|
+
var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
|
|
132536
|
+
var currentLine = file.getLineAndCharacterOfPosition(position).line;
|
|
132537
|
+
if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
|
|
132538
|
+
&& contextToken === parent.moduleSpecifier
|
|
132539
|
+
&& tokenLine === currentLine) {
|
|
132540
|
+
entries.push({
|
|
132541
|
+
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
132542
|
+
kind: "keyword" /* keyword */,
|
|
132543
|
+
kindModifiers: "" /* none */,
|
|
132544
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
132545
|
+
});
|
|
132546
|
+
}
|
|
132547
|
+
}
|
|
132548
|
+
return entries;
|
|
132549
|
+
}
|
|
132485
132550
|
/** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
|
|
132486
132551
|
function getJsDocTagAtPosition(node, position) {
|
|
132487
132552
|
return ts.findAncestor(node, function (n) {
|
|
@@ -149834,9 +149899,10 @@ var ts;
|
|
|
149834
149899
|
var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
|
|
149835
149900
|
if (!info)
|
|
149836
149901
|
return undefined;
|
|
149837
|
-
var fixes = info.fixes, symbolName = info.symbolName;
|
|
149902
|
+
var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
|
|
149838
149903
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
149839
|
-
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149904
|
+
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149905
|
+
/*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
|
|
149840
149906
|
},
|
|
149841
149907
|
fixIds: [importFixId],
|
|
149842
149908
|
getAllCodeActions: function (context) {
|
|
@@ -149875,7 +149941,7 @@ var ts;
|
|
|
149875
149941
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149876
149942
|
var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149877
149943
|
if (fix) {
|
|
149878
|
-
addImport({ fixes: [fix], symbolName: symbolName });
|
|
149944
|
+
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149879
149945
|
}
|
|
149880
149946
|
}
|
|
149881
149947
|
function addImport(info) {
|
|
@@ -150046,7 +150112,8 @@ var ts;
|
|
|
150046
150112
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
150047
150113
|
return {
|
|
150048
150114
|
moduleSpecifier: fix.moduleSpecifier,
|
|
150049
|
-
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150115
|
+
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150116
|
+
/*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
|
|
150050
150117
|
};
|
|
150051
150118
|
}
|
|
150052
150119
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
@@ -150054,7 +150121,8 @@ var ts;
|
|
|
150054
150121
|
var compilerOptions = program.getCompilerOptions();
|
|
150055
150122
|
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
150056
150123
|
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
150057
|
-
|
|
150124
|
+
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
|
|
150125
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
|
|
150058
150126
|
}
|
|
150059
150127
|
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
150060
150128
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
@@ -150347,7 +150415,7 @@ var ts;
|
|
|
150347
150415
|
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
150348
150416
|
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
150349
150417
|
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
150350
|
-
return fix && { fixes: [fix], symbolName: symbolName_1 };
|
|
150418
|
+
return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
|
|
150351
150419
|
}
|
|
150352
150420
|
else {
|
|
150353
150421
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
@@ -150392,6 +150460,7 @@ var ts;
|
|
|
150392
150460
|
return 0 /* EqualTo */;
|
|
150393
150461
|
}
|
|
150394
150462
|
function getFixesInfoForUMDImport(_a, token) {
|
|
150463
|
+
var _b;
|
|
150395
150464
|
var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
|
|
150396
150465
|
var checker = program.getTypeChecker();
|
|
150397
150466
|
var umdSymbol = getUmdSymbol(token, checker);
|
|
@@ -150402,7 +150471,7 @@ var ts;
|
|
|
150402
150471
|
var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150403
150472
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150404
150473
|
var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150405
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150474
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150406
150475
|
}
|
|
150407
150476
|
function getUmdSymbol(token, checker) {
|
|
150408
150477
|
// try the identifier to see if it is the umd symbol
|
|
@@ -150473,7 +150542,7 @@ var ts;
|
|
|
150473
150542
|
var _ = _a[0], exportInfos = _a[1];
|
|
150474
150543
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150475
150544
|
}));
|
|
150476
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150545
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
|
|
150477
150546
|
}
|
|
150478
150547
|
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
150479
150548
|
var checker = program.getTypeChecker();
|
|
@@ -150568,14 +150637,14 @@ var ts;
|
|
|
150568
150637
|
// allowSyntheticDefaultImports/esModuleInterop is enabled.
|
|
150569
150638
|
return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
|
|
150570
150639
|
}
|
|
150571
|
-
function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150640
|
+
function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150572
150641
|
var diag;
|
|
150573
150642
|
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
|
150574
|
-
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
|
|
150643
|
+
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
|
|
150575
150644
|
});
|
|
150576
150645
|
return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
|
|
150577
150646
|
}
|
|
150578
|
-
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150647
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150579
150648
|
switch (fix.kind) {
|
|
150580
150649
|
case 0 /* UseNamespace */:
|
|
150581
150650
|
addNamespaceQualifier(changes, sourceFile, fix);
|
|
@@ -150587,11 +150656,9 @@ var ts;
|
|
|
150587
150656
|
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
|
|
150588
150657
|
doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
|
|
150589
150658
|
var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
|
|
150590
|
-
return
|
|
150591
|
-
|
|
150592
|
-
|
|
150593
|
-
moduleSpecifierWithoutQuotes
|
|
150594
|
-
]; // you too!
|
|
150659
|
+
return includeSymbolNameInDescription
|
|
150660
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
|
|
150661
|
+
: [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
|
|
150595
150662
|
}
|
|
150596
150663
|
case 3 /* AddNew */: {
|
|
150597
150664
|
var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
|
|
@@ -150600,7 +150667,9 @@ var ts;
|
|
|
150600
150667
|
var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
|
|
150601
150668
|
var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
|
|
150602
150669
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
150603
|
-
return
|
|
150670
|
+
return includeSymbolNameInDescription
|
|
150671
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
|
|
150672
|
+
: [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
|
|
150604
150673
|
}
|
|
150605
150674
|
case 4 /* PromoteTypeOnly */: {
|
|
150606
150675
|
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
@@ -158460,14 +158529,22 @@ var ts;
|
|
|
158460
158529
|
var result = [];
|
|
158461
158530
|
return visitor(selection) ? undefined : result;
|
|
158462
158531
|
function visitor(node) {
|
|
158463
|
-
var _a;
|
|
158464
158532
|
if (ts.isTypeReferenceNode(node)) {
|
|
158465
158533
|
if (ts.isIdentifier(node.typeName)) {
|
|
158466
|
-
var
|
|
158467
|
-
var
|
|
158468
|
-
|
|
158469
|
-
|
|
158470
|
-
|
|
158534
|
+
var typeName = node.typeName;
|
|
158535
|
+
var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
|
|
158536
|
+
for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
|
|
158537
|
+
var decl = _a[_i];
|
|
158538
|
+
if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
|
|
158539
|
+
// skip extraction if the type node is in the range of the type parameter declaration.
|
|
158540
|
+
// function foo<T extends { a?: /**/T }>(): void;
|
|
158541
|
+
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
158542
|
+
return true;
|
|
158543
|
+
}
|
|
158544
|
+
if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
158545
|
+
ts.pushIfUnique(result, decl);
|
|
158546
|
+
break;
|
|
158547
|
+
}
|
|
158471
158548
|
}
|
|
158472
158549
|
}
|
|
158473
158550
|
}
|