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

fix: React class component defaultProps types #6900

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from

Conversation

bvandercar-vt
Copy link
Contributor

@bvandercar-vt bvandercar-vt commented Jul 8, 2024

Fixes #6899

Checklist

  • [N/A] Includes tests
  • [N/A] Update documentation

Changes proposed in this pull request:

See issue in #6899

Setting defaultProps to a type of Partial<Props> makes all component props partial, which could lead to disastrous effects. TypeScript advises against this starting with TS v3.0:

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#explicit-types-on-defaultprops

If an explicit type annotation is added, e.g. static defaultProps: Partial<Props>; the compiler will not be able to identify which properties have defaults

Use static defaultProps: Pick<Props, "name">; as an explicit type annotation instead, or do not add a type annotation as done in the example above.

@bvandercar-vt bvandercar-vt changed the title fix: react class component defaultProps types fix: React class component defaultProps types Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TabsProps has "id" as required, but is not required in component usage
1 participant