Skip to content

@callback is only generic after @template tag #25736

Open
@ghost

Description

TypeScript Version: master

Search Terms:

Code

Our declaration:

export interface JSDocSignature extends JSDocType, Declaration {
    kind: SyntaxKind.JSDocSignature;
    typeParameters?: ReadonlyArray<JSDocTemplateTag>;
    ...
}

Attempt to use:

/**
 * @callback Cb
 * @template T
 * @param {T} p
 * @return {T}
 */

/** @type {Cb} */
const x = p => p;

Expected behavior:

typeParameters is set somewhere, and type Cb = <T>(p: T) => T (or type Cb<T> = (p: T) => T)

Actual behavior:

  1. typeParameters is not set.
  2. Cb says that it requires a generic argument, but when provided, there's an error on x: 'any => any' isn't assignable to 'Cb'.
  3. Requesting quickinfo on Cb/**/<number> causes an infinite recursion in getTypePredicateOfSignature.

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallycheckJsRelates to checking JavaScript using TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions