Skip to content
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

[Bug]: TypeScript: TableToolbarMenuProps.iconDescription is required #13778

Closed
2 tasks done
lewandom opened this issue May 10, 2023 · 2 comments · Fixed by #13804
Closed
2 tasks done

[Bug]: TypeScript: TableToolbarMenuProps.iconDescription is required #13778

lewandom opened this issue May 10, 2023 · 2 comments · Fixed by #13804

Comments

@lewandom
Copy link
Contributor

Package

@carbon/react

Browser

No response

Package version

1.28.0

React version

No response

Description

When using TableToolbarMenu component in a TypeScript project, the iconDescription prop must be provided:

Type error: Property 'iconDescription' is missing in type '{ children: Element[]; }' but required in type 'TableToolbarMenuProps'.

While it is really a required prop in PropTypes, it does have a default value in defaultProps. Therefore, to keep same usage of this component between JS and TS, it'd be better to make it optional in TableToolbarMenuProps and set a default value when destructuring functional component props.

Raising this as a bug despite this probably would be covered by #13424, because it actually errors out in real life usage.

Reproduction/example

See below

Steps to reproduce

Simply create use the component in a TypeScript project without any props:

<TableToolbarMenu>
   ...
</TableToolbarMenu>

Suggested Severity

None

Application/PAL

No response

Code of Conduct

@lewandom
Copy link
Contributor Author

A similar problem exists for TableHeader.scope property.

@tay1orjones
Copy link
Member

@lewandom thanks for catching this, I agree. Anywhere a prop is marked required but has a default like this should not be required and the default provided through default function params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants