typescript 4.6.0-dev.20220125 → 4.6.0-dev.20220129
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/it/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 +19 -4
- package/lib/pt-br/diagnosticMessages.generated.json +19 -4
- package/lib/ru/diagnosticMessages.generated.json +19 -4
- package/lib/tr/diagnosticMessages.generated.json +19 -4
- package/lib/tsc.js +142 -97
- package/lib/tsserver.js +564 -216
- package/lib/tsserverlibrary.d.ts +9 -5
- package/lib/tsserverlibrary.js +564 -216
- package/lib/typescript.d.ts +9 -5
- package/lib/typescript.js +564 -216
- package/lib/typescriptServices.d.ts +9 -5
- package/lib/typescriptServices.js +564 -216
- package/lib/typingsInstaller.js +153 -108
- 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/tsserverlibrary.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.20220129";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8049,7 +8049,7 @@ var ts;
|
|
|
8049
8049
|
}
|
|
8050
8050
|
})(ts || (ts = {}));
|
|
8051
8051
|
// <auto-generated />
|
|
8052
|
-
// generated from './
|
|
8052
|
+
// generated from './diagnosticMessages.json' in 'src/compiler'
|
|
8053
8053
|
/* @internal */
|
|
8054
8054
|
var ts;
|
|
8055
8055
|
(function (ts) {
|
|
@@ -9637,9 +9637,8 @@ var ts;
|
|
|
9637
9637
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
9638
9638
|
Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
|
|
9639
9639
|
Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
|
|
9640
|
-
|
|
9640
|
+
Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
|
|
9641
9641
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
9642
|
-
Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
|
|
9643
9642
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
9644
9643
|
Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
|
|
9645
9644
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
@@ -9656,8 +9655,6 @@ var ts;
|
|
|
9656
9655
|
Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
|
|
9657
9656
|
Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
|
|
9658
9657
|
Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
|
|
9659
|
-
Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
|
|
9660
|
-
Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
|
|
9661
9658
|
Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
|
|
9662
9659
|
Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
|
|
9663
9660
|
Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
|
|
@@ -9667,6 +9664,10 @@ var ts;
|
|
|
9667
9664
|
Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
|
|
9668
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}'."),
|
|
9669
9666
|
Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
|
|
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}\""),
|
|
9670
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"),
|
|
9671
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}'"),
|
|
9672
9673
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -14257,10 +14258,13 @@ var ts;
|
|
|
14257
14258
|
function packageIdIsEqual(a, b) {
|
|
14258
14259
|
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
|
|
14259
14260
|
}
|
|
14260
|
-
function
|
|
14261
|
-
var name = _a.name, subModuleName = _a.subModuleName
|
|
14262
|
-
|
|
14263
|
-
|
|
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;
|
|
14264
14268
|
}
|
|
14265
14269
|
ts.packageIdToString = packageIdToString;
|
|
14266
14270
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
@@ -15093,6 +15097,15 @@ var ts;
|
|
|
15093
15097
|
};
|
|
15094
15098
|
}
|
|
15095
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;
|
|
15096
15109
|
function createDiagnosticForRange(sourceFile, range, message) {
|
|
15097
15110
|
return {
|
|
15098
15111
|
file: sourceFile,
|
|
@@ -15261,7 +15274,8 @@ var ts;
|
|
|
15261
15274
|
node.kind === 212 /* FunctionExpression */ ||
|
|
15262
15275
|
node.kind === 213 /* ArrowFunction */ ||
|
|
15263
15276
|
node.kind === 211 /* ParenthesizedExpression */ ||
|
|
15264
|
-
node.kind === 253 /* VariableDeclaration */
|
|
15277
|
+
node.kind === 253 /* VariableDeclaration */ ||
|
|
15278
|
+
node.kind === 274 /* ExportSpecifier */) ?
|
|
15265
15279
|
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
|
|
15266
15280
|
ts.getLeadingCommentRanges(text, node.pos);
|
|
15267
15281
|
// True if the comment starts with '/**' but not if it is '/**/'
|
|
@@ -21052,6 +21066,59 @@ var ts;
|
|
|
21052
21066
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
21053
21067
|
}
|
|
21054
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;
|
|
21055
21122
|
})(ts || (ts = {}));
|
|
21056
21123
|
/* @internal */
|
|
21057
21124
|
var ts;
|
|
@@ -36412,7 +36479,8 @@ var ts;
|
|
|
36412
36479
|
return finishNode(node, pos);
|
|
36413
36480
|
}
|
|
36414
36481
|
function parseExportSpecifier() {
|
|
36415
|
-
|
|
36482
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
36483
|
+
return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
|
|
36416
36484
|
}
|
|
36417
36485
|
function parseImportSpecifier() {
|
|
36418
36486
|
return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
|
|
@@ -43617,14 +43685,12 @@ var ts;
|
|
|
43617
43685
|
}
|
|
43618
43686
|
var binder = createBinder();
|
|
43619
43687
|
function bindSourceFile(file, options) {
|
|
43620
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
|
|
43621
43688
|
ts.performance.mark("beforeBind");
|
|
43622
43689
|
ts.perfLogger.logStartBindFile("" + file.fileName);
|
|
43623
43690
|
binder(file, options);
|
|
43624
43691
|
ts.perfLogger.logStopBindFile();
|
|
43625
43692
|
ts.performance.mark("afterBind");
|
|
43626
43693
|
ts.performance.measure("Bind", "beforeBind", "afterBind");
|
|
43627
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43628
43694
|
}
|
|
43629
43695
|
ts.bindSourceFile = bindSourceFile;
|
|
43630
43696
|
function createBinder() {
|
|
@@ -43684,7 +43750,9 @@ var ts;
|
|
|
43684
43750
|
ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
|
|
43685
43751
|
ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
|
|
43686
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);
|
|
43687
43754
|
bind(file);
|
|
43755
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43688
43756
|
file.symbolCount = symbolCount;
|
|
43689
43757
|
file.classifiableNames = classifiableNames;
|
|
43690
43758
|
delayedBindJSDocTypedefTag();
|
|
@@ -47951,6 +48019,9 @@ var ts;
|
|
|
47951
48019
|
suggestionDiagnostics.add(diagnostic);
|
|
47952
48020
|
return diagnostic;
|
|
47953
48021
|
}
|
|
48022
|
+
function isDeprecatedSymbol(symbol) {
|
|
48023
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
|
|
48024
|
+
}
|
|
47954
48025
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
47955
48026
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
47956
48027
|
return addDeprecatedSuggestionWorker(declarations, diagnostic);
|
|
@@ -48942,24 +49013,19 @@ var ts;
|
|
|
48942
49013
|
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
48943
49014
|
}
|
|
48944
49015
|
}
|
|
48945
|
-
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
|
|
48946
|
-
|
|
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
|
+
}
|
|
48947
49025
|
}
|
|
48948
49026
|
}
|
|
48949
49027
|
return result;
|
|
48950
49028
|
}
|
|
48951
|
-
function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
|
|
48952
|
-
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48953
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48954
|
-
if (typeOnlyDeclaration) {
|
|
48955
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48956
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48957
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48958
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48959
|
-
addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48960
|
-
}
|
|
48961
|
-
}
|
|
48962
|
-
}
|
|
48963
49029
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48964
49030
|
if (!typeOnlyDeclaration)
|
|
48965
49031
|
return diagnostic;
|
|
@@ -52721,7 +52787,8 @@ var ts;
|
|
|
52721
52787
|
includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
|
|
52722
52788
|
}
|
|
52723
52789
|
if (ts.isIdentifier(node)) {
|
|
52724
|
-
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);
|
|
52725
52792
|
name.symbol = sym; // for quickinfo, which uses identifier symbol information
|
|
52726
52793
|
return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
52727
52794
|
}
|
|
@@ -60737,7 +60804,7 @@ var ts;
|
|
|
60737
60804
|
}
|
|
60738
60805
|
var prop = getPropertyOfType(objectType, propName);
|
|
60739
60806
|
if (prop) {
|
|
60740
|
-
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations &&
|
|
60807
|
+
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
|
|
60741
60808
|
var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
|
|
60742
60809
|
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
|
|
60743
60810
|
}
|
|
@@ -70140,9 +70207,9 @@ var ts;
|
|
|
70140
70207
|
markAliasReferenced(symbol, node);
|
|
70141
70208
|
}
|
|
70142
70209
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
70143
|
-
var
|
|
70144
|
-
if (
|
|
70145
|
-
addDeprecatedSuggestion(node,
|
|
70210
|
+
var targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
|
|
70211
|
+
if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
|
|
70212
|
+
addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
|
|
70146
70213
|
}
|
|
70147
70214
|
var declaration = localOrExportSymbol.valueDeclaration;
|
|
70148
70215
|
if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
|
|
@@ -73154,7 +73221,7 @@ var ts;
|
|
|
73154
73221
|
}
|
|
73155
73222
|
}
|
|
73156
73223
|
else {
|
|
73157
|
-
if (
|
|
73224
|
+
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
73158
73225
|
addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
|
|
73159
73226
|
}
|
|
73160
73227
|
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
|
|
@@ -74613,7 +74680,7 @@ var ts;
|
|
|
74613
74680
|
}
|
|
74614
74681
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
74615
74682
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
74616
|
-
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);
|
|
74617
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
|
|
74618
74685
|
// arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
|
|
74619
74686
|
var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
|
|
@@ -82992,16 +83059,15 @@ var ts;
|
|
|
82992
83059
|
return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
|
|
82993
83060
|
case 206 /* ElementAccessExpression */:
|
|
82994
83061
|
case 205 /* PropertyAccessExpression */:
|
|
82995
|
-
|
|
82996
|
-
|
|
82997
|
-
var type = getTypeOfExpression(ex.expression);
|
|
83062
|
+
if (isConstantMemberAccess(expr)) {
|
|
83063
|
+
var type = getTypeOfExpression(expr.expression);
|
|
82998
83064
|
if (type.symbol && type.symbol.flags & 384 /* Enum */) {
|
|
82999
83065
|
var name = void 0;
|
|
83000
|
-
if (
|
|
83001
|
-
name =
|
|
83066
|
+
if (expr.kind === 205 /* PropertyAccessExpression */) {
|
|
83067
|
+
name = expr.name.escapedText;
|
|
83002
83068
|
}
|
|
83003
83069
|
else {
|
|
83004
|
-
name = ts.escapeLeadingUnderscores(ts.cast(
|
|
83070
|
+
name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
|
|
83005
83071
|
}
|
|
83006
83072
|
return evaluateEnumMember(expr, type.symbol, name);
|
|
83007
83073
|
}
|
|
@@ -83029,6 +83095,10 @@ var ts;
|
|
|
83029
83095
|
}
|
|
83030
83096
|
}
|
|
83031
83097
|
function isConstantMemberAccess(node) {
|
|
83098
|
+
var type = getTypeOfExpression(node);
|
|
83099
|
+
if (type === errorType) {
|
|
83100
|
+
return false;
|
|
83101
|
+
}
|
|
83032
83102
|
return node.kind === 79 /* Identifier */ ||
|
|
83033
83103
|
node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
|
|
83034
83104
|
node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
|
|
@@ -83323,7 +83393,6 @@ var ts;
|
|
|
83323
83393
|
return true;
|
|
83324
83394
|
}
|
|
83325
83395
|
function checkAliasSymbol(node) {
|
|
83326
|
-
var _a;
|
|
83327
83396
|
var symbol = getSymbolOfNode(node);
|
|
83328
83397
|
var target = resolveAlias(symbol);
|
|
83329
83398
|
if (target !== unknownSymbol) {
|
|
@@ -83379,10 +83448,45 @@ var ts;
|
|
|
83379
83448
|
}
|
|
83380
83449
|
}
|
|
83381
83450
|
}
|
|
83382
|
-
if (ts.isImportSpecifier(node)
|
|
83383
|
-
|
|
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;
|
|
83384
83487
|
}
|
|
83385
83488
|
}
|
|
83489
|
+
return targetSymbol;
|
|
83386
83490
|
}
|
|
83387
83491
|
function checkImportBinding(node) {
|
|
83388
83492
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -85818,7 +85922,7 @@ var ts;
|
|
|
85818
85922
|
if (quickResult !== undefined) {
|
|
85819
85923
|
return quickResult;
|
|
85820
85924
|
}
|
|
85821
|
-
var lastStatic, lastDeclare, lastAsync,
|
|
85925
|
+
var lastStatic, lastDeclare, lastAsync, lastOverride;
|
|
85822
85926
|
var flags = 0 /* None */;
|
|
85823
85927
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
85824
85928
|
var modifier = _a[_i];
|
|
@@ -85922,7 +86026,6 @@ var ts;
|
|
|
85922
86026
|
return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
|
|
85923
86027
|
}
|
|
85924
86028
|
flags |= 64 /* Readonly */;
|
|
85925
|
-
lastReadonly = modifier;
|
|
85926
86029
|
break;
|
|
85927
86030
|
case 93 /* ExportKeyword */:
|
|
85928
86031
|
if (flags & 1 /* Export */) {
|
|
@@ -86035,18 +86138,12 @@ var ts;
|
|
|
86035
86138
|
if (flags & 32 /* Static */) {
|
|
86036
86139
|
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
|
|
86037
86140
|
}
|
|
86038
|
-
if (flags & 128 /* Abstract */) {
|
|
86039
|
-
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
|
|
86040
|
-
}
|
|
86041
86141
|
if (flags & 16384 /* Override */) {
|
|
86042
86142
|
return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
|
|
86043
86143
|
}
|
|
86044
|
-
|
|
86144
|
+
if (flags & 256 /* Async */) {
|
|
86045
86145
|
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
|
|
86046
86146
|
}
|
|
86047
|
-
else if (flags & 64 /* Readonly */) {
|
|
86048
|
-
return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
|
|
86049
|
-
}
|
|
86050
86147
|
return false;
|
|
86051
86148
|
}
|
|
86052
86149
|
else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
|
|
@@ -116041,14 +116138,14 @@ var ts;
|
|
|
116041
116138
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
116042
116139
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
116043
116140
|
addFileIncludeReason(dupFile, reason);
|
|
116044
|
-
sourceFileToPackageName.set(path, packageId
|
|
116141
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
116045
116142
|
processingOtherFiles.push(dupFile);
|
|
116046
116143
|
return dupFile;
|
|
116047
116144
|
}
|
|
116048
116145
|
else if (file) {
|
|
116049
116146
|
// This is the first source file to have this packageId.
|
|
116050
116147
|
packageIdToSourceFile.set(packageIdKey, file);
|
|
116051
|
-
sourceFileToPackageName.set(path, packageId
|
|
116148
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
116052
116149
|
}
|
|
116053
116150
|
}
|
|
116054
116151
|
addFileToFilesByName(file, path, redirectedPath);
|
|
@@ -120187,7 +120284,7 @@ var ts;
|
|
|
120187
120284
|
if (!host.fileExists || !host.readFile) {
|
|
120188
120285
|
return undefined;
|
|
120189
120286
|
}
|
|
120190
|
-
var parts = getNodeModulePathParts(path);
|
|
120287
|
+
var parts = ts.getNodeModulePathParts(path);
|
|
120191
120288
|
if (!parts) {
|
|
120192
120289
|
return undefined;
|
|
120193
120290
|
}
|
|
@@ -120310,58 +120407,6 @@ var ts;
|
|
|
120310
120407
|
}
|
|
120311
120408
|
}
|
|
120312
120409
|
}
|
|
120313
|
-
function getNodeModulePathParts(fullPath) {
|
|
120314
|
-
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
120315
|
-
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
120316
|
-
// Returns indices: ^ ^ ^ ^
|
|
120317
|
-
var topLevelNodeModulesIndex = 0;
|
|
120318
|
-
var topLevelPackageNameIndex = 0;
|
|
120319
|
-
var packageRootIndex = 0;
|
|
120320
|
-
var fileNameIndex = 0;
|
|
120321
|
-
var States;
|
|
120322
|
-
(function (States) {
|
|
120323
|
-
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
120324
|
-
States[States["NodeModules"] = 1] = "NodeModules";
|
|
120325
|
-
States[States["Scope"] = 2] = "Scope";
|
|
120326
|
-
States[States["PackageContent"] = 3] = "PackageContent";
|
|
120327
|
-
})(States || (States = {}));
|
|
120328
|
-
var partStart = 0;
|
|
120329
|
-
var partEnd = 0;
|
|
120330
|
-
var state = 0 /* BeforeNodeModules */;
|
|
120331
|
-
while (partEnd >= 0) {
|
|
120332
|
-
partStart = partEnd;
|
|
120333
|
-
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
120334
|
-
switch (state) {
|
|
120335
|
-
case 0 /* BeforeNodeModules */:
|
|
120336
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120337
|
-
topLevelNodeModulesIndex = partStart;
|
|
120338
|
-
topLevelPackageNameIndex = partEnd;
|
|
120339
|
-
state = 1 /* NodeModules */;
|
|
120340
|
-
}
|
|
120341
|
-
break;
|
|
120342
|
-
case 1 /* NodeModules */:
|
|
120343
|
-
case 2 /* Scope */:
|
|
120344
|
-
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
120345
|
-
state = 2 /* Scope */;
|
|
120346
|
-
}
|
|
120347
|
-
else {
|
|
120348
|
-
packageRootIndex = partEnd;
|
|
120349
|
-
state = 3 /* PackageContent */;
|
|
120350
|
-
}
|
|
120351
|
-
break;
|
|
120352
|
-
case 3 /* PackageContent */:
|
|
120353
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120354
|
-
state = 1 /* NodeModules */;
|
|
120355
|
-
}
|
|
120356
|
-
else {
|
|
120357
|
-
state = 3 /* PackageContent */;
|
|
120358
|
-
}
|
|
120359
|
-
break;
|
|
120360
|
-
}
|
|
120361
|
-
}
|
|
120362
|
-
fileNameIndex = partStart;
|
|
120363
|
-
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
120364
|
-
}
|
|
120365
120410
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120366
120411
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120367
120412
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
@@ -127125,11 +127170,11 @@ var ts;
|
|
|
127125
127170
|
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
|
|
127126
127171
|
}
|
|
127127
127172
|
ts.firstOrOnly = firstOrOnly;
|
|
127128
|
-
function getNameForExportedSymbol(symbol, scriptTarget) {
|
|
127173
|
+
function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
|
|
127129
127174
|
if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
|
|
127130
127175
|
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
|
127131
127176
|
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; })
|
|
127132
|
-
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
|
|
127177
|
+
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
|
|
127133
127178
|
}
|
|
127134
127179
|
return symbol.name;
|
|
127135
127180
|
}
|
|
@@ -127248,6 +127293,17 @@ var ts;
|
|
|
127248
127293
|
var exportInfoId = 1;
|
|
127249
127294
|
var exportInfo = ts.createMultiMap();
|
|
127250
127295
|
var symbols = new ts.Map();
|
|
127296
|
+
/**
|
|
127297
|
+
* Key: node_modules package name (no @types).
|
|
127298
|
+
* Value: path to deepest node_modules folder seen that is
|
|
127299
|
+
* both visible to `usableByFileName` and contains the package.
|
|
127300
|
+
*
|
|
127301
|
+
* Later, we can see if a given SymbolExportInfo is shadowed by
|
|
127302
|
+
* a another installation of the same package in a deeper
|
|
127303
|
+
* node_modules folder by seeing if its path starts with the
|
|
127304
|
+
* value stored here.
|
|
127305
|
+
*/
|
|
127306
|
+
var packages = new ts.Map();
|
|
127251
127307
|
var usableByFileName;
|
|
127252
127308
|
var cache = {
|
|
127253
127309
|
isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
|
|
@@ -127257,11 +127313,32 @@ var ts;
|
|
|
127257
127313
|
symbols.clear();
|
|
127258
127314
|
usableByFileName = undefined;
|
|
127259
127315
|
},
|
|
127260
|
-
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson,
|
|
127316
|
+
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
|
|
127261
127317
|
if (importingFile !== usableByFileName) {
|
|
127262
127318
|
cache.clear();
|
|
127263
127319
|
usableByFileName = importingFile;
|
|
127264
127320
|
}
|
|
127321
|
+
var packageName;
|
|
127322
|
+
if (moduleFile) {
|
|
127323
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
|
|
127324
|
+
if (nodeModulesPathParts) {
|
|
127325
|
+
var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
|
|
127326
|
+
packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
|
|
127327
|
+
if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
|
|
127328
|
+
var prevDeepestNodeModulesPath = packages.get(packageName);
|
|
127329
|
+
var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
|
|
127330
|
+
if (prevDeepestNodeModulesPath) {
|
|
127331
|
+
var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
|
|
127332
|
+
if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
|
|
127333
|
+
packages.set(packageName, nodeModulesPath);
|
|
127334
|
+
}
|
|
127335
|
+
}
|
|
127336
|
+
else {
|
|
127337
|
+
packages.set(packageName, nodeModulesPath);
|
|
127338
|
+
}
|
|
127339
|
+
}
|
|
127340
|
+
}
|
|
127341
|
+
}
|
|
127265
127342
|
var isDefault = exportKind === 1 /* Default */;
|
|
127266
127343
|
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127267
127344
|
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
|
|
@@ -127273,7 +127350,7 @@ var ts;
|
|
|
127273
127350
|
// get a better name.
|
|
127274
127351
|
var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
127275
127352
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
127276
|
-
: ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
|
|
127353
|
+
: ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
|
|
127277
127354
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
127278
127355
|
var id = exportInfoId++;
|
|
127279
127356
|
var target = ts.skipAlias(symbol, checker);
|
|
@@ -127288,6 +127365,7 @@ var ts;
|
|
|
127288
127365
|
moduleName: moduleName,
|
|
127289
127366
|
moduleFile: moduleFile,
|
|
127290
127367
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
127368
|
+
packageName: packageName,
|
|
127291
127369
|
exportKind: exportKind,
|
|
127292
127370
|
targetFlags: target.flags,
|
|
127293
127371
|
isFromPackageJson: isFromPackageJson,
|
|
@@ -127306,7 +127384,17 @@ var ts;
|
|
|
127306
127384
|
return;
|
|
127307
127385
|
exportInfo.forEach(function (info, key) {
|
|
127308
127386
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
127309
|
-
|
|
127387
|
+
var rehydrated = info.map(rehydrateCachedInfo);
|
|
127388
|
+
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
|
|
127389
|
+
if (filtered.length) {
|
|
127390
|
+
action(filtered, function (preferCapitalized) {
|
|
127391
|
+
var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
|
|
127392
|
+
var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
127393
|
+
return preferCapitalized
|
|
127394
|
+
? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
|
|
127395
|
+
: symbolName;
|
|
127396
|
+
}, !!ambientModuleName, key);
|
|
127397
|
+
}
|
|
127310
127398
|
});
|
|
127311
127399
|
},
|
|
127312
127400
|
releaseSymbols: function () {
|
|
@@ -127406,6 +127494,12 @@ var ts;
|
|
|
127406
127494
|
}
|
|
127407
127495
|
return true;
|
|
127408
127496
|
}
|
|
127497
|
+
function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
|
|
127498
|
+
if (!packageName || !info.moduleFileName)
|
|
127499
|
+
return true;
|
|
127500
|
+
var packageDeepestNodeModulesPath = packages.get(packageName);
|
|
127501
|
+
return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
|
|
127502
|
+
}
|
|
127409
127503
|
}
|
|
127410
127504
|
ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
|
|
127411
127505
|
function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
|
|
@@ -127488,7 +127582,6 @@ var ts;
|
|
|
127488
127582
|
}
|
|
127489
127583
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
127490
127584
|
var compilerOptions = program.getCompilerOptions();
|
|
127491
|
-
var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
|
|
127492
127585
|
var moduleCount = 0;
|
|
127493
127586
|
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
127494
127587
|
if (++moduleCount % 100 === 0)
|
|
@@ -127499,11 +127592,11 @@ var ts;
|
|
|
127499
127592
|
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
127500
127593
|
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
127501
127594
|
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
127502
|
-
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson,
|
|
127595
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
127503
127596
|
}
|
|
127504
127597
|
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
127505
127598
|
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
127506
|
-
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson,
|
|
127599
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
127507
127600
|
}
|
|
127508
127601
|
});
|
|
127509
127602
|
});
|
|
@@ -129577,6 +129670,8 @@ var ts;
|
|
|
129577
129670
|
CompletionSource["ThisProperty"] = "ThisProperty/";
|
|
129578
129671
|
/** Auto-import that comes attached to a class member snippet */
|
|
129579
129672
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
129673
|
+
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
129674
|
+
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
129580
129675
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
129581
129676
|
var SymbolOriginInfoKind;
|
|
129582
129677
|
(function (SymbolOriginInfoKind) {
|
|
@@ -129586,6 +129681,7 @@ var ts;
|
|
|
129586
129681
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
|
|
129587
129682
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
129588
129683
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
129684
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
129589
129685
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
129590
129686
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
129591
129687
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -129613,6 +129709,9 @@ var ts;
|
|
|
129613
129709
|
function originIsNullableMember(origin) {
|
|
129614
129710
|
return !!(origin.kind & 16 /* Nullable */);
|
|
129615
129711
|
}
|
|
129712
|
+
function originIsTypeOnlyAlias(origin) {
|
|
129713
|
+
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
129714
|
+
}
|
|
129616
129715
|
var KeywordCompletionFilters;
|
|
129617
129716
|
(function (KeywordCompletionFilters) {
|
|
129618
129717
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -129711,7 +129810,7 @@ var ts;
|
|
|
129711
129810
|
}
|
|
129712
129811
|
switch (completionData.kind) {
|
|
129713
129812
|
case 0 /* Data */:
|
|
129714
|
-
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
|
|
129813
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
|
|
129715
129814
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
129716
129815
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
129717
129816
|
}
|
|
@@ -129831,7 +129930,7 @@ var ts;
|
|
|
129831
129930
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
129832
129931
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129833
129932
|
}
|
|
129834
|
-
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129933
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
129835
129934
|
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129836
129935
|
// Verify if the file is JSX language variant
|
|
129837
129936
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -129844,7 +129943,7 @@ var ts;
|
|
|
129844
129943
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129845
129944
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129846
129945
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129847
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129946
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129848
129947
|
}
|
|
129849
129948
|
else {
|
|
129850
129949
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
@@ -129854,16 +129953,23 @@ var ts;
|
|
|
129854
129953
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129855
129954
|
}
|
|
129856
129955
|
if (keywordFilters !== 0 /* None */) {
|
|
129857
|
-
var
|
|
129956
|
+
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129858
129957
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129859
129958
|
var keywordEntry = _a[_i];
|
|
129860
|
-
if (!
|
|
129959
|
+
if (!entryNames_1.has(keywordEntry.name)) {
|
|
129861
129960
|
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129862
129961
|
}
|
|
129863
129962
|
}
|
|
129864
129963
|
}
|
|
129865
|
-
|
|
129866
|
-
|
|
129964
|
+
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129965
|
+
for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
|
|
129966
|
+
var keywordEntry = _c[_b];
|
|
129967
|
+
if (!entryNames.has(keywordEntry.name)) {
|
|
129968
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129969
|
+
}
|
|
129970
|
+
}
|
|
129971
|
+
for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
|
|
129972
|
+
var literal = literals_1[_d];
|
|
129867
129973
|
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129868
129974
|
}
|
|
129869
129975
|
return {
|
|
@@ -130017,6 +130123,9 @@ var ts;
|
|
|
130017
130123
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
130018
130124
|
}
|
|
130019
130125
|
}
|
|
130126
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
130127
|
+
hasAction = true;
|
|
130128
|
+
}
|
|
130020
130129
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
130021
130130
|
preferences.includeCompletionsWithInsertText &&
|
|
130022
130131
|
completionKind === 3 /* MemberLike */ &&
|
|
@@ -130361,6 +130470,9 @@ var ts;
|
|
|
130361
130470
|
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
|
|
130362
130471
|
return CompletionSource.ThisProperty;
|
|
130363
130472
|
}
|
|
130473
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
130474
|
+
return CompletionSource.TypeOnlyAlias;
|
|
130475
|
+
}
|
|
130364
130476
|
}
|
|
130365
130477
|
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) {
|
|
130366
130478
|
var _a;
|
|
@@ -130388,7 +130500,7 @@ var ts;
|
|
|
130388
130500
|
continue;
|
|
130389
130501
|
}
|
|
130390
130502
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
130391
|
-
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
130503
|
+
var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
130392
130504
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
130393
130505
|
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
130394
130506
|
}
|
|
@@ -130401,6 +130513,7 @@ var ts;
|
|
|
130401
130513
|
add: function (name) { return uniques.set(name, true); },
|
|
130402
130514
|
};
|
|
130403
130515
|
function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
|
|
130516
|
+
var allFlags = symbol.flags;
|
|
130404
130517
|
if (!ts.isSourceFile(location)) {
|
|
130405
130518
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
130406
130519
|
if (ts.isExportAssignment(location.parent)) {
|
|
@@ -130426,11 +130539,10 @@ var ts;
|
|
|
130426
130539
|
|| symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
|
|
130427
130540
|
return false;
|
|
130428
130541
|
}
|
|
130429
|
-
|
|
130430
|
-
symbol = symbolOrigin;
|
|
130542
|
+
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
130431
130543
|
// import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
|
|
130432
130544
|
if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
|
|
130433
|
-
return !!(
|
|
130545
|
+
return !!(allFlags & 1920 /* Namespace */);
|
|
130434
130546
|
}
|
|
130435
130547
|
if (isTypeOnlyLocation) {
|
|
130436
130548
|
// It's a type, but you can reach it by namespace.type as well
|
|
@@ -130438,7 +130550,7 @@ var ts;
|
|
|
130438
130550
|
}
|
|
130439
130551
|
}
|
|
130440
130552
|
// expressions are value space (which includes the value namespaces)
|
|
130441
|
-
return !!(
|
|
130553
|
+
return !!(allFlags & 111551 /* Value */);
|
|
130442
130554
|
}
|
|
130443
130555
|
}
|
|
130444
130556
|
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
|
|
@@ -130572,8 +130684,7 @@ var ts;
|
|
|
130572
130684
|
Completions.createCompletionDetails = createCompletionDetails;
|
|
130573
130685
|
function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
|
|
130574
130686
|
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
|
|
130575
|
-
|
|
130576
|
-
if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
|
|
130687
|
+
if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
|
|
130577
130688
|
// Import statement completion: 'import c|'
|
|
130578
130689
|
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
|
|
130579
130690
|
}
|
|
@@ -130591,13 +130702,19 @@ var ts;
|
|
|
130591
130702
|
};
|
|
130592
130703
|
}
|
|
130593
130704
|
}
|
|
130705
|
+
if (originIsTypeOnlyAlias(origin)) {
|
|
130706
|
+
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
130707
|
+
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
130708
|
+
return { codeActions: [codeAction_1], sourceDisplay: undefined };
|
|
130709
|
+
}
|
|
130594
130710
|
if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
|
|
130595
130711
|
return { codeActions: undefined, sourceDisplay: undefined };
|
|
130596
130712
|
}
|
|
130597
130713
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
130598
130714
|
var moduleSymbol = origin.moduleSymbol;
|
|
130599
130715
|
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
130600
|
-
var
|
|
130716
|
+
var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
|
|
130717
|
+
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;
|
|
130601
130718
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
130602
130719
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
130603
130720
|
}
|
|
@@ -131267,21 +131384,29 @@ var ts;
|
|
|
131267
131384
|
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
|
131268
131385
|
isInSnippetScope = isSnippetScope(scopeNode);
|
|
131269
131386
|
var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
|
|
131387
|
+
var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
|
|
131270
131388
|
symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
|
|
131271
131389
|
ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
|
|
131272
|
-
for (var
|
|
131273
|
-
var symbol =
|
|
131390
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
131391
|
+
var symbol = symbols[i];
|
|
131274
131392
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
131275
131393
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
131276
131394
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
|
|
131277
131395
|
}
|
|
131396
|
+
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
131397
|
+
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
131398
|
+
if (typeOnlyAliasDeclaration) {
|
|
131399
|
+
var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
|
|
131400
|
+
symbolToOriginInfoMap[i] = origin;
|
|
131401
|
+
}
|
|
131402
|
+
}
|
|
131278
131403
|
}
|
|
131279
131404
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
131280
131405
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
|
|
131281
131406
|
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
131282
131407
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
131283
|
-
for (var
|
|
131284
|
-
var symbol =
|
|
131408
|
+
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
131409
|
+
var symbol = _a[_i];
|
|
131285
131410
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
131286
131411
|
symbols.push(symbol);
|
|
131287
131412
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
|
|
@@ -131384,7 +131509,8 @@ var ts;
|
|
|
131384
131509
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
131385
131510
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
131386
131511
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
131387
|
-
exportInfo.forEach(sourceFile.path, function (info,
|
|
131512
|
+
exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
|
|
131513
|
+
var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
|
|
131388
131514
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
131389
131515
|
return;
|
|
131390
131516
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
@@ -131394,6 +131520,10 @@ var ts;
|
|
|
131394
131520
|
return;
|
|
131395
131521
|
if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
131396
131522
|
return;
|
|
131523
|
+
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
131524
|
+
var firstChar = symbolName.charCodeAt(0);
|
|
131525
|
+
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
131526
|
+
return;
|
|
131397
131527
|
var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
|
|
131398
131528
|
if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
|
|
131399
131529
|
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
@@ -131470,16 +131600,19 @@ var ts;
|
|
|
131470
131600
|
return true;
|
|
131471
131601
|
}
|
|
131472
131602
|
if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
|
|
131603
|
+
// <Component<string> /**/ />
|
|
131604
|
+
// <Component<string> /**/ ><Component>
|
|
131605
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131606
|
+
// - location: JsxSelfClosingElement or JsxOpeningElement
|
|
131607
|
+
// - contextToken.parent === location
|
|
131608
|
+
if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
|
|
131609
|
+
return false;
|
|
131610
|
+
}
|
|
131473
131611
|
if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
|
|
131474
|
-
//
|
|
131475
|
-
//
|
|
131476
|
-
//
|
|
131477
|
-
//
|
|
131478
|
-
// - different parents (JSXOpeningElement, JSXElement)
|
|
131479
|
-
// 2. <Component<string> /**/>
|
|
131480
|
-
// - contextToken: GreaterThanToken (before cursor)
|
|
131481
|
-
// - location: GreaterThanToken (after cursor)
|
|
131482
|
-
// - same parent (JSXOpeningElement)
|
|
131612
|
+
// <div>/**/
|
|
131613
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131614
|
+
// - location: JSXElement
|
|
131615
|
+
// - different parents (JSXOpeningElement, JSXElement)
|
|
131483
131616
|
return location.parent.kind !== 279 /* JsxOpeningElement */;
|
|
131484
131617
|
}
|
|
131485
131618
|
if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
|
|
@@ -132386,6 +132519,34 @@ var ts;
|
|
|
132386
132519
|
function keywordForNode(node) {
|
|
132387
132520
|
return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
|
|
132388
132521
|
}
|
|
132522
|
+
function getContextualKeywords(contextToken, position) {
|
|
132523
|
+
var entries = [];
|
|
132524
|
+
/**
|
|
132525
|
+
* An `AssertClause` can come after an import declaration:
|
|
132526
|
+
* import * from "foo" |
|
|
132527
|
+
* import "foo" |
|
|
132528
|
+
* or after a re-export declaration that has a module specifier:
|
|
132529
|
+
* export { foo } from "foo" |
|
|
132530
|
+
* Source: https://tc39.es/proposal-import-assertions/
|
|
132531
|
+
*/
|
|
132532
|
+
if (contextToken) {
|
|
132533
|
+
var file = contextToken.getSourceFile();
|
|
132534
|
+
var parent = contextToken.parent;
|
|
132535
|
+
var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
|
|
132536
|
+
var currentLine = file.getLineAndCharacterOfPosition(position).line;
|
|
132537
|
+
if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
|
|
132538
|
+
&& contextToken === parent.moduleSpecifier
|
|
132539
|
+
&& tokenLine === currentLine) {
|
|
132540
|
+
entries.push({
|
|
132541
|
+
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
132542
|
+
kind: "keyword" /* keyword */,
|
|
132543
|
+
kindModifiers: "" /* none */,
|
|
132544
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
132545
|
+
});
|
|
132546
|
+
}
|
|
132547
|
+
}
|
|
132548
|
+
return entries;
|
|
132549
|
+
}
|
|
132389
132550
|
/** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
|
|
132390
132551
|
function getJsDocTagAtPosition(node, position) {
|
|
132391
132552
|
return ts.findAncestor(node, function (n) {
|
|
@@ -132680,10 +132841,14 @@ var ts;
|
|
|
132680
132841
|
/** True if symbol is a type or a module containing at least one type. */
|
|
132681
132842
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
132682
132843
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
132683
|
-
|
|
132684
|
-
|
|
132685
|
-
|
|
132686
|
-
|
|
132844
|
+
// Since an alias can be merged with a local declaration, we need to test both the alias and its target.
|
|
132845
|
+
// This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
|
|
132846
|
+
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
132847
|
+
function nonAliasCanBeReferencedAtTypeLocation(symbol) {
|
|
132848
|
+
return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
|
|
132849
|
+
!!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
|
|
132850
|
+
checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
|
|
132851
|
+
}
|
|
132687
132852
|
}
|
|
132688
132853
|
function isDeprecated(symbol, checker) {
|
|
132689
132854
|
var declarations = ts.skipAlias(symbol, checker).declarations;
|
|
@@ -134937,8 +135102,8 @@ var ts;
|
|
|
134937
135102
|
var sourceId = ts.getNodeId(sourceFile);
|
|
134938
135103
|
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
|
|
134939
135104
|
var anyNewSymbols = false;
|
|
134940
|
-
for (var _i = 0,
|
|
134941
|
-
var sym =
|
|
135105
|
+
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
135106
|
+
var sym = symbols_1[_i];
|
|
134942
135107
|
anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
|
|
134943
135108
|
}
|
|
134944
135109
|
return anyNewSymbols;
|
|
@@ -141898,6 +142063,8 @@ var ts;
|
|
|
141898
142063
|
}
|
|
141899
142064
|
if (flags & 16 /* Function */)
|
|
141900
142065
|
return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
|
|
142066
|
+
// 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.
|
|
142067
|
+
// So, even when the location is just on the declaration of setter, this function returns getter.
|
|
141901
142068
|
if (flags & 32768 /* GetAccessor */)
|
|
141902
142069
|
return "getter" /* memberGetAccessorElement */;
|
|
141903
142070
|
if (flags & 65536 /* SetAccessor */)
|
|
@@ -141984,9 +142151,24 @@ var ts;
|
|
|
141984
142151
|
}
|
|
141985
142152
|
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
|
141986
142153
|
if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
|
|
141987
|
-
// If
|
|
142154
|
+
// If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
|
|
141988
142155
|
if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
|
|
141989
|
-
|
|
142156
|
+
var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
|
|
142157
|
+
if (declaration) {
|
|
142158
|
+
switch (declaration.kind) {
|
|
142159
|
+
case 171 /* GetAccessor */:
|
|
142160
|
+
symbolKind = "getter" /* memberGetAccessorElement */;
|
|
142161
|
+
break;
|
|
142162
|
+
case 172 /* SetAccessor */:
|
|
142163
|
+
symbolKind = "setter" /* memberSetAccessorElement */;
|
|
142164
|
+
break;
|
|
142165
|
+
default:
|
|
142166
|
+
ts.Debug.assertNever(declaration);
|
|
142167
|
+
}
|
|
142168
|
+
}
|
|
142169
|
+
else {
|
|
142170
|
+
symbolKind = "property" /* memberVariableElement */;
|
|
142171
|
+
}
|
|
141990
142172
|
}
|
|
141991
142173
|
var signature = void 0;
|
|
141992
142174
|
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -142300,6 +142482,8 @@ var ts;
|
|
|
142300
142482
|
}
|
|
142301
142483
|
// For properties, variables and local vars: show the type
|
|
142302
142484
|
if (symbolKind === "property" /* memberVariableElement */ ||
|
|
142485
|
+
symbolKind === "getter" /* memberGetAccessorElement */ ||
|
|
142486
|
+
symbolKind === "setter" /* memberSetAccessorElement */ ||
|
|
142303
142487
|
symbolKind === "JSX attribute" /* jsxAttribute */ ||
|
|
142304
142488
|
symbolFlags & 3 /* Variable */ ||
|
|
142305
142489
|
symbolKind === "local var" /* localVariableElement */ ||
|
|
@@ -142370,7 +142554,7 @@ var ts;
|
|
|
142370
142554
|
}
|
|
142371
142555
|
}
|
|
142372
142556
|
if (tags.length === 0 && !hasMultipleSignatures) {
|
|
142373
|
-
tags = symbol.
|
|
142557
|
+
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
|
|
142374
142558
|
}
|
|
142375
142559
|
if (documentation.length === 0 && documentationFromAlias) {
|
|
142376
142560
|
documentation = documentationFromAlias;
|
|
@@ -145790,6 +145974,7 @@ var ts;
|
|
|
145790
145974
|
ChangeTracker.prototype.delete = function (sourceFile, node) {
|
|
145791
145975
|
this.deletedNodes.push({ sourceFile: sourceFile, node: node });
|
|
145792
145976
|
};
|
|
145977
|
+
/** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
|
|
145793
145978
|
ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
|
|
145794
145979
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
145795
145980
|
this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
|
|
@@ -146193,6 +146378,15 @@ var ts;
|
|
|
146193
146378
|
ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
|
|
146194
146379
|
this.insertText(sourceFile, node.getStart(sourceFile), "export ");
|
|
146195
146380
|
};
|
|
146381
|
+
ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
|
|
146382
|
+
var prevSpecifier = namedImports.elements[index - 1];
|
|
146383
|
+
if (prevSpecifier) {
|
|
146384
|
+
this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
|
|
146385
|
+
}
|
|
146386
|
+
else {
|
|
146387
|
+
this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
|
|
146388
|
+
}
|
|
146389
|
+
};
|
|
146196
146390
|
/**
|
|
146197
146391
|
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
|
|
146198
146392
|
* i.e. arguments in arguments lists, parameters in parameter lists etc.
|
|
@@ -149695,7 +149889,8 @@ var ts;
|
|
|
149695
149889
|
ts.Diagnostics.Cannot_find_namespace_0.code,
|
|
149696
149890
|
ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
|
|
149697
149891
|
ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
|
|
149698
|
-
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
|
|
149892
|
+
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
|
|
149893
|
+
ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
|
|
149699
149894
|
];
|
|
149700
149895
|
codefix.registerCodeFix({
|
|
149701
149896
|
errorCodes: errorCodes,
|
|
@@ -149704,9 +149899,10 @@ var ts;
|
|
|
149704
149899
|
var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
|
|
149705
149900
|
if (!info)
|
|
149706
149901
|
return undefined;
|
|
149707
|
-
var fixes = info.fixes, symbolName = info.symbolName;
|
|
149902
|
+
var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
|
|
149708
149903
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
149709
|
-
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149904
|
+
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149905
|
+
/*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
|
|
149710
149906
|
},
|
|
149711
149907
|
fixIds: [importFixId],
|
|
149712
149908
|
getAllCodeActions: function (context) {
|
|
@@ -149741,11 +149937,11 @@ var ts;
|
|
|
149741
149937
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149742
149938
|
var checker = program.getTypeChecker();
|
|
149743
149939
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149744
|
-
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
|
|
149940
|
+
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149745
149941
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149746
149942
|
var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149747
149943
|
if (fix) {
|
|
149748
|
-
addImport({ fixes: [fix], symbolName: symbolName });
|
|
149944
|
+
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149749
149945
|
}
|
|
149750
149946
|
}
|
|
149751
149947
|
function addImport(info) {
|
|
@@ -149800,6 +149996,9 @@ var ts;
|
|
|
149800
149996
|
}
|
|
149801
149997
|
break;
|
|
149802
149998
|
}
|
|
149999
|
+
case 4 /* PromoteTypeOnly */:
|
|
150000
|
+
// Excluding from fix-all
|
|
150001
|
+
break;
|
|
149803
150002
|
default:
|
|
149804
150003
|
ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
|
|
149805
150004
|
}
|
|
@@ -149891,6 +150090,7 @@ var ts;
|
|
|
149891
150090
|
ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
|
|
149892
150091
|
ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
|
|
149893
150092
|
ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
|
|
150093
|
+
ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
|
|
149894
150094
|
})(ImportFixKind || (ImportFixKind = {}));
|
|
149895
150095
|
// These should not be combined as bitflags, but are given powers of 2 values to
|
|
149896
150096
|
// easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
|
|
@@ -149902,20 +150102,29 @@ var ts;
|
|
|
149902
150102
|
AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
|
|
149903
150103
|
AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
|
|
149904
150104
|
})(AddAsTypeOnly || (AddAsTypeOnly = {}));
|
|
149905
|
-
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
|
|
150105
|
+
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
|
|
149906
150106
|
var compilerOptions = program.getCompilerOptions();
|
|
149907
150107
|
var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
|
|
149908
150108
|
? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
|
|
149909
|
-
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
150109
|
+
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
149910
150110
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149911
150111
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
|
|
149912
150112
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
149913
150113
|
return {
|
|
149914
150114
|
moduleSpecifier: fix.moduleSpecifier,
|
|
149915
|
-
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150115
|
+
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
150116
|
+
/*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
|
|
149916
150117
|
};
|
|
149917
150118
|
}
|
|
149918
150119
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
150120
|
+
function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
|
|
150121
|
+
var compilerOptions = program.getCompilerOptions();
|
|
150122
|
+
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
150123
|
+
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
150124
|
+
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
|
|
150125
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
|
|
150126
|
+
}
|
|
150127
|
+
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
149919
150128
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149920
150129
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149921
150130
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
@@ -149945,7 +150154,7 @@ var ts;
|
|
|
149945
150154
|
}
|
|
149946
150155
|
}
|
|
149947
150156
|
}
|
|
149948
|
-
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
|
|
150157
|
+
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
|
|
149949
150158
|
var result = [];
|
|
149950
150159
|
var compilerOptions = program.getCompilerOptions();
|
|
149951
150160
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -149958,7 +150167,7 @@ var ts;
|
|
|
149958
150167
|
return;
|
|
149959
150168
|
}
|
|
149960
150169
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
149961
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
150170
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
149962
150171
|
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 });
|
|
149963
150172
|
}
|
|
149964
150173
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
@@ -150196,9 +150405,21 @@ var ts;
|
|
|
150196
150405
|
}
|
|
150197
150406
|
function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
|
|
150198
150407
|
var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
|
|
150199
|
-
var info
|
|
150200
|
-
|
|
150201
|
-
|
|
150408
|
+
var info;
|
|
150409
|
+
if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
|
150410
|
+
info = getFixesInfoForUMDImport(context, symbolToken);
|
|
150411
|
+
}
|
|
150412
|
+
else if (!ts.isIdentifier(symbolToken)) {
|
|
150413
|
+
return undefined;
|
|
150414
|
+
}
|
|
150415
|
+
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
150416
|
+
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
150417
|
+
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
150418
|
+
return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
|
|
150419
|
+
}
|
|
150420
|
+
else {
|
|
150421
|
+
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150422
|
+
}
|
|
150202
150423
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150203
150424
|
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150204
150425
|
}
|
|
@@ -150239,6 +150460,7 @@ var ts;
|
|
|
150239
150460
|
return 0 /* EqualTo */;
|
|
150240
150461
|
}
|
|
150241
150462
|
function getFixesInfoForUMDImport(_a, token) {
|
|
150463
|
+
var _b;
|
|
150242
150464
|
var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
|
|
150243
150465
|
var checker = program.getTypeChecker();
|
|
150244
150466
|
var umdSymbol = getUmdSymbol(token, checker);
|
|
@@ -150249,7 +150471,7 @@ var ts;
|
|
|
150249
150471
|
var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150250
150472
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150251
150473
|
var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150252
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150474
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150253
150475
|
}
|
|
150254
150476
|
function getUmdSymbol(token, checker) {
|
|
150255
150477
|
// try the identifier to see if it is the umd symbol
|
|
@@ -150315,12 +150537,22 @@ var ts;
|
|
|
150315
150537
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150316
150538
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150317
150539
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150318
|
-
var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150540
|
+
var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150319
150541
|
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
|
|
150320
150542
|
var _ = _a[0], exportInfos = _a[1];
|
|
150321
150543
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150322
150544
|
}));
|
|
150323
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150545
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
|
|
150546
|
+
}
|
|
150547
|
+
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
150548
|
+
var checker = program.getTypeChecker();
|
|
150549
|
+
var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
150550
|
+
if (!symbol)
|
|
150551
|
+
return undefined;
|
|
150552
|
+
var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
|
|
150553
|
+
if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
|
|
150554
|
+
return undefined;
|
|
150555
|
+
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
150324
150556
|
}
|
|
150325
150557
|
function jsxModeNeedsExplicitImport(jsx) {
|
|
150326
150558
|
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
@@ -150329,14 +150561,20 @@ var ts;
|
|
|
150329
150561
|
var parent = symbolToken.parent;
|
|
150330
150562
|
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150331
150563
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
150332
|
-
if (
|
|
150564
|
+
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
150333
150565
|
return jsxNamespace;
|
|
150334
150566
|
}
|
|
150335
150567
|
}
|
|
150336
150568
|
return symbolToken.text;
|
|
150337
150569
|
}
|
|
150570
|
+
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
|
|
150571
|
+
if (ts.isIntrinsicJsxName(symbolToken.text))
|
|
150572
|
+
return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
|
|
150573
|
+
var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
150574
|
+
return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
|
|
150575
|
+
}
|
|
150338
150576
|
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
|
|
150339
|
-
function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
150577
|
+
function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
150340
150578
|
var _a;
|
|
150341
150579
|
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
|
|
150342
150580
|
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
|
|
@@ -150359,7 +150597,7 @@ var ts;
|
|
|
150359
150597
|
cancellationToken.throwIfCancellationRequested();
|
|
150360
150598
|
var compilerOptions = program.getCompilerOptions();
|
|
150361
150599
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
150362
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
150600
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
150363
150601
|
addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
|
|
150364
150602
|
}
|
|
150365
150603
|
// check exports with the same name
|
|
@@ -150399,14 +150637,14 @@ var ts;
|
|
|
150399
150637
|
// allowSyntheticDefaultImports/esModuleInterop is enabled.
|
|
150400
150638
|
return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
|
|
150401
150639
|
}
|
|
150402
|
-
function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150640
|
+
function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150403
150641
|
var diag;
|
|
150404
150642
|
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
|
150405
|
-
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
|
|
150643
|
+
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
|
|
150406
150644
|
});
|
|
150407
150645
|
return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
|
|
150408
150646
|
}
|
|
150409
|
-
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150647
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150410
150648
|
switch (fix.kind) {
|
|
150411
150649
|
case 0 /* UseNamespace */:
|
|
150412
150650
|
addNamespaceQualifier(changes, sourceFile, fix);
|
|
@@ -150418,11 +150656,9 @@ var ts;
|
|
|
150418
150656
|
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
|
|
150419
150657
|
doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
|
|
150420
150658
|
var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
|
|
150421
|
-
return
|
|
150422
|
-
|
|
150423
|
-
|
|
150424
|
-
moduleSpecifierWithoutQuotes
|
|
150425
|
-
]; // you too!
|
|
150659
|
+
return includeSymbolNameInDescription
|
|
150660
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
|
|
150661
|
+
: [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
|
|
150426
150662
|
}
|
|
150427
150663
|
case 3 /* AddNew */: {
|
|
150428
150664
|
var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
|
|
@@ -150431,12 +150667,84 @@ var ts;
|
|
|
150431
150667
|
var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
|
|
150432
150668
|
var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
|
|
150433
150669
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
150434
|
-
return
|
|
150670
|
+
return includeSymbolNameInDescription
|
|
150671
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
|
|
150672
|
+
: [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
|
|
150673
|
+
}
|
|
150674
|
+
case 4 /* PromoteTypeOnly */: {
|
|
150675
|
+
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
150676
|
+
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
|
|
150677
|
+
return promotedDeclaration.kind === 269 /* ImportSpecifier */
|
|
150678
|
+
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
|
|
150679
|
+
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
|
|
150435
150680
|
}
|
|
150436
150681
|
default:
|
|
150437
150682
|
return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
|
|
150438
150683
|
}
|
|
150439
150684
|
}
|
|
150685
|
+
function getModuleSpecifierText(promotedDeclaration) {
|
|
150686
|
+
var _a, _b;
|
|
150687
|
+
return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
|
|
150688
|
+
? ((_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()
|
|
150689
|
+
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
|
|
150690
|
+
}
|
|
150691
|
+
function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
|
|
150692
|
+
// See comment in `doAddExistingFix` on constant with the same name.
|
|
150693
|
+
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
|
|
150694
|
+
switch (aliasDeclaration.kind) {
|
|
150695
|
+
case 269 /* ImportSpecifier */:
|
|
150696
|
+
if (aliasDeclaration.isTypeOnly) {
|
|
150697
|
+
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
|
|
150698
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150699
|
+
var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
|
|
150700
|
+
var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
|
|
150701
|
+
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
150702
|
+
}
|
|
150703
|
+
else {
|
|
150704
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
150705
|
+
}
|
|
150706
|
+
return aliasDeclaration;
|
|
150707
|
+
}
|
|
150708
|
+
else {
|
|
150709
|
+
ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
150710
|
+
promoteImportClause(aliasDeclaration.parent.parent);
|
|
150711
|
+
return aliasDeclaration.parent.parent;
|
|
150712
|
+
}
|
|
150713
|
+
case 266 /* ImportClause */:
|
|
150714
|
+
promoteImportClause(aliasDeclaration);
|
|
150715
|
+
return aliasDeclaration;
|
|
150716
|
+
case 267 /* NamespaceImport */:
|
|
150717
|
+
promoteImportClause(aliasDeclaration.parent);
|
|
150718
|
+
return aliasDeclaration.parent;
|
|
150719
|
+
case 264 /* ImportEqualsDeclaration */:
|
|
150720
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
|
|
150721
|
+
return aliasDeclaration;
|
|
150722
|
+
default:
|
|
150723
|
+
ts.Debug.failBadSyntaxKind(aliasDeclaration);
|
|
150724
|
+
}
|
|
150725
|
+
function promoteImportClause(importClause) {
|
|
150726
|
+
changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
150727
|
+
if (convertExistingToTypeOnly) {
|
|
150728
|
+
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
|
|
150729
|
+
if (namedImports && namedImports.elements.length > 1) {
|
|
150730
|
+
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
|
|
150731
|
+
aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
|
|
150732
|
+
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
150733
|
+
// The import specifier being promoted will be the only non-type-only,
|
|
150734
|
+
// import in the NamedImports, so it should be moved to the front.
|
|
150735
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150736
|
+
changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
|
|
150737
|
+
}
|
|
150738
|
+
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
|
|
150739
|
+
var element = _a[_i];
|
|
150740
|
+
if (element !== aliasDeclaration && !element.isTypeOnly) {
|
|
150741
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
|
|
150742
|
+
}
|
|
150743
|
+
}
|
|
150744
|
+
}
|
|
150745
|
+
}
|
|
150746
|
+
}
|
|
150747
|
+
}
|
|
150440
150748
|
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
|
|
150441
150749
|
var _a;
|
|
150442
150750
|
if (clause.kind === 200 /* ObjectBindingPattern */) {
|
|
@@ -150474,13 +150782,7 @@ var ts;
|
|
|
150474
150782
|
var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
|
|
150475
150783
|
? 0
|
|
150476
150784
|
: ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
|
|
150477
|
-
|
|
150478
|
-
if (prevSpecifier) {
|
|
150479
|
-
changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
|
|
150480
|
-
}
|
|
150481
|
-
else {
|
|
150482
|
-
changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
|
|
150483
|
-
}
|
|
150785
|
+
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
150484
150786
|
}
|
|
150485
150787
|
}
|
|
150486
150788
|
else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
|
|
@@ -150595,17 +150897,20 @@ var ts;
|
|
|
150595
150897
|
var declarations = _a.declarations;
|
|
150596
150898
|
return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
|
|
150597
150899
|
}
|
|
150598
|
-
function moduleSymbolToValidIdentifier(moduleSymbol, target) {
|
|
150599
|
-
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
|
|
150900
|
+
function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
|
|
150901
|
+
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
|
|
150600
150902
|
}
|
|
150601
150903
|
codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
|
|
150602
|
-
function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
|
|
150904
|
+
function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
|
|
150603
150905
|
var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
|
|
150604
150906
|
var res = "";
|
|
150605
150907
|
var lastCharWasValid = true;
|
|
150606
150908
|
var firstCharCode = baseName.charCodeAt(0);
|
|
150607
150909
|
if (ts.isIdentifierStart(firstCharCode, target)) {
|
|
150608
150910
|
res += String.fromCharCode(firstCharCode);
|
|
150911
|
+
if (forceCapitalize) {
|
|
150912
|
+
res = res.toUpperCase();
|
|
150913
|
+
}
|
|
150609
150914
|
}
|
|
150610
150915
|
else {
|
|
150611
150916
|
lastCharWasValid = false;
|
|
@@ -158224,14 +158529,22 @@ var ts;
|
|
|
158224
158529
|
var result = [];
|
|
158225
158530
|
return visitor(selection) ? undefined : result;
|
|
158226
158531
|
function visitor(node) {
|
|
158227
|
-
var _a;
|
|
158228
158532
|
if (ts.isTypeReferenceNode(node)) {
|
|
158229
158533
|
if (ts.isIdentifier(node.typeName)) {
|
|
158230
|
-
var
|
|
158231
|
-
var
|
|
158232
|
-
|
|
158233
|
-
|
|
158234
|
-
|
|
158534
|
+
var typeName = node.typeName;
|
|
158535
|
+
var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
|
|
158536
|
+
for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
|
|
158537
|
+
var decl = _a[_i];
|
|
158538
|
+
if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
|
|
158539
|
+
// skip extraction if the type node is in the range of the type parameter declaration.
|
|
158540
|
+
// function foo<T extends { a?: /**/T }>(): void;
|
|
158541
|
+
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
158542
|
+
return true;
|
|
158543
|
+
}
|
|
158544
|
+
if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
158545
|
+
ts.pushIfUnique(result, decl);
|
|
158546
|
+
break;
|
|
158547
|
+
}
|
|
158235
158548
|
}
|
|
158236
158549
|
}
|
|
158237
158550
|
}
|
|
@@ -160574,13 +160887,11 @@ var ts;
|
|
|
160574
160887
|
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
160575
160888
|
case 171 /* GetAccessor */:
|
|
160576
160889
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
160577
|
-
this.contextualGetAccessorDocumentationComment = ts.emptyArray;
|
|
160578
160890
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
160579
160891
|
}
|
|
160580
160892
|
return this.contextualGetAccessorDocumentationComment;
|
|
160581
160893
|
case 172 /* SetAccessor */:
|
|
160582
160894
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
160583
|
-
this.contextualSetAccessorDocumentationComment = ts.emptyArray;
|
|
160584
160895
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
160585
160896
|
}
|
|
160586
160897
|
return this.contextualSetAccessorDocumentationComment;
|
|
@@ -160590,10 +160901,26 @@ var ts;
|
|
|
160590
160901
|
};
|
|
160591
160902
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
160592
160903
|
if (this.tags === undefined) {
|
|
160593
|
-
this.tags =
|
|
160904
|
+
this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
|
|
160594
160905
|
}
|
|
160595
160906
|
return this.tags;
|
|
160596
160907
|
};
|
|
160908
|
+
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
160909
|
+
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
160910
|
+
case 171 /* GetAccessor */:
|
|
160911
|
+
if (!this.contextualGetAccessorTags) {
|
|
160912
|
+
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
160913
|
+
}
|
|
160914
|
+
return this.contextualGetAccessorTags;
|
|
160915
|
+
case 172 /* SetAccessor */:
|
|
160916
|
+
if (!this.contextualSetAccessorTags) {
|
|
160917
|
+
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
160918
|
+
}
|
|
160919
|
+
return this.contextualSetAccessorTags;
|
|
160920
|
+
default:
|
|
160921
|
+
return this.getJsDocTags(checker);
|
|
160922
|
+
}
|
|
160923
|
+
};
|
|
160597
160924
|
return SymbolObject;
|
|
160598
160925
|
}());
|
|
160599
160926
|
var TokenObject = /** @class */ (function (_super) {
|
|
@@ -160763,10 +161090,7 @@ var ts;
|
|
|
160763
161090
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160764
161091
|
};
|
|
160765
161092
|
SignatureObject.prototype.getJsDocTags = function () {
|
|
160766
|
-
|
|
160767
|
-
this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : [];
|
|
160768
|
-
}
|
|
160769
|
-
return this.jsDocTags;
|
|
161093
|
+
return this.jsDocTags || (this.jsDocTags = getJsDocTagsOfDeclarations(ts.singleElementArray(this.declaration), this.checker));
|
|
160770
161094
|
};
|
|
160771
161095
|
return SignatureObject;
|
|
160772
161096
|
}());
|
|
@@ -160778,12 +161102,30 @@ var ts;
|
|
|
160778
161102
|
function hasJSDocInheritDocTag(node) {
|
|
160779
161103
|
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
160780
161104
|
}
|
|
160781
|
-
function
|
|
160782
|
-
|
|
160783
|
-
|
|
160784
|
-
|
|
160785
|
-
|
|
160786
|
-
|
|
161105
|
+
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
161106
|
+
if (!declarations)
|
|
161107
|
+
return ts.emptyArray;
|
|
161108
|
+
var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
|
|
161109
|
+
if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
161110
|
+
var seenSymbols_1 = new ts.Set();
|
|
161111
|
+
var _loop_22 = function (declaration) {
|
|
161112
|
+
var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
161113
|
+
var _a;
|
|
161114
|
+
if (!seenSymbols_1.has(symbol)) {
|
|
161115
|
+
seenSymbols_1.add(symbol);
|
|
161116
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
161117
|
+
return symbol.getContextualJsDocTags(declaration, checker);
|
|
161118
|
+
}
|
|
161119
|
+
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
|
|
161120
|
+
}
|
|
161121
|
+
});
|
|
161122
|
+
if (inheritedTags) {
|
|
161123
|
+
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
161124
|
+
}
|
|
161125
|
+
};
|
|
161126
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
161127
|
+
var declaration = declarations_6[_i];
|
|
161128
|
+
_loop_22(declaration);
|
|
160787
161129
|
}
|
|
160788
161130
|
}
|
|
160789
161131
|
return tags;
|
|
@@ -160793,18 +161135,24 @@ var ts;
|
|
|
160793
161135
|
return ts.emptyArray;
|
|
160794
161136
|
var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
|
|
160795
161137
|
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
160796
|
-
var
|
|
160797
|
-
|
|
160798
|
-
var declaration = declarations_6[_i];
|
|
161138
|
+
var seenSymbols_2 = new ts.Set();
|
|
161139
|
+
var _loop_23 = function (declaration) {
|
|
160799
161140
|
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
160800
|
-
if (!
|
|
160801
|
-
|
|
161141
|
+
if (!seenSymbols_2.has(symbol)) {
|
|
161142
|
+
seenSymbols_2.add(symbol);
|
|
161143
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
161144
|
+
return symbol.getContextualDocumentationComment(declaration, checker);
|
|
161145
|
+
}
|
|
160802
161146
|
return symbol.getDocumentationComment(checker);
|
|
160803
161147
|
}
|
|
160804
161148
|
});
|
|
160805
161149
|
// TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
|
|
160806
161150
|
if (inheritedDocs)
|
|
160807
161151
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
161152
|
+
};
|
|
161153
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
161154
|
+
var declaration = declarations_7[_i];
|
|
161155
|
+
_loop_23(declaration);
|
|
160808
161156
|
}
|
|
160809
161157
|
}
|
|
160810
161158
|
return doc;
|