Skip to content

Docgen: Crash for untyped @param descriptions on default re-export #37766

@dmsnell

Description

@dmsnell

Description

In context-provider modules we typically re-export the Provider as the default export, wrapping a custom context.

export const Context = createContext( false );

const { Consumer, Provider } = Context;

/**
 * @param {boolean} props.value Whether to turn the thing on.
 * @returns {WPComponent} Provider component
 */
export default Provider;

For TypeScript modules we don't need or want the type annotations as those are enforced and maintained by the compiler.

/**
 * @param props.value Whether to turn the thing on.
 * @returns Provider component
 */
export default Provider;

When generating the docs though it fails with a couple of different types of errors.

TypeError: Cannot read properties of undefined (reading 'name')
TypeError: Cannot read properties of undefined (reading '0')

These come from trying to get the first parameter and printing the name of the function in the error log.

Step-by-step reproduction instructions

See Description

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Labels

Needs TestingNeeds further testing to be confirmed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions