Skip to content

Commit 465042e

Browse files
committed
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.
1 parent b8b1201 commit 465042e

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

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

0 commit comments

Comments
 (0)