blueprint
blueprint copied to clipboard
fix: React class component defaultProps types
Fixes #6899
Checklist
- [N/A] Includes tests
- [N/A] Update documentation
Changes proposed in this pull request:
See issue in https://github.com/palantir/blueprint/issues/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.