typescript 4.6.0-dev.20220210 → 4.6.0-dev.20220211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +70 -41
- package/lib/tsserver.js +210 -78
- package/lib/tsserverlibrary.js +210 -78
- package/lib/typescript.js +210 -78
- package/lib/typescriptServices.js +210 -78
- package/lib/typingsInstaller.js +70 -44
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220211";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8080,6 +8080,7 @@ var ts;
|
|
|
8080
8080
|
An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
|
|
8081
8081
|
Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
|
|
8082
8082
|
An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
|
|
8083
|
+
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8083
8084
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8084
8085
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8085
8086
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -9638,6 +9639,9 @@ var ts;
|
|
|
9638
9639
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9639
9640
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9640
9641
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9642
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9643
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9644
|
+
Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
9641
9645
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
9642
9646
|
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9643
9647
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -54635,12 +54639,9 @@ var ts;
|
|
|
54635
54639
|
}
|
|
54636
54640
|
}
|
|
54637
54641
|
if (ts.isInJSFile(declaration)) {
|
|
54638
|
-
var
|
|
54639
|
-
if (
|
|
54640
|
-
|
|
54641
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54642
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54643
|
-
}
|
|
54642
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54643
|
+
if (type_1)
|
|
54644
|
+
return type_1;
|
|
54644
54645
|
}
|
|
54645
54646
|
// Use contextual parameter type if one is available
|
|
54646
54647
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -55207,9 +55208,9 @@ var ts;
|
|
|
55207
55208
|
if (typeNode === undefined) {
|
|
55208
55209
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55209
55210
|
}
|
|
55210
|
-
var
|
|
55211
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55211
55212
|
// an errorType will make `checkTryStatement` issue an error
|
|
55212
|
-
return isTypeAny(
|
|
55213
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55213
55214
|
}
|
|
55214
55215
|
// Handle export default expressions
|
|
55215
55216
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55438,11 +55439,11 @@ var ts;
|
|
|
55438
55439
|
return errorType;
|
|
55439
55440
|
}
|
|
55440
55441
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55441
|
-
var
|
|
55442
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55442
55443
|
if (!popTypeResolution()) {
|
|
55443
55444
|
return reportCircularityError(symbol);
|
|
55444
55445
|
}
|
|
55445
|
-
return
|
|
55446
|
+
return type_3;
|
|
55446
55447
|
}
|
|
55447
55448
|
}
|
|
55448
55449
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -57674,10 +57675,10 @@ var ts;
|
|
|
57674
57675
|
var baseTypes = [];
|
|
57675
57676
|
var different = false;
|
|
57676
57677
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57677
|
-
var
|
|
57678
|
-
var baseType = getBaseConstraint(
|
|
57678
|
+
var type_4 = types_7[_i];
|
|
57679
|
+
var baseType = getBaseConstraint(type_4);
|
|
57679
57680
|
if (baseType) {
|
|
57680
|
-
if (baseType !==
|
|
57681
|
+
if (baseType !== type_4) {
|
|
57681
57682
|
different = true;
|
|
57682
57683
|
}
|
|
57683
57684
|
baseTypes.push(baseType);
|
|
@@ -58390,6 +58391,13 @@ var ts;
|
|
|
58390
58391
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58391
58392
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58392
58393
|
}
|
|
58394
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58395
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58396
|
+
if (!signature)
|
|
58397
|
+
return undefined;
|
|
58398
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58399
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58400
|
+
}
|
|
58393
58401
|
function getReturnTypeOfTypeTag(node) {
|
|
58394
58402
|
var signature = getSignatureOfTypeTag(node);
|
|
58395
58403
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -75579,8 +75587,8 @@ var ts;
|
|
|
75579
75587
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75580
75588
|
var synthType = type;
|
|
75581
75589
|
if (!synthType.defaultOnlyType) {
|
|
75582
|
-
var
|
|
75583
|
-
synthType.defaultOnlyType =
|
|
75590
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75591
|
+
synthType.defaultOnlyType = type_5;
|
|
75584
75592
|
}
|
|
75585
75593
|
return synthType.defaultOnlyType;
|
|
75586
75594
|
}
|
|
@@ -76307,12 +76315,12 @@ var ts;
|
|
|
76307
76315
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76308
76316
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76309
76317
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76310
|
-
var
|
|
76318
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76311
76319
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76312
|
-
if (
|
|
76320
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76313
76321
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76314
76322
|
}
|
|
76315
|
-
return !!(filterType(
|
|
76323
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76316
76324
|
}
|
|
76317
76325
|
var type = getTypeOfExpression(node.expression);
|
|
76318
76326
|
if (!isLiteralType(type)) {
|
|
@@ -78434,6 +78442,7 @@ var ts;
|
|
|
78434
78442
|
}
|
|
78435
78443
|
}
|
|
78436
78444
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78445
|
+
checkUnmatchedJSDocParameters(node);
|
|
78437
78446
|
ts.forEach(node.parameters, checkParameter);
|
|
78438
78447
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78439
78448
|
if (node.type) {
|
|
@@ -80005,31 +80014,6 @@ var ts;
|
|
|
80005
80014
|
}
|
|
80006
80015
|
function checkJSDocParameterTag(node) {
|
|
80007
80016
|
checkSourceElement(node.typeExpression);
|
|
80008
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
80009
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
80010
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
80011
|
-
// and give a better error message when the host function mentions `arguments`
|
|
80012
|
-
// but the tag doesn't have an array type
|
|
80013
|
-
if (decl) {
|
|
80014
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
80015
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
80016
|
-
return;
|
|
80017
|
-
}
|
|
80018
|
-
if (!containsArgumentsReference(decl)) {
|
|
80019
|
-
if (ts.isQualifiedName(node.name)) {
|
|
80020
|
-
error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
|
|
80021
|
-
}
|
|
80022
|
-
else {
|
|
80023
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
80024
|
-
}
|
|
80025
|
-
}
|
|
80026
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
80027
|
-
node.typeExpression && node.typeExpression.type &&
|
|
80028
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
80029
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 /* QualifiedName */ ? node.name.right : node.name));
|
|
80030
|
-
}
|
|
80031
|
-
}
|
|
80032
|
-
}
|
|
80033
80017
|
}
|
|
80034
80018
|
function checkJSDocPropertyTag(node) {
|
|
80035
80019
|
checkSourceElement(node.typeExpression);
|
|
@@ -82102,6 +82086,45 @@ var ts;
|
|
|
82102
82086
|
error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
|
|
82103
82087
|
}
|
|
82104
82088
|
}
|
|
82089
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82090
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82091
|
+
if (!ts.length(jsdocParameters))
|
|
82092
|
+
return;
|
|
82093
|
+
var isJs = ts.isInJSFile(node);
|
|
82094
|
+
var parameters = new ts.Set();
|
|
82095
|
+
var excludedParameters = new ts.Set();
|
|
82096
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82097
|
+
var name = _a.name;
|
|
82098
|
+
if (ts.isIdentifier(name)) {
|
|
82099
|
+
parameters.add(name.escapedText);
|
|
82100
|
+
}
|
|
82101
|
+
if (ts.isBindingPattern(name)) {
|
|
82102
|
+
excludedParameters.add(index);
|
|
82103
|
+
}
|
|
82104
|
+
});
|
|
82105
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82106
|
+
if (containsArguments) {
|
|
82107
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82108
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82109
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82110
|
+
errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
|
|
82111
|
+
}
|
|
82112
|
+
}
|
|
82113
|
+
else {
|
|
82114
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82115
|
+
var name = _a.name;
|
|
82116
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82117
|
+
return;
|
|
82118
|
+
}
|
|
82119
|
+
if (ts.isQualifiedName(name)) {
|
|
82120
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82121
|
+
}
|
|
82122
|
+
else {
|
|
82123
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82124
|
+
}
|
|
82125
|
+
});
|
|
82126
|
+
}
|
|
82127
|
+
}
|
|
82105
82128
|
/**
|
|
82106
82129
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82107
82130
|
*/
|
|
@@ -83310,6 +83333,9 @@ var ts;
|
|
|
83310
83333
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83311
83334
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83312
83335
|
}
|
|
83336
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83337
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83338
|
+
}
|
|
83313
83339
|
break;
|
|
83314
83340
|
}
|
|
83315
83341
|
case 274 /* ExportSpecifier */: {
|
|
@@ -145828,8 +145854,18 @@ var ts;
|
|
|
145828
145854
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
145829
145855
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
145830
145856
|
};
|
|
145857
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
145858
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
145859
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
145860
|
+
});
|
|
145861
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
145862
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
145863
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145864
|
+
};
|
|
145865
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
145866
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
145867
|
+
};
|
|
145831
145868
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
145832
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
145833
145869
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145834
145870
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
145835
145871
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -145837,20 +145873,10 @@ var ts;
|
|
|
145837
145873
|
oldTags[i] = merged;
|
|
145838
145874
|
return !!merged;
|
|
145839
145875
|
}); });
|
|
145840
|
-
|
|
145841
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145842
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145843
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145844
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145845
|
-
var host = updateJSDocHost(parent);
|
|
145846
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145876
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
145847
145877
|
};
|
|
145848
145878
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
145849
|
-
|
|
145850
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145851
|
-
var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray([], (ts.filter(oldTags, predicate) || ts.emptyArray), true)));
|
|
145852
|
-
var host = updateJSDocHost(parent);
|
|
145853
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145879
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
145854
145880
|
};
|
|
145855
145881
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
145856
145882
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -149645,9 +149671,9 @@ var ts;
|
|
|
149645
149671
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149646
149672
|
var checker = program.getTypeChecker();
|
|
149647
149673
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149648
|
-
var
|
|
149674
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149649
149675
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149650
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
149676
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149651
149677
|
if (fix) {
|
|
149652
149678
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149653
149679
|
}
|
|
@@ -149836,7 +149862,7 @@ var ts;
|
|
|
149836
149862
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149837
149863
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149838
149864
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149839
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
149865
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
149840
149866
|
}
|
|
149841
149867
|
function codeFixActionToCodeAction(_a) {
|
|
149842
149868
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149896,7 +149922,7 @@ var ts;
|
|
|
149896
149922
|
/*position*/ undefined,
|
|
149897
149923
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149898
149924
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149899
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
149925
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
149900
149926
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149901
149927
|
}
|
|
149902
149928
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150066,7 +150092,7 @@ var ts;
|
|
|
150066
150092
|
// 5. Literally nothing to go on
|
|
150067
150093
|
return true;
|
|
150068
150094
|
}
|
|
150069
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150095
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
150070
150096
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
150071
150097
|
var compilerOptions = program.getCompilerOptions();
|
|
150072
150098
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -150075,7 +150101,7 @@ var ts;
|
|
|
150075
150101
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
150076
150102
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
150077
150103
|
var computedWithoutCacheCount = 0;
|
|
150078
|
-
var fixes = ts.flatMap(
|
|
150104
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
150079
150105
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
150080
150106
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
150081
150107
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -150084,7 +150110,7 @@ var ts;
|
|
|
150084
150110
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
150085
150111
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
150086
150112
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
150087
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150113
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
150088
150114
|
: {
|
|
150089
150115
|
kind: 3 /* AddNew */,
|
|
150090
150116
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -150092,6 +150118,7 @@ var ts;
|
|
|
150092
150118
|
useRequire: useRequire,
|
|
150093
150119
|
addAsTypeOnly: addAsTypeOnly,
|
|
150094
150120
|
exportInfo: exportInfo,
|
|
150121
|
+
isReExport: i > 0,
|
|
150095
150122
|
};
|
|
150096
150123
|
});
|
|
150097
150124
|
});
|
|
@@ -150129,12 +150156,13 @@ var ts;
|
|
|
150129
150156
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150130
150157
|
}
|
|
150131
150158
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150132
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150159
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150133
150160
|
}
|
|
150134
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150135
|
-
|
|
150161
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150162
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150163
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150136
150164
|
}
|
|
150137
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150165
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150138
150166
|
if (!ts.some(fixes))
|
|
150139
150167
|
return;
|
|
150140
150168
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150143,22 +150171,37 @@ var ts;
|
|
|
150143
150171
|
}
|
|
150144
150172
|
return fixes.reduce(function (best, fix) {
|
|
150145
150173
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150146
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150174
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150147
150175
|
});
|
|
150148
150176
|
}
|
|
150149
150177
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150150
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150178
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150151
150179
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150152
150180
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150153
150181
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150154
|
-
|| ts.compareBooleans(
|
|
150182
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150155
150183
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150156
150184
|
}
|
|
150157
150185
|
return 0 /* EqualTo */;
|
|
150158
150186
|
}
|
|
150159
|
-
|
|
150160
|
-
|
|
150161
|
-
|
|
150187
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150188
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150189
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150190
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150191
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150192
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150193
|
+
var _a;
|
|
150194
|
+
if (fix.isReExport &&
|
|
150195
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150196
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150197
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150198
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150199
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150200
|
+
}
|
|
150201
|
+
return false;
|
|
150202
|
+
}
|
|
150203
|
+
function isIndexFileName(fileName) {
|
|
150204
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150162
150205
|
}
|
|
150163
150206
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150164
150207
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150176,9 +150219,9 @@ var ts;
|
|
|
150176
150219
|
return undefined;
|
|
150177
150220
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150178
150221
|
var symbolName = umdSymbol.name;
|
|
150179
|
-
var
|
|
150222
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150180
150223
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150181
|
-
var fixes = getImportFixes(
|
|
150224
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150182
150225
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150183
150226
|
}
|
|
150184
150227
|
function getUmdSymbol(token, checker) {
|
|
@@ -150245,8 +150288,8 @@ var ts;
|
|
|
150245
150288
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150246
150289
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150247
150290
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150248
|
-
var
|
|
150249
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150291
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150292
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150250
150293
|
var _ = _a[0], exportInfos = _a[1];
|
|
150251
150294
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150252
150295
|
}));
|
|
@@ -152347,6 +152390,95 @@ var ts;
|
|
|
152347
152390
|
})(ts || (ts = {}));
|
|
152348
152391
|
/* @internal */
|
|
152349
152392
|
var ts;
|
|
152393
|
+
(function (ts) {
|
|
152394
|
+
var codefix;
|
|
152395
|
+
(function (codefix) {
|
|
152396
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
152397
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
152398
|
+
var errorCodes = [
|
|
152399
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
152400
|
+
];
|
|
152401
|
+
codefix.registerCodeFix({
|
|
152402
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
152403
|
+
errorCodes: errorCodes,
|
|
152404
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
152405
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
152406
|
+
var actions = [];
|
|
152407
|
+
var info = getInfo(sourceFile, span.start);
|
|
152408
|
+
if (info) {
|
|
152409
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
152410
|
+
ts.append(actions, getRenameAction(context, info));
|
|
152411
|
+
return actions;
|
|
152412
|
+
}
|
|
152413
|
+
return undefined;
|
|
152414
|
+
},
|
|
152415
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
152416
|
+
var tagsToSignature = new ts.Map();
|
|
152417
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
152418
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
152419
|
+
var file = _a.file, start = _a.start;
|
|
152420
|
+
var info = getInfo(file, start);
|
|
152421
|
+
if (info) {
|
|
152422
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
152423
|
+
}
|
|
152424
|
+
});
|
|
152425
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
152426
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
152427
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
152428
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
152429
|
+
}
|
|
152430
|
+
});
|
|
152431
|
+
}));
|
|
152432
|
+
}
|
|
152433
|
+
});
|
|
152434
|
+
function getDeleteAction(context, _a) {
|
|
152435
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152436
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152437
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
152438
|
+
});
|
|
152439
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
152440
|
+
}
|
|
152441
|
+
function getRenameAction(context, _a) {
|
|
152442
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152443
|
+
if (!ts.length(signature.parameters))
|
|
152444
|
+
return undefined;
|
|
152445
|
+
var sourceFile = context.sourceFile;
|
|
152446
|
+
var tags = ts.getJSDocTags(signature);
|
|
152447
|
+
var names = new ts.Set();
|
|
152448
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
152449
|
+
var tag = tags_2[_i];
|
|
152450
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
152451
|
+
names.add(tag.name.escapedText);
|
|
152452
|
+
}
|
|
152453
|
+
}
|
|
152454
|
+
// @todo - match to all available names instead to the first parameter name
|
|
152455
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
152456
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
152457
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
152458
|
+
});
|
|
152459
|
+
if (parameterName === undefined)
|
|
152460
|
+
return undefined;
|
|
152461
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
152462
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152463
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
152464
|
+
});
|
|
152465
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
152466
|
+
}
|
|
152467
|
+
function getInfo(sourceFile, pos) {
|
|
152468
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
152469
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
152470
|
+
var jsDocParameterTag = token.parent;
|
|
152471
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
152472
|
+
if (signature) {
|
|
152473
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
152474
|
+
}
|
|
152475
|
+
}
|
|
152476
|
+
return undefined;
|
|
152477
|
+
}
|
|
152478
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
152479
|
+
})(ts || (ts = {}));
|
|
152480
|
+
/* @internal */
|
|
152481
|
+
var ts;
|
|
152350
152482
|
(function (ts) {
|
|
152351
152483
|
var codefix;
|
|
152352
152484
|
(function (codefix) {
|