Prop types don't match runtime types
Version
3.0.0
Reproduction link
https://codepen.io/kaelwd/pen/oNLgNGe?editors=1010
Steps to reproduce
Use boolean props in a typescript component
What is expected?
Boolean props should have type boolean
, as their default default value is false
What is actually happening?
All non-required props without a default value are T | undefined
component.test-d.ts
uses required: true
to strip the undefined, but this is incorrect as boolean props aren't necessarily required. There are no checks for non-required boolean props.
Changing RequiredKeys
to
type RequiredKeys<T> = {
[K in keyof T]: T[K] extends { required: true } | { default: any } | BooleanConstructor | { type: BooleanConstructor } ? K : never
}[keyof T]
fixes it but seems wrong as they aren't actually required. default is in there already so whatever.
Yet another reproduction
Version 3.0.0-0
Reproduction link https://gist.github.com/wxk6b1203/66914efbb633897655f525af9e4f3140
What is expected? The default value specification at L 33 could be omitted.
What is actually happening?
If the default value at L 33 was deleted, the computed
below shows that the overload not match.
I'm also having a lot of problems with props in TypeScript.
Version 3.0.1
Reproduction link TS Playground - Examples at the bottom