Skip to content

fix: React class component defaultProps types #7520

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

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

Conversation

bvandercar-vt
Copy link
Contributor

Fixes #6899

Checklist

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

Changes proposed in this pull request:

Setting defaultProps to a type of Partial<Props> makes all of that component's props optional, when the implementation may be different. So, this could lead to disastrous effects. TypeScript advises against this starting with TS v3.0:

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

As an example, see issue #6899

@bvandercar-vt bvandercar-vt force-pushed the bvandercar/react-class-component-defaultProps branch from 7f8b905 to dda9ac0 Compare July 31, 2025 14:47
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