Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 Pick PR #47959 (Only suggest @param codefixes in ...) into release-4.6 #47962

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/compiler/checker.ts
Expand Up @@ -38536,9 +38536,9 @@ namespace ts {
const containsArguments = containsArgumentsReference(node);
if (containsArguments) {
const lastJSDocParam = lastOrUndefined(jsdocParameters);
if (lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
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));
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));
}
}
else {
Expand All @@ -38547,7 +38547,9 @@ namespace ts {
return;
}
if (isQualifiedName(name)) {
errorOrSuggestion(isJs, name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
if (isJs) {
error(name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
}
}
else {
errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name));
Expand Down
18 changes: 18 additions & 0 deletions tests/cases/fourslash/jsdocParam_suggestion1.ts
@@ -0,0 +1,18 @@
/// <reference path="fourslash.ts" />
// @Filename: a.ts
//// /**
//// * @param options - whatever
//// * @param options.zone - equally bad
//// */
//// declare function bad(options: any): void
////
//// /**
//// * @param {number} obtuse
//// */
//// function worse(): void {
//// arguments
//// }

goTo.file('a.ts')
verify.getSuggestionDiagnostics([]);