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/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.20220211";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8274,6 +8274,7 @@ var ts;
|
|
|
8274
8274
|
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."),
|
|
8275
8275
|
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."),
|
|
8276
8276
|
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."),
|
|
8277
|
+
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."),
|
|
8277
8278
|
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."),
|
|
8278
8279
|
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."),
|
|
8279
8280
|
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."),
|
|
@@ -9832,6 +9833,9 @@ var ts;
|
|
|
9832
9833
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9833
9834
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9834
9835
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9836
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9837
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9838
|
+
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}'"),
|
|
9835
9839
|
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."),
|
|
9836
9840
|
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'."),
|
|
9837
9841
|
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?"),
|
|
@@ -54829,12 +54833,9 @@ var ts;
|
|
|
54829
54833
|
}
|
|
54830
54834
|
}
|
|
54831
54835
|
if (ts.isInJSFile(declaration)) {
|
|
54832
|
-
var
|
|
54833
|
-
if (
|
|
54834
|
-
|
|
54835
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54836
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54837
|
-
}
|
|
54836
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54837
|
+
if (type_1)
|
|
54838
|
+
return type_1;
|
|
54838
54839
|
}
|
|
54839
54840
|
// Use contextual parameter type if one is available
|
|
54840
54841
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -55401,9 +55402,9 @@ var ts;
|
|
|
55401
55402
|
if (typeNode === undefined) {
|
|
55402
55403
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55403
55404
|
}
|
|
55404
|
-
var
|
|
55405
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55405
55406
|
// an errorType will make `checkTryStatement` issue an error
|
|
55406
|
-
return isTypeAny(
|
|
55407
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55407
55408
|
}
|
|
55408
55409
|
// Handle export default expressions
|
|
55409
55410
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55632,11 +55633,11 @@ var ts;
|
|
|
55632
55633
|
return errorType;
|
|
55633
55634
|
}
|
|
55634
55635
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55635
|
-
var
|
|
55636
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55636
55637
|
if (!popTypeResolution()) {
|
|
55637
55638
|
return reportCircularityError(symbol);
|
|
55638
55639
|
}
|
|
55639
|
-
return
|
|
55640
|
+
return type_3;
|
|
55640
55641
|
}
|
|
55641
55642
|
}
|
|
55642
55643
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -57868,10 +57869,10 @@ var ts;
|
|
|
57868
57869
|
var baseTypes = [];
|
|
57869
57870
|
var different = false;
|
|
57870
57871
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57871
|
-
var
|
|
57872
|
-
var baseType = getBaseConstraint(
|
|
57872
|
+
var type_4 = types_7[_i];
|
|
57873
|
+
var baseType = getBaseConstraint(type_4);
|
|
57873
57874
|
if (baseType) {
|
|
57874
|
-
if (baseType !==
|
|
57875
|
+
if (baseType !== type_4) {
|
|
57875
57876
|
different = true;
|
|
57876
57877
|
}
|
|
57877
57878
|
baseTypes.push(baseType);
|
|
@@ -58584,6 +58585,13 @@ var ts;
|
|
|
58584
58585
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58585
58586
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58586
58587
|
}
|
|
58588
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58589
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58590
|
+
if (!signature)
|
|
58591
|
+
return undefined;
|
|
58592
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58593
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58594
|
+
}
|
|
58587
58595
|
function getReturnTypeOfTypeTag(node) {
|
|
58588
58596
|
var signature = getSignatureOfTypeTag(node);
|
|
58589
58597
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -75773,8 +75781,8 @@ var ts;
|
|
|
75773
75781
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75774
75782
|
var synthType = type;
|
|
75775
75783
|
if (!synthType.defaultOnlyType) {
|
|
75776
|
-
var
|
|
75777
|
-
synthType.defaultOnlyType =
|
|
75784
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75785
|
+
synthType.defaultOnlyType = type_5;
|
|
75778
75786
|
}
|
|
75779
75787
|
return synthType.defaultOnlyType;
|
|
75780
75788
|
}
|
|
@@ -76501,12 +76509,12 @@ var ts;
|
|
|
76501
76509
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76502
76510
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76503
76511
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76504
|
-
var
|
|
76512
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76505
76513
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76506
|
-
if (
|
|
76514
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76507
76515
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76508
76516
|
}
|
|
76509
|
-
return !!(filterType(
|
|
76517
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76510
76518
|
}
|
|
76511
76519
|
var type = getTypeOfExpression(node.expression);
|
|
76512
76520
|
if (!isLiteralType(type)) {
|
|
@@ -78628,6 +78636,7 @@ var ts;
|
|
|
78628
78636
|
}
|
|
78629
78637
|
}
|
|
78630
78638
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78639
|
+
checkUnmatchedJSDocParameters(node);
|
|
78631
78640
|
ts.forEach(node.parameters, checkParameter);
|
|
78632
78641
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78633
78642
|
if (node.type) {
|
|
@@ -80199,31 +80208,6 @@ var ts;
|
|
|
80199
80208
|
}
|
|
80200
80209
|
function checkJSDocParameterTag(node) {
|
|
80201
80210
|
checkSourceElement(node.typeExpression);
|
|
80202
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
80203
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
80204
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
80205
|
-
// and give a better error message when the host function mentions `arguments`
|
|
80206
|
-
// but the tag doesn't have an array type
|
|
80207
|
-
if (decl) {
|
|
80208
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
80209
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
80210
|
-
return;
|
|
80211
|
-
}
|
|
80212
|
-
if (!containsArgumentsReference(decl)) {
|
|
80213
|
-
if (ts.isQualifiedName(node.name)) {
|
|
80214
|
-
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));
|
|
80215
|
-
}
|
|
80216
|
-
else {
|
|
80217
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
80218
|
-
}
|
|
80219
|
-
}
|
|
80220
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
80221
|
-
node.typeExpression && node.typeExpression.type &&
|
|
80222
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
80223
|
-
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));
|
|
80224
|
-
}
|
|
80225
|
-
}
|
|
80226
|
-
}
|
|
80227
80211
|
}
|
|
80228
80212
|
function checkJSDocPropertyTag(node) {
|
|
80229
80213
|
checkSourceElement(node.typeExpression);
|
|
@@ -82296,6 +82280,45 @@ var ts;
|
|
|
82296
82280
|
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
|
|
82297
82281
|
}
|
|
82298
82282
|
}
|
|
82283
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82284
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82285
|
+
if (!ts.length(jsdocParameters))
|
|
82286
|
+
return;
|
|
82287
|
+
var isJs = ts.isInJSFile(node);
|
|
82288
|
+
var parameters = new ts.Set();
|
|
82289
|
+
var excludedParameters = new ts.Set();
|
|
82290
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82291
|
+
var name = _a.name;
|
|
82292
|
+
if (ts.isIdentifier(name)) {
|
|
82293
|
+
parameters.add(name.escapedText);
|
|
82294
|
+
}
|
|
82295
|
+
if (ts.isBindingPattern(name)) {
|
|
82296
|
+
excludedParameters.add(index);
|
|
82297
|
+
}
|
|
82298
|
+
});
|
|
82299
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82300
|
+
if (containsArguments) {
|
|
82301
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82302
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82303
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82304
|
+
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));
|
|
82305
|
+
}
|
|
82306
|
+
}
|
|
82307
|
+
else {
|
|
82308
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82309
|
+
var name = _a.name;
|
|
82310
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82311
|
+
return;
|
|
82312
|
+
}
|
|
82313
|
+
if (ts.isQualifiedName(name)) {
|
|
82314
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82315
|
+
}
|
|
82316
|
+
else {
|
|
82317
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82318
|
+
}
|
|
82319
|
+
});
|
|
82320
|
+
}
|
|
82321
|
+
}
|
|
82299
82322
|
/**
|
|
82300
82323
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82301
82324
|
*/
|
|
@@ -83504,6 +83527,9 @@ var ts;
|
|
|
83504
83527
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83505
83528
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83506
83529
|
}
|
|
83530
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83531
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83532
|
+
}
|
|
83507
83533
|
break;
|
|
83508
83534
|
}
|
|
83509
83535
|
case 274 /* ExportSpecifier */: {
|
|
@@ -146439,8 +146465,18 @@ var ts;
|
|
|
146439
146465
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
146440
146466
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
146441
146467
|
};
|
|
146468
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
146469
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
146470
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
146471
|
+
});
|
|
146472
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
146473
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
146474
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
146475
|
+
};
|
|
146476
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
146477
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
146478
|
+
};
|
|
146442
146479
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
146443
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
146444
146480
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
146445
146481
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
146446
146482
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -146448,20 +146484,10 @@ var ts;
|
|
|
146448
146484
|
oldTags[i] = merged;
|
|
146449
146485
|
return !!merged;
|
|
146450
146486
|
}); });
|
|
146451
|
-
|
|
146452
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
146453
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
146454
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
146455
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
146456
|
-
var host = updateJSDocHost(parent);
|
|
146457
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146487
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
146458
146488
|
};
|
|
146459
146489
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
146460
|
-
|
|
146461
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
146462
|
-
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)));
|
|
146463
|
-
var host = updateJSDocHost(parent);
|
|
146464
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146490
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
146465
146491
|
};
|
|
146466
146492
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
146467
146493
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -150256,9 +150282,9 @@ var ts;
|
|
|
150256
150282
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
150257
150283
|
var checker = program.getTypeChecker();
|
|
150258
150284
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
150259
|
-
var
|
|
150285
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
150260
150286
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150261
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
150287
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
150262
150288
|
if (fix) {
|
|
150263
150289
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
150264
150290
|
}
|
|
@@ -150447,7 +150473,7 @@ var ts;
|
|
|
150447
150473
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
150448
150474
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
150449
150475
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
150450
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
150476
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
150451
150477
|
}
|
|
150452
150478
|
function codeFixActionToCodeAction(_a) {
|
|
150453
150479
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -150507,7 +150533,7 @@ var ts;
|
|
|
150507
150533
|
/*position*/ undefined,
|
|
150508
150534
|
/*isValidTypeOnlyUseSite*/ false,
|
|
150509
150535
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
150510
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
150536
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
150511
150537
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
150512
150538
|
}
|
|
150513
150539
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150677,7 +150703,7 @@ var ts;
|
|
|
150677
150703
|
// 5. Literally nothing to go on
|
|
150678
150704
|
return true;
|
|
150679
150705
|
}
|
|
150680
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150706
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
150681
150707
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
150682
150708
|
var compilerOptions = program.getCompilerOptions();
|
|
150683
150709
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -150686,7 +150712,7 @@ var ts;
|
|
|
150686
150712
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
150687
150713
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
150688
150714
|
var computedWithoutCacheCount = 0;
|
|
150689
|
-
var fixes = ts.flatMap(
|
|
150715
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
150690
150716
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
150691
150717
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
150692
150718
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -150695,7 +150721,7 @@ var ts;
|
|
|
150695
150721
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
150696
150722
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
150697
150723
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
150698
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150724
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
150699
150725
|
: {
|
|
150700
150726
|
kind: 3 /* AddNew */,
|
|
150701
150727
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -150703,6 +150729,7 @@ var ts;
|
|
|
150703
150729
|
useRequire: useRequire,
|
|
150704
150730
|
addAsTypeOnly: addAsTypeOnly,
|
|
150705
150731
|
exportInfo: exportInfo,
|
|
150732
|
+
isReExport: i > 0,
|
|
150706
150733
|
};
|
|
150707
150734
|
});
|
|
150708
150735
|
});
|
|
@@ -150740,12 +150767,13 @@ var ts;
|
|
|
150740
150767
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150741
150768
|
}
|
|
150742
150769
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150743
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150770
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150744
150771
|
}
|
|
150745
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150746
|
-
|
|
150772
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150773
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150774
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150747
150775
|
}
|
|
150748
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150776
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150749
150777
|
if (!ts.some(fixes))
|
|
150750
150778
|
return;
|
|
150751
150779
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150754,22 +150782,37 @@ var ts;
|
|
|
150754
150782
|
}
|
|
150755
150783
|
return fixes.reduce(function (best, fix) {
|
|
150756
150784
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150757
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150785
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150758
150786
|
});
|
|
150759
150787
|
}
|
|
150760
150788
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150761
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150789
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150762
150790
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150763
150791
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150764
150792
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150765
|
-
|| ts.compareBooleans(
|
|
150793
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150766
150794
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150767
150795
|
}
|
|
150768
150796
|
return 0 /* EqualTo */;
|
|
150769
150797
|
}
|
|
150770
|
-
|
|
150771
|
-
|
|
150772
|
-
|
|
150798
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150799
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150800
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150801
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150802
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150803
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150804
|
+
var _a;
|
|
150805
|
+
if (fix.isReExport &&
|
|
150806
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150807
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150808
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150809
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150810
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150811
|
+
}
|
|
150812
|
+
return false;
|
|
150813
|
+
}
|
|
150814
|
+
function isIndexFileName(fileName) {
|
|
150815
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150773
150816
|
}
|
|
150774
150817
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150775
150818
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150787,9 +150830,9 @@ var ts;
|
|
|
150787
150830
|
return undefined;
|
|
150788
150831
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150789
150832
|
var symbolName = umdSymbol.name;
|
|
150790
|
-
var
|
|
150833
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150791
150834
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150792
|
-
var fixes = getImportFixes(
|
|
150835
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150793
150836
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150794
150837
|
}
|
|
150795
150838
|
function getUmdSymbol(token, checker) {
|
|
@@ -150856,8 +150899,8 @@ var ts;
|
|
|
150856
150899
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150857
150900
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150858
150901
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150859
|
-
var
|
|
150860
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150902
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150903
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150861
150904
|
var _ = _a[0], exportInfos = _a[1];
|
|
150862
150905
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150863
150906
|
}));
|
|
@@ -152958,6 +153001,95 @@ var ts;
|
|
|
152958
153001
|
})(ts || (ts = {}));
|
|
152959
153002
|
/* @internal */
|
|
152960
153003
|
var ts;
|
|
153004
|
+
(function (ts) {
|
|
153005
|
+
var codefix;
|
|
153006
|
+
(function (codefix) {
|
|
153007
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
153008
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
153009
|
+
var errorCodes = [
|
|
153010
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
153011
|
+
];
|
|
153012
|
+
codefix.registerCodeFix({
|
|
153013
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
153014
|
+
errorCodes: errorCodes,
|
|
153015
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
153016
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
153017
|
+
var actions = [];
|
|
153018
|
+
var info = getInfo(sourceFile, span.start);
|
|
153019
|
+
if (info) {
|
|
153020
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
153021
|
+
ts.append(actions, getRenameAction(context, info));
|
|
153022
|
+
return actions;
|
|
153023
|
+
}
|
|
153024
|
+
return undefined;
|
|
153025
|
+
},
|
|
153026
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
153027
|
+
var tagsToSignature = new ts.Map();
|
|
153028
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
153029
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
153030
|
+
var file = _a.file, start = _a.start;
|
|
153031
|
+
var info = getInfo(file, start);
|
|
153032
|
+
if (info) {
|
|
153033
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
153034
|
+
}
|
|
153035
|
+
});
|
|
153036
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
153037
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
153038
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
153039
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
153040
|
+
}
|
|
153041
|
+
});
|
|
153042
|
+
}));
|
|
153043
|
+
}
|
|
153044
|
+
});
|
|
153045
|
+
function getDeleteAction(context, _a) {
|
|
153046
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
153047
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
153048
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
153049
|
+
});
|
|
153050
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
153051
|
+
}
|
|
153052
|
+
function getRenameAction(context, _a) {
|
|
153053
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
153054
|
+
if (!ts.length(signature.parameters))
|
|
153055
|
+
return undefined;
|
|
153056
|
+
var sourceFile = context.sourceFile;
|
|
153057
|
+
var tags = ts.getJSDocTags(signature);
|
|
153058
|
+
var names = new ts.Set();
|
|
153059
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
153060
|
+
var tag = tags_2[_i];
|
|
153061
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
153062
|
+
names.add(tag.name.escapedText);
|
|
153063
|
+
}
|
|
153064
|
+
}
|
|
153065
|
+
// @todo - match to all available names instead to the first parameter name
|
|
153066
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
153067
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
153068
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
153069
|
+
});
|
|
153070
|
+
if (parameterName === undefined)
|
|
153071
|
+
return undefined;
|
|
153072
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
153073
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
153074
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
153075
|
+
});
|
|
153076
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
153077
|
+
}
|
|
153078
|
+
function getInfo(sourceFile, pos) {
|
|
153079
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
153080
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
153081
|
+
var jsDocParameterTag = token.parent;
|
|
153082
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
153083
|
+
if (signature) {
|
|
153084
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
153085
|
+
}
|
|
153086
|
+
}
|
|
153087
|
+
return undefined;
|
|
153088
|
+
}
|
|
153089
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
153090
|
+
})(ts || (ts = {}));
|
|
153091
|
+
/* @internal */
|
|
153092
|
+
var ts;
|
|
152961
153093
|
(function (ts) {
|
|
152962
153094
|
var codefix;
|
|
152963
153095
|
(function (codefix) {
|