-
Notifications
You must be signed in to change notification settings - Fork 9
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
Prop types are not inferred if component is returned indirectly. #68
Comments
As far as I know you can't pass props into variables in TypeScript, so to me this seems like a "gotcha!" that could be mentioned in the documentation perhaps? |
Currently, this is how you have to do it. I'm not happy with this, but we couldn't find a way make TypeScript infer the types if the generic was specified on only one of the two types. We discussed alternate component syntaxes that got around this, but they all came with other tradeoffs. We'd gladly accept a PR that fixes this 🙂 I'm indifferent two which of the two types would get the annotation, and which would be inferred.
Yep, the type is passed directly in: export type ForgoNewComponentCtor<Props extends {} = {}> = (
props: Props & ForgoComponentProps
) => Component<Props>; The
Good call, I'll update the migration section of the docs to reflect this. |
#68: Update the docs to clarify handling component generic types
When using TypeScript, prop types are not correctly inferred if the forgo component is not directly returned, see minimal example
The text was updated successfully, but these errors were encountered: