mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Fix getTypeFromJSDocVariadicType in callback tag (#43562)
* Fix getTypeFromJSDocVariadicType in @callback Variadics have never worked there, I think. * add test + fix lint * remove outdated comment
This commit is contained in:
committed by
GitHub
parent
c1923e9cd1
commit
2bb54dc11a
@@ -38433,7 +38433,8 @@ namespace ts {
|
||||
if (isJSDocTypeExpression(node.parent) && isJSDocParameterTag(paramTag)) {
|
||||
// Else we will add a diagnostic, see `checkJSDocVariadicType`.
|
||||
const host = getHostSignatureFromJSDoc(paramTag);
|
||||
if (host) {
|
||||
const isCallbackTag = isJSDocCallbackTag(paramTag.parent.parent);
|
||||
if (host || isCallbackTag) {
|
||||
/*
|
||||
Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
|
||||
So in the following situation we will not create an array type:
|
||||
@@ -38441,7 +38442,9 @@ namespace ts {
|
||||
function f(a) {}
|
||||
Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type.
|
||||
*/
|
||||
const lastParamDeclaration = lastOrUndefined(host.parameters);
|
||||
const lastParamDeclaration = isCallbackTag
|
||||
? lastOrUndefined((paramTag.parent.parent as unknown as JSDocCallbackTag).typeExpression.parameters)
|
||||
: lastOrUndefined(host!.parameters);
|
||||
const symbol = getParameterSymbolFromJSDoc(paramTag);
|
||||
if (!lastParamDeclaration ||
|
||||
symbol && lastParamDeclaration.symbol === symbol && isRestParameter(lastParamDeclaration)) {
|
||||
|
||||
Reference in New Issue
Block a user