-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve behaviour of ...
inside JSDoc functions
#22809
Conversation
// from bcryptjs | ||
/** @param {function(...[*])} callback */ | ||
function g(callback) { | ||
>g : (callback: (...arg0: [any][]) => any) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the intention to have a single-element tuple type in an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it, given the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this came from some real (but quite confused) jsdoc in bcryptjs. I think the author's intent was any[][]
but they wrote ...[*]
src/compiler/checker.ts
Outdated
@@ -24542,6 +24549,11 @@ namespace ts { | |||
} | |||
} | |||
} | |||
if (isParameter(parent) && isJSDocFunctionType(parent.parent)) { | |||
if (last(parent.parent.parameters) === parent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this if
is necessary, just use an array type all the time, we will issue a diagnostic for a non-last parameter anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess you're right. I'm not sure adding | undefined
as the fallback case ever makes sense, actually.
...type
when it is the last parameter of a jsdocfunction()
type....type
is marked as a rest parameter....type
results intype[]
inside a jsdoc function type.Fixes #22508