Skip to content

@typedef doesn't seem to recognize default exports #35552

Closed
@matthew-dean

Description

@matthew-dean

Search Terms:
JSDoc default named exports @typedef

Code
Given the following files:

/// file1.js
function foo() { return true; }
export { foo };

/// file2.js
/**
 * @typedef { ReturnType<import('./file1').foo> } Foo
 */

TypeScript / VSCode will correctly identify the type.

However, if it's a default export like:

/// file1.js
function foo() { return true; }
export default foo;

... then there seems to be no way for TS to recognize the type via @typedef. Neither of the following will work:

/// file2.js
/**
 * @typedef { ReturnType<import('./file1')> } Foo
 */
/**
 * @typedef { ReturnType<import('./file1').default> } Foo
 */

Related Issues:
Possibly Related? #33136

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions