Skip to content

Commit 5150682

Browse files
authored
Only suggest @param codefixes in TS (microsoft#47959)
* Only issue @param suggestions with codefixes in TS Previously, there were 2 JS errors that were issued as suggestions in TS files. But there was no codefix for these errors, and the errors were incorrect in TS. This PR only issues the JS-specific errors on JS files. * Minimise test
1 parent acfdd1b commit 5150682

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Diff for: src/compiler/checker.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -38650,9 +38650,9 @@ namespace ts {
3865038650
const containsArguments = containsArgumentsReference(node);
3865138651
if (containsArguments) {
3865238652
const lastJSDocParam = lastOrUndefined(jsdocParameters);
38653-
if (lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
38653+
if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
3865438654
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
38655-
errorOrSuggestion(isJs, lastJSDocParam.name, 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, idText(lastJSDocParam.name));
38655+
error(lastJSDocParam.name, 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, idText(lastJSDocParam.name));
3865638656
}
3865738657
}
3865838658
else {
@@ -38661,7 +38661,9 @@ namespace ts {
3866138661
return;
3866238662
}
3866338663
if (isQualifiedName(name)) {
38664-
errorOrSuggestion(isJs, name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
38664+
if (isJs) {
38665+
error(name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
38666+
}
3866538667
}
3866638668
else {
3866738669
errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name));

Diff for: tests/cases/fourslash/jsdocParam_suggestion1.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="fourslash.ts" />
2+
// @Filename: a.ts
3+
//// /**
4+
//// * @param options - whatever
5+
//// * @param options.zone - equally bad
6+
//// */
7+
//// declare function bad(options: any): void
8+
////
9+
//// /**
10+
//// * @param {number} obtuse
11+
//// */
12+
//// function worse(): void {
13+
//// arguments
14+
//// }
15+
16+
goTo.file('a.ts')
17+
verify.getSuggestionDiagnostics([]);
18+

0 commit comments

Comments
 (0)