typescript 4.6.0-dev.20220124 → 4.6.0-dev.20220128
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 +19 -4
- package/lib/de/diagnosticMessages.generated.json +19 -4
- package/lib/es/diagnosticMessages.generated.json +19 -4
- package/lib/fr/diagnosticMessages.generated.json +19 -4
- package/lib/ja/diagnosticMessages.generated.json +19 -4
- package/lib/ko/diagnosticMessages.generated.json +19 -4
- package/lib/lib.dom.d.ts +72 -0
- package/lib/lib.dom.iterable.d.ts +4 -0
- package/lib/lib.webworker.d.ts +48 -0
- package/lib/pl/diagnosticMessages.generated.json +17 -4
- package/lib/pt-br/diagnosticMessages.generated.json +19 -4
- package/lib/ru/diagnosticMessages.generated.json +19 -4
- package/lib/tr/diagnosticMessages.generated.json +17 -4
- package/lib/tsc.js +148 -90
- package/lib/tsserver.js +555 -202
- package/lib/tsserverlibrary.d.ts +9 -5
- package/lib/tsserverlibrary.js +555 -202
- package/lib/typescript.d.ts +9 -5
- package/lib/typescript.js +555 -202
- package/lib/typescriptServices.d.ts +9 -5
- package/lib/typescriptServices.js +555 -202
- package/lib/typingsInstaller.js +158 -100
- package/lib/zh-cn/diagnosticMessages.generated.json +19 -4
- package/lib/zh-tw/diagnosticMessages.generated.json +19 -4
- 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.20220128";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -305,13 +305,18 @@ var ts;
|
|
|
305
305
|
/* @internal */
|
|
306
306
|
var NativeCollections;
|
|
307
307
|
(function (NativeCollections) {
|
|
308
|
+
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
309
|
+
typeof global !== "undefined" ? global :
|
|
310
|
+
typeof self !== "undefined" ? self :
|
|
311
|
+
undefined;
|
|
308
312
|
/**
|
|
309
313
|
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
|
|
310
314
|
*/
|
|
311
315
|
function tryGetNativeMap() {
|
|
312
316
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
317
|
+
var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
|
|
313
318
|
// eslint-disable-next-line no-in-operator
|
|
314
|
-
return typeof
|
|
319
|
+
return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
315
320
|
}
|
|
316
321
|
NativeCollections.tryGetNativeMap = tryGetNativeMap;
|
|
317
322
|
/**
|
|
@@ -319,8 +324,9 @@ var ts;
|
|
|
319
324
|
*/
|
|
320
325
|
function tryGetNativeSet() {
|
|
321
326
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
327
|
+
var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
|
|
322
328
|
// eslint-disable-next-line no-in-operator
|
|
323
|
-
return typeof
|
|
329
|
+
return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
324
330
|
}
|
|
325
331
|
NativeCollections.tryGetNativeSet = tryGetNativeSet;
|
|
326
332
|
})(NativeCollections || (NativeCollections = {}));
|
|
@@ -9631,9 +9637,8 @@ var ts;
|
|
|
9631
9637
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
9632
9638
|
Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
|
|
9633
9639
|
Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
|
|
9634
|
-
|
|
9640
|
+
Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
|
|
9635
9641
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
9636
|
-
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}\""),
|
|
9637
9642
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
9638
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}'"),
|
|
9639
9644
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
@@ -9650,8 +9655,6 @@ var ts;
|
|
|
9650
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"),
|
|
9651
9656
|
Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
|
|
9652
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'"),
|
|
9653
|
-
Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
|
|
9654
|
-
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}\""),
|
|
9655
9658
|
Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
|
|
9656
9659
|
Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
|
|
9657
9660
|
Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
|
|
@@ -9661,6 +9664,10 @@ var ts;
|
|
|
9661
9664
|
Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
|
|
9662
9665
|
Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
|
|
9663
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}'"),
|
|
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}\""),
|
|
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}\""),
|
|
9664
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"),
|
|
9665
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}'"),
|
|
9666
9673
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -14251,10 +14258,13 @@ var ts;
|
|
|
14251
14258
|
function packageIdIsEqual(a, b) {
|
|
14252
14259
|
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
|
|
14253
14260
|
}
|
|
14254
|
-
function
|
|
14255
|
-
var name = _a.name, subModuleName = _a.subModuleName
|
|
14256
|
-
|
|
14257
|
-
|
|
14261
|
+
function packageIdToPackageName(_a) {
|
|
14262
|
+
var name = _a.name, subModuleName = _a.subModuleName;
|
|
14263
|
+
return subModuleName ? name + "/" + subModuleName : name;
|
|
14264
|
+
}
|
|
14265
|
+
ts.packageIdToPackageName = packageIdToPackageName;
|
|
14266
|
+
function packageIdToString(packageId) {
|
|
14267
|
+
return packageIdToPackageName(packageId) + "@" + packageId.version;
|
|
14258
14268
|
}
|
|
14259
14269
|
ts.packageIdToString = packageIdToString;
|
|
14260
14270
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
@@ -15087,6 +15097,15 @@ var ts;
|
|
|
15087
15097
|
};
|
|
15088
15098
|
}
|
|
15089
15099
|
ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
|
|
15100
|
+
function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
|
|
15101
|
+
return typeof diagnostic.messageText === "string" ? {
|
|
15102
|
+
code: diagnostic.code,
|
|
15103
|
+
category: diagnostic.category,
|
|
15104
|
+
messageText: diagnostic.messageText,
|
|
15105
|
+
next: diagnostic.next,
|
|
15106
|
+
} : diagnostic.messageText;
|
|
15107
|
+
}
|
|
15108
|
+
ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
|
|
15090
15109
|
function createDiagnosticForRange(sourceFile, range, message) {
|
|
15091
15110
|
return {
|
|
15092
15111
|
file: sourceFile,
|
|
@@ -15255,7 +15274,8 @@ var ts;
|
|
|
15255
15274
|
node.kind === 212 /* FunctionExpression */ ||
|
|
15256
15275
|
node.kind === 213 /* ArrowFunction */ ||
|
|
15257
15276
|
node.kind === 211 /* ParenthesizedExpression */ ||
|
|
15258
|
-
node.kind === 253 /* VariableDeclaration */
|
|
15277
|
+
node.kind === 253 /* VariableDeclaration */ ||
|
|
15278
|
+
node.kind === 274 /* ExportSpecifier */) ?
|
|
15259
15279
|
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
|
|
15260
15280
|
ts.getLeadingCommentRanges(text, node.pos);
|
|
15261
15281
|
// True if the comment starts with '/**' but not if it is '/**/'
|
|
@@ -21046,6 +21066,59 @@ var ts;
|
|
|
21046
21066
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
21047
21067
|
}
|
|
21048
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;
|
|
21049
21122
|
})(ts || (ts = {}));
|
|
21050
21123
|
/* @internal */
|
|
21051
21124
|
var ts;
|
|
@@ -36406,7 +36479,8 @@ var ts;
|
|
|
36406
36479
|
return finishNode(node, pos);
|
|
36407
36480
|
}
|
|
36408
36481
|
function parseExportSpecifier() {
|
|
36409
|
-
|
|
36482
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
36483
|
+
return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
|
|
36410
36484
|
}
|
|
36411
36485
|
function parseImportSpecifier() {
|
|
36412
36486
|
return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
|
|
@@ -43611,14 +43685,12 @@ var ts;
|
|
|
43611
43685
|
}
|
|
43612
43686
|
var binder = createBinder();
|
|
43613
43687
|
function bindSourceFile(file, options) {
|
|
43614
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
|
|
43615
43688
|
ts.performance.mark("beforeBind");
|
|
43616
43689
|
ts.perfLogger.logStartBindFile("" + file.fileName);
|
|
43617
43690
|
binder(file, options);
|
|
43618
43691
|
ts.perfLogger.logStopBindFile();
|
|
43619
43692
|
ts.performance.mark("afterBind");
|
|
43620
43693
|
ts.performance.measure("Bind", "beforeBind", "afterBind");
|
|
43621
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43622
43694
|
}
|
|
43623
43695
|
ts.bindSourceFile = bindSourceFile;
|
|
43624
43696
|
function createBinder() {
|
|
@@ -43678,7 +43750,9 @@ var ts;
|
|
|
43678
43750
|
ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
|
|
43679
43751
|
ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
|
|
43680
43752
|
if (!file.locals) {
|
|
43753
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
|
|
43681
43754
|
bind(file);
|
|
43755
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43682
43756
|
file.symbolCount = symbolCount;
|
|
43683
43757
|
file.classifiableNames = classifiableNames;
|
|
43684
43758
|
delayedBindJSDocTypedefTag();
|
|
@@ -47945,6 +48019,9 @@ var ts;
|
|
|
47945
48019
|
suggestionDiagnostics.add(diagnostic);
|
|
47946
48020
|
return diagnostic;
|
|
47947
48021
|
}
|
|
48022
|
+
function isDeprecatedSymbol(symbol) {
|
|
48023
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
|
|
48024
|
+
}
|
|
47948
48025
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
47949
48026
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
47950
48027
|
return addDeprecatedSuggestionWorker(declarations, diagnostic);
|
|
@@ -48936,24 +49013,19 @@ var ts;
|
|
|
48936
49013
|
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
48937
49014
|
}
|
|
48938
49015
|
}
|
|
48939
|
-
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
|
|
48940
|
-
|
|
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
|
+
}
|
|
48941
49025
|
}
|
|
48942
49026
|
}
|
|
48943
49027
|
return result;
|
|
48944
49028
|
}
|
|
48945
|
-
function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
|
|
48946
|
-
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48947
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48948
|
-
if (typeOnlyDeclaration) {
|
|
48949
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48950
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48951
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48952
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48953
|
-
addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48954
|
-
}
|
|
48955
|
-
}
|
|
48956
|
-
}
|
|
48957
49029
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48958
49030
|
if (!typeOnlyDeclaration)
|
|
48959
49031
|
return diagnostic;
|
|
@@ -52715,7 +52787,8 @@ var ts;
|
|
|
52715
52787
|
includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
|
|
52716
52788
|
}
|
|
52717
52789
|
if (ts.isIdentifier(node)) {
|
|
52718
|
-
var
|
|
52790
|
+
var type = getDeclaredTypeOfSymbol(sym);
|
|
52791
|
+
var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
|
|
52719
52792
|
name.symbol = sym; // for quickinfo, which uses identifier symbol information
|
|
52720
52793
|
return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
52721
52794
|
}
|
|
@@ -60731,7 +60804,7 @@ var ts;
|
|
|
60731
60804
|
}
|
|
60732
60805
|
var prop = getPropertyOfType(objectType, propName);
|
|
60733
60806
|
if (prop) {
|
|
60734
|
-
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations &&
|
|
60807
|
+
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
|
|
60735
60808
|
var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
|
|
60736
60809
|
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
|
|
60737
60810
|
}
|
|
@@ -70134,9 +70207,9 @@ var ts;
|
|
|
70134
70207
|
markAliasReferenced(symbol, node);
|
|
70135
70208
|
}
|
|
70136
70209
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
70137
|
-
var
|
|
70138
|
-
if (
|
|
70139
|
-
addDeprecatedSuggestion(node,
|
|
70210
|
+
var targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
|
|
70211
|
+
if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
|
|
70212
|
+
addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
|
|
70140
70213
|
}
|
|
70141
70214
|
var declaration = localOrExportSymbol.valueDeclaration;
|
|
70142
70215
|
if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
|
|
@@ -73148,7 +73221,7 @@ var ts;
|
|
|
73148
73221
|
}
|
|
73149
73222
|
}
|
|
73150
73223
|
else {
|
|
73151
|
-
if (
|
|
73224
|
+
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
73152
73225
|
addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
|
|
73153
73226
|
}
|
|
73154
73227
|
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
|
|
@@ -74607,7 +74680,7 @@ var ts;
|
|
|
74607
74680
|
}
|
|
74608
74681
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
74609
74682
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
74610
|
-
var chain = ts.chainDiagnosticMessages(ts.map(diags_3,
|
|
74683
|
+
var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
|
|
74611
74684
|
// The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input
|
|
74612
74685
|
// arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
|
|
74613
74686
|
var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
|
|
@@ -82986,16 +83059,15 @@ var ts;
|
|
|
82986
83059
|
return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
|
|
82987
83060
|
case 206 /* ElementAccessExpression */:
|
|
82988
83061
|
case 205 /* PropertyAccessExpression */:
|
|
82989
|
-
|
|
82990
|
-
|
|
82991
|
-
var type = getTypeOfExpression(ex.expression);
|
|
83062
|
+
if (isConstantMemberAccess(expr)) {
|
|
83063
|
+
var type = getTypeOfExpression(expr.expression);
|
|
82992
83064
|
if (type.symbol && type.symbol.flags & 384 /* Enum */) {
|
|
82993
83065
|
var name = void 0;
|
|
82994
|
-
if (
|
|
82995
|
-
name =
|
|
83066
|
+
if (expr.kind === 205 /* PropertyAccessExpression */) {
|
|
83067
|
+
name = expr.name.escapedText;
|
|
82996
83068
|
}
|
|
82997
83069
|
else {
|
|
82998
|
-
name = ts.escapeLeadingUnderscores(ts.cast(
|
|
83070
|
+
name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
|
|
82999
83071
|
}
|
|
83000
83072
|
return evaluateEnumMember(expr, type.symbol, name);
|
|
83001
83073
|
}
|
|
@@ -83023,6 +83095,10 @@ var ts;
|
|
|
83023
83095
|
}
|
|
83024
83096
|
}
|
|
83025
83097
|
function isConstantMemberAccess(node) {
|
|
83098
|
+
var type = getTypeOfExpression(node);
|
|
83099
|
+
if (type === errorType) {
|
|
83100
|
+
return false;
|
|
83101
|
+
}
|
|
83026
83102
|
return node.kind === 79 /* Identifier */ ||
|
|
83027
83103
|
node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
|
|
83028
83104
|
node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
|
|
@@ -83317,7 +83393,6 @@ var ts;
|
|
|
83317
83393
|
return true;
|
|
83318
83394
|
}
|
|
83319
83395
|
function checkAliasSymbol(node) {
|
|
83320
|
-
var _a;
|
|
83321
83396
|
var symbol = getSymbolOfNode(node);
|
|
83322
83397
|
var target = resolveAlias(symbol);
|
|
83323
83398
|
if (target !== unknownSymbol) {
|
|
@@ -83373,10 +83448,45 @@ var ts;
|
|
|
83373
83448
|
}
|
|
83374
83449
|
}
|
|
83375
83450
|
}
|
|
83376
|
-
if (ts.isImportSpecifier(node)
|
|
83377
|
-
|
|
83451
|
+
if (ts.isImportSpecifier(node)) {
|
|
83452
|
+
var targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
|
|
83453
|
+
if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
|
|
83454
|
+
addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
|
|
83455
|
+
}
|
|
83456
|
+
}
|
|
83457
|
+
}
|
|
83458
|
+
}
|
|
83459
|
+
function isDeprecatedAliasedSymbol(symbol) {
|
|
83460
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
|
|
83461
|
+
}
|
|
83462
|
+
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
83463
|
+
if (!(symbol.flags & 2097152 /* Alias */))
|
|
83464
|
+
return symbol;
|
|
83465
|
+
var targetSymbol = resolveAlias(symbol);
|
|
83466
|
+
if (targetSymbol === unknownSymbol)
|
|
83467
|
+
return targetSymbol;
|
|
83468
|
+
while (symbol.flags & 2097152 /* Alias */) {
|
|
83469
|
+
var target = getImmediateAliasedSymbol(symbol);
|
|
83470
|
+
if (target) {
|
|
83471
|
+
if (target === targetSymbol)
|
|
83472
|
+
break;
|
|
83473
|
+
if (target.declarations && ts.length(target.declarations)) {
|
|
83474
|
+
if (isDeprecatedAliasedSymbol(target)) {
|
|
83475
|
+
addDeprecatedSuggestion(location, target.declarations, target.escapedName);
|
|
83476
|
+
break;
|
|
83477
|
+
}
|
|
83478
|
+
else {
|
|
83479
|
+
if (symbol === targetSymbol)
|
|
83480
|
+
break;
|
|
83481
|
+
symbol = target;
|
|
83482
|
+
}
|
|
83483
|
+
}
|
|
83484
|
+
}
|
|
83485
|
+
else {
|
|
83486
|
+
break;
|
|
83378
83487
|
}
|
|
83379
83488
|
}
|
|
83489
|
+
return targetSymbol;
|
|
83380
83490
|
}
|
|
83381
83491
|
function checkImportBinding(node) {
|
|
83382
83492
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -116035,14 +116145,14 @@ var ts;
|
|
|
116035
116145
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
116036
116146
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
116037
116147
|
addFileIncludeReason(dupFile, reason);
|
|
116038
|
-
sourceFileToPackageName.set(path, packageId
|
|
116148
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
116039
116149
|
processingOtherFiles.push(dupFile);
|
|
116040
116150
|
return dupFile;
|
|
116041
116151
|
}
|
|
116042
116152
|
else if (file) {
|
|
116043
116153
|
// This is the first source file to have this packageId.
|
|
116044
116154
|
packageIdToSourceFile.set(packageIdKey, file);
|
|
116045
|
-
sourceFileToPackageName.set(path, packageId
|
|
116155
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
116046
116156
|
}
|
|
116047
116157
|
}
|
|
116048
116158
|
addFileToFilesByName(file, path, redirectedPath);
|
|
@@ -120181,7 +120291,7 @@ var ts;
|
|
|
120181
120291
|
if (!host.fileExists || !host.readFile) {
|
|
120182
120292
|
return undefined;
|
|
120183
120293
|
}
|
|
120184
|
-
var parts = getNodeModulePathParts(path);
|
|
120294
|
+
var parts = ts.getNodeModulePathParts(path);
|
|
120185
120295
|
if (!parts) {
|
|
120186
120296
|
return undefined;
|
|
120187
120297
|
}
|
|
@@ -120304,58 +120414,6 @@ var ts;
|
|
|
120304
120414
|
}
|
|
120305
120415
|
}
|
|
120306
120416
|
}
|
|
120307
|
-
function getNodeModulePathParts(fullPath) {
|
|
120308
|
-
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
120309
|
-
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
120310
|
-
// Returns indices: ^ ^ ^ ^
|
|
120311
|
-
var topLevelNodeModulesIndex = 0;
|
|
120312
|
-
var topLevelPackageNameIndex = 0;
|
|
120313
|
-
var packageRootIndex = 0;
|
|
120314
|
-
var fileNameIndex = 0;
|
|
120315
|
-
var States;
|
|
120316
|
-
(function (States) {
|
|
120317
|
-
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
120318
|
-
States[States["NodeModules"] = 1] = "NodeModules";
|
|
120319
|
-
States[States["Scope"] = 2] = "Scope";
|
|
120320
|
-
States[States["PackageContent"] = 3] = "PackageContent";
|
|
120321
|
-
})(States || (States = {}));
|
|
120322
|
-
var partStart = 0;
|
|
120323
|
-
var partEnd = 0;
|
|
120324
|
-
var state = 0 /* BeforeNodeModules */;
|
|
120325
|
-
while (partEnd >= 0) {
|
|
120326
|
-
partStart = partEnd;
|
|
120327
|
-
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
120328
|
-
switch (state) {
|
|
120329
|
-
case 0 /* BeforeNodeModules */:
|
|
120330
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120331
|
-
topLevelNodeModulesIndex = partStart;
|
|
120332
|
-
topLevelPackageNameIndex = partEnd;
|
|
120333
|
-
state = 1 /* NodeModules */;
|
|
120334
|
-
}
|
|
120335
|
-
break;
|
|
120336
|
-
case 1 /* NodeModules */:
|
|
120337
|
-
case 2 /* Scope */:
|
|
120338
|
-
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
120339
|
-
state = 2 /* Scope */;
|
|
120340
|
-
}
|
|
120341
|
-
else {
|
|
120342
|
-
packageRootIndex = partEnd;
|
|
120343
|
-
state = 3 /* PackageContent */;
|
|
120344
|
-
}
|
|
120345
|
-
break;
|
|
120346
|
-
case 3 /* PackageContent */:
|
|
120347
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120348
|
-
state = 1 /* NodeModules */;
|
|
120349
|
-
}
|
|
120350
|
-
else {
|
|
120351
|
-
state = 3 /* PackageContent */;
|
|
120352
|
-
}
|
|
120353
|
-
break;
|
|
120354
|
-
}
|
|
120355
|
-
}
|
|
120356
|
-
fileNameIndex = partStart;
|
|
120357
|
-
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
120358
|
-
}
|
|
120359
120417
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120360
120418
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120361
120419
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
@@ -127119,11 +127177,11 @@ var ts;
|
|
|
127119
127177
|
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
|
|
127120
127178
|
}
|
|
127121
127179
|
ts.firstOrOnly = firstOrOnly;
|
|
127122
|
-
function getNameForExportedSymbol(symbol, scriptTarget) {
|
|
127180
|
+
function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
|
|
127123
127181
|
if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
|
|
127124
127182
|
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
|
127125
127183
|
return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
|
|
127126
|
-
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
|
|
127184
|
+
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
|
|
127127
127185
|
}
|
|
127128
127186
|
return symbol.name;
|
|
127129
127187
|
}
|
|
@@ -127242,6 +127300,17 @@ var ts;
|
|
|
127242
127300
|
var exportInfoId = 1;
|
|
127243
127301
|
var exportInfo = ts.createMultiMap();
|
|
127244
127302
|
var symbols = new ts.Map();
|
|
127303
|
+
/**
|
|
127304
|
+
* Key: node_modules package name (no @types).
|
|
127305
|
+
* Value: path to deepest node_modules folder seen that is
|
|
127306
|
+
* both visible to `usableByFileName` and contains the package.
|
|
127307
|
+
*
|
|
127308
|
+
* Later, we can see if a given SymbolExportInfo is shadowed by
|
|
127309
|
+
* a another installation of the same package in a deeper
|
|
127310
|
+
* node_modules folder by seeing if its path starts with the
|
|
127311
|
+
* value stored here.
|
|
127312
|
+
*/
|
|
127313
|
+
var packages = new ts.Map();
|
|
127245
127314
|
var usableByFileName;
|
|
127246
127315
|
var cache = {
|
|
127247
127316
|
isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
|
|
@@ -127251,11 +127320,32 @@ var ts;
|
|
|
127251
127320
|
symbols.clear();
|
|
127252
127321
|
usableByFileName = undefined;
|
|
127253
127322
|
},
|
|
127254
|
-
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson,
|
|
127323
|
+
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
|
|
127255
127324
|
if (importingFile !== usableByFileName) {
|
|
127256
127325
|
cache.clear();
|
|
127257
127326
|
usableByFileName = importingFile;
|
|
127258
127327
|
}
|
|
127328
|
+
var packageName;
|
|
127329
|
+
if (moduleFile) {
|
|
127330
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
|
|
127331
|
+
if (nodeModulesPathParts) {
|
|
127332
|
+
var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
|
|
127333
|
+
packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
|
|
127334
|
+
if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
|
|
127335
|
+
var prevDeepestNodeModulesPath = packages.get(packageName);
|
|
127336
|
+
var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
|
|
127337
|
+
if (prevDeepestNodeModulesPath) {
|
|
127338
|
+
var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
|
|
127339
|
+
if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
|
|
127340
|
+
packages.set(packageName, nodeModulesPath);
|
|
127341
|
+
}
|
|
127342
|
+
}
|
|
127343
|
+
else {
|
|
127344
|
+
packages.set(packageName, nodeModulesPath);
|
|
127345
|
+
}
|
|
127346
|
+
}
|
|
127347
|
+
}
|
|
127348
|
+
}
|
|
127259
127349
|
var isDefault = exportKind === 1 /* Default */;
|
|
127260
127350
|
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127261
127351
|
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
|
|
@@ -127267,7 +127357,7 @@ var ts;
|
|
|
127267
127357
|
// get a better name.
|
|
127268
127358
|
var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
127269
127359
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
127270
|
-
: ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
|
|
127360
|
+
: ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
|
|
127271
127361
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
127272
127362
|
var id = exportInfoId++;
|
|
127273
127363
|
var target = ts.skipAlias(symbol, checker);
|
|
@@ -127282,6 +127372,7 @@ var ts;
|
|
|
127282
127372
|
moduleName: moduleName,
|
|
127283
127373
|
moduleFile: moduleFile,
|
|
127284
127374
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
127375
|
+
packageName: packageName,
|
|
127285
127376
|
exportKind: exportKind,
|
|
127286
127377
|
targetFlags: target.flags,
|
|
127287
127378
|
isFromPackageJson: isFromPackageJson,
|
|
@@ -127300,7 +127391,17 @@ var ts;
|
|
|
127300
127391
|
return;
|
|
127301
127392
|
exportInfo.forEach(function (info, key) {
|
|
127302
127393
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
127303
|
-
|
|
127394
|
+
var rehydrated = info.map(rehydrateCachedInfo);
|
|
127395
|
+
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
|
|
127396
|
+
if (filtered.length) {
|
|
127397
|
+
action(filtered, function (preferCapitalized) {
|
|
127398
|
+
var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
|
|
127399
|
+
var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127400
|
+
return preferCapitalized
|
|
127401
|
+
? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
|
|
127402
|
+
: symbolName;
|
|
127403
|
+
}, !!ambientModuleName, key);
|
|
127404
|
+
}
|
|
127304
127405
|
});
|
|
127305
127406
|
},
|
|
127306
127407
|
releaseSymbols: function () {
|
|
@@ -127400,6 +127501,12 @@ var ts;
|
|
|
127400
127501
|
}
|
|
127401
127502
|
return true;
|
|
127402
127503
|
}
|
|
127504
|
+
function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
|
|
127505
|
+
if (!packageName || !info.moduleFileName)
|
|
127506
|
+
return true;
|
|
127507
|
+
var packageDeepestNodeModulesPath = packages.get(packageName);
|
|
127508
|
+
return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
|
|
127509
|
+
}
|
|
127403
127510
|
}
|
|
127404
127511
|
ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
|
|
127405
127512
|
function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
|
|
@@ -127482,7 +127589,6 @@ var ts;
|
|
|
127482
127589
|
}
|
|
127483
127590
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
127484
127591
|
var compilerOptions = program.getCompilerOptions();
|
|
127485
|
-
var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
|
|
127486
127592
|
var moduleCount = 0;
|
|
127487
127593
|
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
127488
127594
|
if (++moduleCount % 100 === 0)
|
|
@@ -127493,11 +127599,11 @@ var ts;
|
|
|
127493
127599
|
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
127494
127600
|
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
127495
127601
|
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
127496
|
-
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson,
|
|
127602
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
127497
127603
|
}
|
|
127498
127604
|
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
127499
127605
|
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
127500
|
-
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson,
|
|
127606
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
127501
127607
|
}
|
|
127502
127608
|
});
|
|
127503
127609
|
});
|
|
@@ -129571,6 +129677,8 @@ var ts;
|
|
|
129571
129677
|
CompletionSource["ThisProperty"] = "ThisProperty/";
|
|
129572
129678
|
/** Auto-import that comes attached to a class member snippet */
|
|
129573
129679
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
129680
|
+
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
129681
|
+
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
129574
129682
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
129575
129683
|
var SymbolOriginInfoKind;
|
|
129576
129684
|
(function (SymbolOriginInfoKind) {
|
|
@@ -129580,6 +129688,7 @@ var ts;
|
|
|
129580
129688
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
|
|
129581
129689
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
129582
129690
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
129691
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
129583
129692
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
129584
129693
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
129585
129694
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -129607,6 +129716,9 @@ var ts;
|
|
|
129607
129716
|
function originIsNullableMember(origin) {
|
|
129608
129717
|
return !!(origin.kind & 16 /* Nullable */);
|
|
129609
129718
|
}
|
|
129719
|
+
function originIsTypeOnlyAlias(origin) {
|
|
129720
|
+
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
129721
|
+
}
|
|
129610
129722
|
var KeywordCompletionFilters;
|
|
129611
129723
|
(function (KeywordCompletionFilters) {
|
|
129612
129724
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -129705,7 +129817,7 @@ var ts;
|
|
|
129705
129817
|
}
|
|
129706
129818
|
switch (completionData.kind) {
|
|
129707
129819
|
case 0 /* Data */:
|
|
129708
|
-
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
|
|
129820
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
|
|
129709
129821
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
129710
129822
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
129711
129823
|
}
|
|
@@ -129825,7 +129937,7 @@ var ts;
|
|
|
129825
129937
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
129826
129938
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129827
129939
|
}
|
|
129828
|
-
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129940
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
129829
129941
|
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;
|
|
129830
129942
|
// Verify if the file is JSX language variant
|
|
129831
129943
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -129838,7 +129950,7 @@ var ts;
|
|
|
129838
129950
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129839
129951
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129840
129952
|
/*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);
|
|
129841
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129953
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129842
129954
|
}
|
|
129843
129955
|
else {
|
|
129844
129956
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
@@ -129848,16 +129960,23 @@ var ts;
|
|
|
129848
129960
|
/*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);
|
|
129849
129961
|
}
|
|
129850
129962
|
if (keywordFilters !== 0 /* None */) {
|
|
129851
|
-
var
|
|
129963
|
+
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129852
129964
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129853
129965
|
var keywordEntry = _a[_i];
|
|
129854
|
-
if (!
|
|
129966
|
+
if (!entryNames_1.has(keywordEntry.name)) {
|
|
129855
129967
|
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129856
129968
|
}
|
|
129857
129969
|
}
|
|
129858
129970
|
}
|
|
129859
|
-
|
|
129860
|
-
|
|
129971
|
+
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129972
|
+
for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
|
|
129973
|
+
var keywordEntry = _c[_b];
|
|
129974
|
+
if (!entryNames.has(keywordEntry.name)) {
|
|
129975
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129976
|
+
}
|
|
129977
|
+
}
|
|
129978
|
+
for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
|
|
129979
|
+
var literal = literals_1[_d];
|
|
129861
129980
|
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129862
129981
|
}
|
|
129863
129982
|
return {
|
|
@@ -130011,6 +130130,9 @@ var ts;
|
|
|
130011
130130
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
130012
130131
|
}
|
|
130013
130132
|
}
|
|
130133
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
130134
|
+
hasAction = true;
|
|
130135
|
+
}
|
|
130014
130136
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
130015
130137
|
preferences.includeCompletionsWithInsertText &&
|
|
130016
130138
|
completionKind === 3 /* MemberLike */ &&
|
|
@@ -130355,6 +130477,9 @@ var ts;
|
|
|
130355
130477
|
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
|
|
130356
130478
|
return CompletionSource.ThisProperty;
|
|
130357
130479
|
}
|
|
130480
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
130481
|
+
return CompletionSource.TypeOnlyAlias;
|
|
130482
|
+
}
|
|
130358
130483
|
}
|
|
130359
130484
|
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
130360
130485
|
var _a;
|
|
@@ -130382,7 +130507,7 @@ var ts;
|
|
|
130382
130507
|
continue;
|
|
130383
130508
|
}
|
|
130384
130509
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
130385
|
-
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
130510
|
+
var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
130386
130511
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
130387
130512
|
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
130388
130513
|
}
|
|
@@ -130395,6 +130520,7 @@ var ts;
|
|
|
130395
130520
|
add: function (name) { return uniques.set(name, true); },
|
|
130396
130521
|
};
|
|
130397
130522
|
function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
|
|
130523
|
+
var allFlags = symbol.flags;
|
|
130398
130524
|
if (!ts.isSourceFile(location)) {
|
|
130399
130525
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
130400
130526
|
if (ts.isExportAssignment(location.parent)) {
|
|
@@ -130420,11 +130546,10 @@ var ts;
|
|
|
130420
130546
|
|| symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
|
|
130421
130547
|
return false;
|
|
130422
130548
|
}
|
|
130423
|
-
|
|
130424
|
-
symbol = symbolOrigin;
|
|
130549
|
+
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
130425
130550
|
// import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
|
|
130426
130551
|
if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
|
|
130427
|
-
return !!(
|
|
130552
|
+
return !!(allFlags & 1920 /* Namespace */);
|
|
130428
130553
|
}
|
|
130429
130554
|
if (isTypeOnlyLocation) {
|
|
130430
130555
|
// It's a type, but you can reach it by namespace.type as well
|
|
@@ -130432,7 +130557,7 @@ var ts;
|
|
|
130432
130557
|
}
|
|
130433
130558
|
}
|
|
130434
130559
|
// expressions are value space (which includes the value namespaces)
|
|
130435
|
-
return !!(
|
|
130560
|
+
return !!(allFlags & 111551 /* Value */);
|
|
130436
130561
|
}
|
|
130437
130562
|
}
|
|
130438
130563
|
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
|
|
@@ -130566,8 +130691,7 @@ var ts;
|
|
|
130566
130691
|
Completions.createCompletionDetails = createCompletionDetails;
|
|
130567
130692
|
function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
|
|
130568
130693
|
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
|
|
130569
|
-
|
|
130570
|
-
if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
|
|
130694
|
+
if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
|
|
130571
130695
|
// Import statement completion: 'import c|'
|
|
130572
130696
|
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
|
|
130573
130697
|
}
|
|
@@ -130585,13 +130709,19 @@ var ts;
|
|
|
130585
130709
|
};
|
|
130586
130710
|
}
|
|
130587
130711
|
}
|
|
130712
|
+
if (originIsTypeOnlyAlias(origin)) {
|
|
130713
|
+
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
130714
|
+
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
130715
|
+
return { codeActions: [codeAction_1], sourceDisplay: undefined };
|
|
130716
|
+
}
|
|
130588
130717
|
if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
|
|
130589
130718
|
return { codeActions: undefined, sourceDisplay: undefined };
|
|
130590
130719
|
}
|
|
130591
130720
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
130592
130721
|
var moduleSymbol = origin.moduleSymbol;
|
|
130593
130722
|
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
130594
|
-
var
|
|
130723
|
+
var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
|
|
130724
|
+
var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
|
|
130595
130725
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
130596
130726
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
130597
130727
|
}
|
|
@@ -131261,21 +131391,29 @@ var ts;
|
|
|
131261
131391
|
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
|
131262
131392
|
isInSnippetScope = isSnippetScope(scopeNode);
|
|
131263
131393
|
var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
|
|
131394
|
+
var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
|
|
131264
131395
|
symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
|
|
131265
131396
|
ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
|
|
131266
|
-
for (var
|
|
131267
|
-
var symbol =
|
|
131397
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
131398
|
+
var symbol = symbols[i];
|
|
131268
131399
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
131269
131400
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
131270
131401
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
|
|
131271
131402
|
}
|
|
131403
|
+
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
131404
|
+
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
131405
|
+
if (typeOnlyAliasDeclaration) {
|
|
131406
|
+
var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
|
|
131407
|
+
symbolToOriginInfoMap[i] = origin;
|
|
131408
|
+
}
|
|
131409
|
+
}
|
|
131272
131410
|
}
|
|
131273
131411
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
131274
131412
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
|
|
131275
131413
|
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
131276
131414
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
131277
|
-
for (var
|
|
131278
|
-
var symbol =
|
|
131415
|
+
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
131416
|
+
var symbol = _a[_i];
|
|
131279
131417
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
131280
131418
|
symbols.push(symbol);
|
|
131281
131419
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
|
|
@@ -131378,7 +131516,8 @@ var ts;
|
|
|
131378
131516
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
131379
131517
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
131380
131518
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
131381
|
-
exportInfo.forEach(sourceFile.path, function (info,
|
|
131519
|
+
exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
|
|
131520
|
+
var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
|
|
131382
131521
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
131383
131522
|
return;
|
|
131384
131523
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
@@ -131388,6 +131527,10 @@ var ts;
|
|
|
131388
131527
|
return;
|
|
131389
131528
|
if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
131390
131529
|
return;
|
|
131530
|
+
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
131531
|
+
var firstChar = symbolName.charCodeAt(0);
|
|
131532
|
+
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
131533
|
+
return;
|
|
131391
131534
|
var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
|
|
131392
131535
|
if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
|
|
131393
131536
|
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
@@ -131464,16 +131607,19 @@ var ts;
|
|
|
131464
131607
|
return true;
|
|
131465
131608
|
}
|
|
131466
131609
|
if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
|
|
131610
|
+
// <Component<string> /**/ />
|
|
131611
|
+
// <Component<string> /**/ ><Component>
|
|
131612
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131613
|
+
// - location: JsxSelfClosingElement or JsxOpeningElement
|
|
131614
|
+
// - contextToken.parent === location
|
|
131615
|
+
if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
|
|
131616
|
+
return false;
|
|
131617
|
+
}
|
|
131467
131618
|
if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
|
|
131468
|
-
//
|
|
131469
|
-
//
|
|
131470
|
-
//
|
|
131471
|
-
//
|
|
131472
|
-
// - different parents (JSXOpeningElement, JSXElement)
|
|
131473
|
-
// 2. <Component<string> /**/>
|
|
131474
|
-
// - contextToken: GreaterThanToken (before cursor)
|
|
131475
|
-
// - location: GreaterThanToken (after cursor)
|
|
131476
|
-
// - same parent (JSXOpeningElement)
|
|
131619
|
+
// <div>/**/
|
|
131620
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131621
|
+
// - location: JSXElement
|
|
131622
|
+
// - different parents (JSXOpeningElement, JSXElement)
|
|
131477
131623
|
return location.parent.kind !== 279 /* JsxOpeningElement */;
|
|
131478
131624
|
}
|
|
131479
131625
|
if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
|
|
@@ -132380,6 +132526,34 @@ var ts;
|
|
|
132380
132526
|
function keywordForNode(node) {
|
|
132381
132527
|
return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
|
|
132382
132528
|
}
|
|
132529
|
+
function getContextualKeywords(contextToken, position) {
|
|
132530
|
+
var entries = [];
|
|
132531
|
+
/**
|
|
132532
|
+
* An `AssertClause` can come after an import declaration:
|
|
132533
|
+
* import * from "foo" |
|
|
132534
|
+
* import "foo" |
|
|
132535
|
+
* or after a re-export declaration that has a module specifier:
|
|
132536
|
+
* export { foo } from "foo" |
|
|
132537
|
+
* Source: https://tc39.es/proposal-import-assertions/
|
|
132538
|
+
*/
|
|
132539
|
+
if (contextToken) {
|
|
132540
|
+
var file = contextToken.getSourceFile();
|
|
132541
|
+
var parent = contextToken.parent;
|
|
132542
|
+
var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
|
|
132543
|
+
var currentLine = file.getLineAndCharacterOfPosition(position).line;
|
|
132544
|
+
if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
|
|
132545
|
+
&& contextToken === parent.moduleSpecifier
|
|
132546
|
+
&& tokenLine === currentLine) {
|
|
132547
|
+
entries.push({
|
|
132548
|
+
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
132549
|
+
kind: "keyword" /* keyword */,
|
|
132550
|
+
kindModifiers: "" /* none */,
|
|
132551
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
132552
|
+
});
|
|
132553
|
+
}
|
|
132554
|
+
}
|
|
132555
|
+
return entries;
|
|
132556
|
+
}
|
|
132383
132557
|
/** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
|
|
132384
132558
|
function getJsDocTagAtPosition(node, position) {
|
|
132385
132559
|
return ts.findAncestor(node, function (n) {
|
|
@@ -132674,10 +132848,14 @@ var ts;
|
|
|
132674
132848
|
/** True if symbol is a type or a module containing at least one type. */
|
|
132675
132849
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
132676
132850
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
132677
|
-
|
|
132678
|
-
|
|
132679
|
-
|
|
132680
|
-
|
|
132851
|
+
// Since an alias can be merged with a local declaration, we need to test both the alias and its target.
|
|
132852
|
+
// This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
|
|
132853
|
+
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
132854
|
+
function nonAliasCanBeReferencedAtTypeLocation(symbol) {
|
|
132855
|
+
return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
|
|
132856
|
+
!!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
|
|
132857
|
+
checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
|
|
132858
|
+
}
|
|
132681
132859
|
}
|
|
132682
132860
|
function isDeprecated(symbol, checker) {
|
|
132683
132861
|
var declarations = ts.skipAlias(symbol, checker).declarations;
|
|
@@ -134931,8 +135109,8 @@ var ts;
|
|
|
134931
135109
|
var sourceId = ts.getNodeId(sourceFile);
|
|
134932
135110
|
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
|
|
134933
135111
|
var anyNewSymbols = false;
|
|
134934
|
-
for (var _i = 0,
|
|
134935
|
-
var sym =
|
|
135112
|
+
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
135113
|
+
var sym = symbols_1[_i];
|
|
134936
135114
|
anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
|
|
134937
135115
|
}
|
|
134938
135116
|
return anyNewSymbols;
|
|
@@ -141892,6 +142070,8 @@ var ts;
|
|
|
141892
142070
|
}
|
|
141893
142071
|
if (flags & 16 /* Function */)
|
|
141894
142072
|
return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
|
|
142073
|
+
// FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag.
|
|
142074
|
+
// So, even when the location is just on the declaration of setter, this function returns getter.
|
|
141895
142075
|
if (flags & 32768 /* GetAccessor */)
|
|
141896
142076
|
return "getter" /* memberGetAccessorElement */;
|
|
141897
142077
|
if (flags & 65536 /* SetAccessor */)
|
|
@@ -141978,9 +142158,24 @@ var ts;
|
|
|
141978
142158
|
}
|
|
141979
142159
|
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
|
141980
142160
|
if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
|
|
141981
|
-
// If
|
|
142161
|
+
// If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
|
|
141982
142162
|
if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
|
|
141983
|
-
|
|
142163
|
+
var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
|
|
142164
|
+
if (declaration) {
|
|
142165
|
+
switch (declaration.kind) {
|
|
142166
|
+
case 171 /* GetAccessor */:
|
|
142167
|
+
symbolKind = "getter" /* memberGetAccessorElement */;
|
|
142168
|
+
break;
|
|
142169
|
+
case 172 /* SetAccessor */:
|
|
142170
|
+
symbolKind = "setter" /* memberSetAccessorElement */;
|
|
142171
|
+
break;
|
|
142172
|
+
default:
|
|
142173
|
+
ts.Debug.assertNever(declaration);
|
|
142174
|
+
}
|
|
142175
|
+
}
|
|
142176
|
+
else {
|
|
142177
|
+
symbolKind = "property" /* memberVariableElement */;
|
|
142178
|
+
}
|
|
141984
142179
|
}
|
|
141985
142180
|
var signature = void 0;
|
|
141986
142181
|
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -142294,6 +142489,8 @@ var ts;
|
|
|
142294
142489
|
}
|
|
142295
142490
|
// For properties, variables and local vars: show the type
|
|
142296
142491
|
if (symbolKind === "property" /* memberVariableElement */ ||
|
|
142492
|
+
symbolKind === "getter" /* memberGetAccessorElement */ ||
|
|
142493
|
+
symbolKind === "setter" /* memberSetAccessorElement */ ||
|
|
142297
142494
|
symbolKind === "JSX attribute" /* jsxAttribute */ ||
|
|
142298
142495
|
symbolFlags & 3 /* Variable */ ||
|
|
142299
142496
|
symbolKind === "local var" /* localVariableElement */ ||
|
|
@@ -142364,7 +142561,7 @@ var ts;
|
|
|
142364
142561
|
}
|
|
142365
142562
|
}
|
|
142366
142563
|
if (tags.length === 0 && !hasMultipleSignatures) {
|
|
142367
|
-
tags = symbol.
|
|
142564
|
+
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
|
|
142368
142565
|
}
|
|
142369
142566
|
if (documentation.length === 0 && documentationFromAlias) {
|
|
142370
142567
|
documentation = documentationFromAlias;
|
|
@@ -145784,6 +145981,7 @@ var ts;
|
|
|
145784
145981
|
ChangeTracker.prototype.delete = function (sourceFile, node) {
|
|
145785
145982
|
this.deletedNodes.push({ sourceFile: sourceFile, node: node });
|
|
145786
145983
|
};
|
|
145984
|
+
/** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
|
|
145787
145985
|
ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
|
|
145788
145986
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
145789
145987
|
this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
|
|
@@ -146187,6 +146385,15 @@ var ts;
|
|
|
146187
146385
|
ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
|
|
146188
146386
|
this.insertText(sourceFile, node.getStart(sourceFile), "export ");
|
|
146189
146387
|
};
|
|
146388
|
+
ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
|
|
146389
|
+
var prevSpecifier = namedImports.elements[index - 1];
|
|
146390
|
+
if (prevSpecifier) {
|
|
146391
|
+
this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
|
|
146392
|
+
}
|
|
146393
|
+
else {
|
|
146394
|
+
this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
|
|
146395
|
+
}
|
|
146396
|
+
};
|
|
146190
146397
|
/**
|
|
146191
146398
|
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
|
|
146192
146399
|
* i.e. arguments in arguments lists, parameters in parameter lists etc.
|
|
@@ -149689,7 +149896,8 @@ var ts;
|
|
|
149689
149896
|
ts.Diagnostics.Cannot_find_namespace_0.code,
|
|
149690
149897
|
ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
|
|
149691
149898
|
ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
|
|
149692
|
-
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
|
|
149899
|
+
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
|
|
149900
|
+
ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
|
|
149693
149901
|
];
|
|
149694
149902
|
codefix.registerCodeFix({
|
|
149695
149903
|
errorCodes: errorCodes,
|
|
@@ -149698,9 +149906,10 @@ var ts;
|
|
|
149698
149906
|
var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
|
|
149699
149907
|
if (!info)
|
|
149700
149908
|
return undefined;
|
|
149701
|
-
var fixes = info.fixes, symbolName = info.symbolName;
|
|
149909
|
+
var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
|
|
149702
149910
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
149703
|
-
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149911
|
+
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149912
|
+
/*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
|
|
149704
149913
|
},
|
|
149705
149914
|
fixIds: [importFixId],
|
|
149706
149915
|
getAllCodeActions: function (context) {
|
|
@@ -149735,11 +149944,11 @@ var ts;
|
|
|
149735
149944
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149736
149945
|
var checker = program.getTypeChecker();
|
|
149737
149946
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149738
|
-
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
|
|
149947
|
+
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149739
149948
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149740
149949
|
var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149741
149950
|
if (fix) {
|
|
149742
|
-
addImport({ fixes: [fix], symbolName: symbolName });
|
|
149951
|
+
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149743
149952
|
}
|
|
149744
149953
|
}
|
|
149745
149954
|
function addImport(info) {
|
|
@@ -149794,6 +150003,9 @@ var ts;
|
|
|
149794
150003
|
}
|
|
149795
150004
|
break;
|
|
149796
150005
|
}
|
|
150006
|
+
case 4 /* PromoteTypeOnly */:
|
|
150007
|
+
// Excluding from fix-all
|
|
150008
|
+
break;
|
|
149797
150009
|
default:
|
|
149798
150010
|
ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
|
|
149799
150011
|
}
|
|
@@ -149885,6 +150097,7 @@ var ts;
|
|
|
149885
150097
|
ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
|
|
149886
150098
|
ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
|
|
149887
150099
|
ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
|
|
150100
|
+
ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
|
|
149888
150101
|
})(ImportFixKind || (ImportFixKind = {}));
|
|
149889
150102
|
// These should not be combined as bitflags, but are given powers of 2 values to
|
|
149890
150103
|
// easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
|
|
@@ -149896,20 +150109,29 @@ var ts;
|
|
|
149896
150109
|
AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
|
|
149897
150110
|
AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
|
|
149898
150111
|
})(AddAsTypeOnly || (AddAsTypeOnly = {}));
|
|
149899
|
-
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
|
|
150112
|
+
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
|
|
149900
150113
|
var compilerOptions = program.getCompilerOptions();
|
|
149901
150114
|
var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
|
|
149902
150115
|
? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
|
|
149903
|
-
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
150116
|
+
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
149904
150117
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149905
150118
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
|
|
149906
150119
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
149907
150120
|
return {
|
|
149908
150121
|
moduleSpecifier: fix.moduleSpecifier,
|
|
149909
|
-
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150122
|
+
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150123
|
+
/*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
|
|
149910
150124
|
};
|
|
149911
150125
|
}
|
|
149912
150126
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
150127
|
+
function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
|
|
150128
|
+
var compilerOptions = program.getCompilerOptions();
|
|
150129
|
+
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
150130
|
+
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
150131
|
+
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
|
|
150132
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
|
|
150133
|
+
}
|
|
150134
|
+
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
149913
150135
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149914
150136
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149915
150137
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
@@ -149939,7 +150161,7 @@ var ts;
|
|
|
149939
150161
|
}
|
|
149940
150162
|
}
|
|
149941
150163
|
}
|
|
149942
|
-
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
|
|
150164
|
+
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
|
|
149943
150165
|
var result = [];
|
|
149944
150166
|
var compilerOptions = program.getCompilerOptions();
|
|
149945
150167
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -149952,7 +150174,7 @@ var ts;
|
|
|
149952
150174
|
return;
|
|
149953
150175
|
}
|
|
149954
150176
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
149955
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
150177
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
149956
150178
|
result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
149957
150179
|
}
|
|
149958
150180
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
@@ -150190,9 +150412,21 @@ var ts;
|
|
|
150190
150412
|
}
|
|
150191
150413
|
function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
|
|
150192
150414
|
var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
|
|
150193
|
-
var info
|
|
150194
|
-
|
|
150195
|
-
|
|
150415
|
+
var info;
|
|
150416
|
+
if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
|
150417
|
+
info = getFixesInfoForUMDImport(context, symbolToken);
|
|
150418
|
+
}
|
|
150419
|
+
else if (!ts.isIdentifier(symbolToken)) {
|
|
150420
|
+
return undefined;
|
|
150421
|
+
}
|
|
150422
|
+
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
150423
|
+
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
150424
|
+
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
150425
|
+
return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
|
|
150426
|
+
}
|
|
150427
|
+
else {
|
|
150428
|
+
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150429
|
+
}
|
|
150196
150430
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150197
150431
|
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150198
150432
|
}
|
|
@@ -150233,6 +150467,7 @@ var ts;
|
|
|
150233
150467
|
return 0 /* EqualTo */;
|
|
150234
150468
|
}
|
|
150235
150469
|
function getFixesInfoForUMDImport(_a, token) {
|
|
150470
|
+
var _b;
|
|
150236
150471
|
var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
|
|
150237
150472
|
var checker = program.getTypeChecker();
|
|
150238
150473
|
var umdSymbol = getUmdSymbol(token, checker);
|
|
@@ -150243,7 +150478,7 @@ var ts;
|
|
|
150243
150478
|
var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150244
150479
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150245
150480
|
var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150246
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150481
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150247
150482
|
}
|
|
150248
150483
|
function getUmdSymbol(token, checker) {
|
|
150249
150484
|
// try the identifier to see if it is the umd symbol
|
|
@@ -150309,12 +150544,22 @@ var ts;
|
|
|
150309
150544
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150310
150545
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150311
150546
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150312
|
-
var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150547
|
+
var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150313
150548
|
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
|
|
150314
150549
|
var _ = _a[0], exportInfos = _a[1];
|
|
150315
150550
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150316
150551
|
}));
|
|
150317
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150552
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
|
|
150553
|
+
}
|
|
150554
|
+
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
150555
|
+
var checker = program.getTypeChecker();
|
|
150556
|
+
var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
150557
|
+
if (!symbol)
|
|
150558
|
+
return undefined;
|
|
150559
|
+
var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
|
|
150560
|
+
if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
|
|
150561
|
+
return undefined;
|
|
150562
|
+
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
150318
150563
|
}
|
|
150319
150564
|
function jsxModeNeedsExplicitImport(jsx) {
|
|
150320
150565
|
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
@@ -150323,14 +150568,20 @@ var ts;
|
|
|
150323
150568
|
var parent = symbolToken.parent;
|
|
150324
150569
|
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150325
150570
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
150326
|
-
if (
|
|
150571
|
+
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
150327
150572
|
return jsxNamespace;
|
|
150328
150573
|
}
|
|
150329
150574
|
}
|
|
150330
150575
|
return symbolToken.text;
|
|
150331
150576
|
}
|
|
150577
|
+
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
|
|
150578
|
+
if (ts.isIntrinsicJsxName(symbolToken.text))
|
|
150579
|
+
return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
|
|
150580
|
+
var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
150581
|
+
return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
|
|
150582
|
+
}
|
|
150332
150583
|
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
|
|
150333
|
-
function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
150584
|
+
function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
150334
150585
|
var _a;
|
|
150335
150586
|
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
|
|
150336
150587
|
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
|
|
@@ -150353,7 +150604,7 @@ var ts;
|
|
|
150353
150604
|
cancellationToken.throwIfCancellationRequested();
|
|
150354
150605
|
var compilerOptions = program.getCompilerOptions();
|
|
150355
150606
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
150356
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
150607
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
150357
150608
|
addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
|
|
150358
150609
|
}
|
|
150359
150610
|
// check exports with the same name
|
|
@@ -150393,14 +150644,14 @@ var ts;
|
|
|
150393
150644
|
// allowSyntheticDefaultImports/esModuleInterop is enabled.
|
|
150394
150645
|
return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
|
|
150395
150646
|
}
|
|
150396
|
-
function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150647
|
+
function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150397
150648
|
var diag;
|
|
150398
150649
|
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
|
150399
|
-
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
|
|
150650
|
+
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
|
|
150400
150651
|
});
|
|
150401
150652
|
return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
|
|
150402
150653
|
}
|
|
150403
|
-
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150654
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150404
150655
|
switch (fix.kind) {
|
|
150405
150656
|
case 0 /* UseNamespace */:
|
|
150406
150657
|
addNamespaceQualifier(changes, sourceFile, fix);
|
|
@@ -150412,11 +150663,9 @@ var ts;
|
|
|
150412
150663
|
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
|
|
150413
150664
|
doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
|
|
150414
150665
|
var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
|
|
150415
|
-
return
|
|
150416
|
-
|
|
150417
|
-
|
|
150418
|
-
moduleSpecifierWithoutQuotes
|
|
150419
|
-
]; // you too!
|
|
150666
|
+
return includeSymbolNameInDescription
|
|
150667
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
|
|
150668
|
+
: [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
|
|
150420
150669
|
}
|
|
150421
150670
|
case 3 /* AddNew */: {
|
|
150422
150671
|
var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
|
|
@@ -150425,12 +150674,84 @@ var ts;
|
|
|
150425
150674
|
var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
|
|
150426
150675
|
var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
|
|
150427
150676
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
150428
|
-
return
|
|
150677
|
+
return includeSymbolNameInDescription
|
|
150678
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
|
|
150679
|
+
: [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
|
|
150680
|
+
}
|
|
150681
|
+
case 4 /* PromoteTypeOnly */: {
|
|
150682
|
+
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
150683
|
+
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
|
|
150684
|
+
return promotedDeclaration.kind === 269 /* ImportSpecifier */
|
|
150685
|
+
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
|
|
150686
|
+
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
|
|
150429
150687
|
}
|
|
150430
150688
|
default:
|
|
150431
150689
|
return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
|
|
150432
150690
|
}
|
|
150433
150691
|
}
|
|
150692
|
+
function getModuleSpecifierText(promotedDeclaration) {
|
|
150693
|
+
var _a, _b;
|
|
150694
|
+
return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
|
|
150695
|
+
? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
|
|
150696
|
+
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
|
|
150697
|
+
}
|
|
150698
|
+
function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
|
|
150699
|
+
// See comment in `doAddExistingFix` on constant with the same name.
|
|
150700
|
+
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
|
|
150701
|
+
switch (aliasDeclaration.kind) {
|
|
150702
|
+
case 269 /* ImportSpecifier */:
|
|
150703
|
+
if (aliasDeclaration.isTypeOnly) {
|
|
150704
|
+
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
|
|
150705
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150706
|
+
var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
|
|
150707
|
+
var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
|
|
150708
|
+
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
150709
|
+
}
|
|
150710
|
+
else {
|
|
150711
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
150712
|
+
}
|
|
150713
|
+
return aliasDeclaration;
|
|
150714
|
+
}
|
|
150715
|
+
else {
|
|
150716
|
+
ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
150717
|
+
promoteImportClause(aliasDeclaration.parent.parent);
|
|
150718
|
+
return aliasDeclaration.parent.parent;
|
|
150719
|
+
}
|
|
150720
|
+
case 266 /* ImportClause */:
|
|
150721
|
+
promoteImportClause(aliasDeclaration);
|
|
150722
|
+
return aliasDeclaration;
|
|
150723
|
+
case 267 /* NamespaceImport */:
|
|
150724
|
+
promoteImportClause(aliasDeclaration.parent);
|
|
150725
|
+
return aliasDeclaration.parent;
|
|
150726
|
+
case 264 /* ImportEqualsDeclaration */:
|
|
150727
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
|
|
150728
|
+
return aliasDeclaration;
|
|
150729
|
+
default:
|
|
150730
|
+
ts.Debug.failBadSyntaxKind(aliasDeclaration);
|
|
150731
|
+
}
|
|
150732
|
+
function promoteImportClause(importClause) {
|
|
150733
|
+
changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
150734
|
+
if (convertExistingToTypeOnly) {
|
|
150735
|
+
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
|
|
150736
|
+
if (namedImports && namedImports.elements.length > 1) {
|
|
150737
|
+
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
|
|
150738
|
+
aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
|
|
150739
|
+
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
150740
|
+
// The import specifier being promoted will be the only non-type-only,
|
|
150741
|
+
// import in the NamedImports, so it should be moved to the front.
|
|
150742
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150743
|
+
changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
|
|
150744
|
+
}
|
|
150745
|
+
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
|
|
150746
|
+
var element = _a[_i];
|
|
150747
|
+
if (element !== aliasDeclaration && !element.isTypeOnly) {
|
|
150748
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
|
|
150749
|
+
}
|
|
150750
|
+
}
|
|
150751
|
+
}
|
|
150752
|
+
}
|
|
150753
|
+
}
|
|
150754
|
+
}
|
|
150434
150755
|
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
|
|
150435
150756
|
var _a;
|
|
150436
150757
|
if (clause.kind === 200 /* ObjectBindingPattern */) {
|
|
@@ -150468,13 +150789,7 @@ var ts;
|
|
|
150468
150789
|
var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
|
|
150469
150790
|
? 0
|
|
150470
150791
|
: ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
|
|
150471
|
-
|
|
150472
|
-
if (prevSpecifier) {
|
|
150473
|
-
changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
|
|
150474
|
-
}
|
|
150475
|
-
else {
|
|
150476
|
-
changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
|
|
150477
|
-
}
|
|
150792
|
+
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
150478
150793
|
}
|
|
150479
150794
|
}
|
|
150480
150795
|
else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
|
|
@@ -150589,17 +150904,20 @@ var ts;
|
|
|
150589
150904
|
var declarations = _a.declarations;
|
|
150590
150905
|
return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
|
|
150591
150906
|
}
|
|
150592
|
-
function moduleSymbolToValidIdentifier(moduleSymbol, target) {
|
|
150593
|
-
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
|
|
150907
|
+
function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
|
|
150908
|
+
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
|
|
150594
150909
|
}
|
|
150595
150910
|
codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
|
|
150596
|
-
function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
|
|
150911
|
+
function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
|
|
150597
150912
|
var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
|
|
150598
150913
|
var res = "";
|
|
150599
150914
|
var lastCharWasValid = true;
|
|
150600
150915
|
var firstCharCode = baseName.charCodeAt(0);
|
|
150601
150916
|
if (ts.isIdentifierStart(firstCharCode, target)) {
|
|
150602
150917
|
res += String.fromCharCode(firstCharCode);
|
|
150918
|
+
if (forceCapitalize) {
|
|
150919
|
+
res = res.toUpperCase();
|
|
150920
|
+
}
|
|
150603
150921
|
}
|
|
150604
150922
|
else {
|
|
150605
150923
|
lastCharWasValid = false;
|
|
@@ -160568,13 +160886,11 @@ var ts;
|
|
|
160568
160886
|
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
160569
160887
|
case 171 /* GetAccessor */:
|
|
160570
160888
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
160571
|
-
this.contextualGetAccessorDocumentationComment = ts.emptyArray;
|
|
160572
160889
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
160573
160890
|
}
|
|
160574
160891
|
return this.contextualGetAccessorDocumentationComment;
|
|
160575
160892
|
case 172 /* SetAccessor */:
|
|
160576
160893
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
160577
|
-
this.contextualSetAccessorDocumentationComment = ts.emptyArray;
|
|
160578
160894
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
160579
160895
|
}
|
|
160580
160896
|
return this.contextualSetAccessorDocumentationComment;
|
|
@@ -160584,10 +160900,26 @@ var ts;
|
|
|
160584
160900
|
};
|
|
160585
160901
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
160586
160902
|
if (this.tags === undefined) {
|
|
160587
|
-
this.tags =
|
|
160903
|
+
this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
|
|
160588
160904
|
}
|
|
160589
160905
|
return this.tags;
|
|
160590
160906
|
};
|
|
160907
|
+
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
160908
|
+
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
160909
|
+
case 171 /* GetAccessor */:
|
|
160910
|
+
if (!this.contextualGetAccessorTags) {
|
|
160911
|
+
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
160912
|
+
}
|
|
160913
|
+
return this.contextualGetAccessorTags;
|
|
160914
|
+
case 172 /* SetAccessor */:
|
|
160915
|
+
if (!this.contextualSetAccessorTags) {
|
|
160916
|
+
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
160917
|
+
}
|
|
160918
|
+
return this.contextualSetAccessorTags;
|
|
160919
|
+
default:
|
|
160920
|
+
return this.getJsDocTags(checker);
|
|
160921
|
+
}
|
|
160922
|
+
};
|
|
160591
160923
|
return SymbolObject;
|
|
160592
160924
|
}());
|
|
160593
160925
|
var TokenObject = /** @class */ (function (_super) {
|
|
@@ -160757,10 +161089,7 @@ var ts;
|
|
|
160757
161089
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160758
161090
|
};
|
|
160759
161091
|
SignatureObject.prototype.getJsDocTags = function () {
|
|
160760
|
-
|
|
160761
|
-
this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : [];
|
|
160762
|
-
}
|
|
160763
|
-
return this.jsDocTags;
|
|
161092
|
+
return this.jsDocTags || (this.jsDocTags = getJsDocTagsOfDeclarations(ts.singleElementArray(this.declaration), this.checker));
|
|
160764
161093
|
};
|
|
160765
161094
|
return SignatureObject;
|
|
160766
161095
|
}());
|
|
@@ -160772,12 +161101,30 @@ var ts;
|
|
|
160772
161101
|
function hasJSDocInheritDocTag(node) {
|
|
160773
161102
|
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
160774
161103
|
}
|
|
160775
|
-
function
|
|
160776
|
-
|
|
160777
|
-
|
|
160778
|
-
|
|
160779
|
-
|
|
160780
|
-
|
|
161104
|
+
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
161105
|
+
if (!declarations)
|
|
161106
|
+
return ts.emptyArray;
|
|
161107
|
+
var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
|
|
161108
|
+
if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
161109
|
+
var seenSymbols_1 = new ts.Set();
|
|
161110
|
+
var _loop_22 = function (declaration) {
|
|
161111
|
+
var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
161112
|
+
var _a;
|
|
161113
|
+
if (!seenSymbols_1.has(symbol)) {
|
|
161114
|
+
seenSymbols_1.add(symbol);
|
|
161115
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
161116
|
+
return symbol.getContextualJsDocTags(declaration, checker);
|
|
161117
|
+
}
|
|
161118
|
+
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
|
|
161119
|
+
}
|
|
161120
|
+
});
|
|
161121
|
+
if (inheritedTags) {
|
|
161122
|
+
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
161123
|
+
}
|
|
161124
|
+
};
|
|
161125
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
161126
|
+
var declaration = declarations_6[_i];
|
|
161127
|
+
_loop_22(declaration);
|
|
160781
161128
|
}
|
|
160782
161129
|
}
|
|
160783
161130
|
return tags;
|
|
@@ -160787,18 +161134,24 @@ var ts;
|
|
|
160787
161134
|
return ts.emptyArray;
|
|
160788
161135
|
var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
|
|
160789
161136
|
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
160790
|
-
var
|
|
160791
|
-
|
|
160792
|
-
var declaration = declarations_6[_i];
|
|
161137
|
+
var seenSymbols_2 = new ts.Set();
|
|
161138
|
+
var _loop_23 = function (declaration) {
|
|
160793
161139
|
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
160794
|
-
if (!
|
|
160795
|
-
|
|
161140
|
+
if (!seenSymbols_2.has(symbol)) {
|
|
161141
|
+
seenSymbols_2.add(symbol);
|
|
161142
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
161143
|
+
return symbol.getContextualDocumentationComment(declaration, checker);
|
|
161144
|
+
}
|
|
160796
161145
|
return symbol.getDocumentationComment(checker);
|
|
160797
161146
|
}
|
|
160798
161147
|
});
|
|
160799
161148
|
// TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
|
|
160800
161149
|
if (inheritedDocs)
|
|
160801
161150
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
161151
|
+
};
|
|
161152
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
161153
|
+
var declaration = declarations_7[_i];
|
|
161154
|
+
_loop_23(declaration);
|
|
160802
161155
|
}
|
|
160803
161156
|
}
|
|
160804
161157
|
return doc;
|