Skip to content

Commit ec6ae0f

Browse files
TypeScript Botsandersn
TypeScript Bot
andauthored
Cherry-pick PR #47959 into release-4.6 (#47962)
Component commits: 465042e 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. 4056b38 Minimise test 4fb10f1 Merge branch 'main' into only-suggest-param-codefixes-in-ts 72499ac Merge branch 'main' into only-suggest-param-codefixes-in-ts Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent ded20c6 commit ec6ae0f

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/compiler/checker.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -38536,9 +38536,9 @@ namespace ts {
3853638536
const containsArguments = containsArgumentsReference(node);
3853738537
if (containsArguments) {
3853838538
const lastJSDocParam = lastOrUndefined(jsdocParameters);
38539-
if (lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
38539+
if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
3854038540
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
38541-
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));
38541+
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));
3854238542
}
3854338543
}
3854438544
else {
@@ -38547,7 +38547,9 @@ namespace ts {
3854738547
return;
3854838548
}
3854938549
if (isQualifiedName(name)) {
38550-
errorOrSuggestion(isJs, name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
38550+
if (isJs) {
38551+
error(name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
38552+
}
3855138553
}
3855238554
else {
3855338555
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,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)