-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Add utility types, ComponentProps and ComponentListeners #2094
Comments
Should be fairly straightforward to provide - open to PR. |
- ComponentProps: Extract props type of component - ComponentListeners: Extract event handlers type of component
@wonderful-panda I see you started working on this in your fork. Do you need any help to get this ready for a PR? |
@LinusBorg PR is already opened. |
Oh, I missed that. Will link issue and PR for better tracking now. Thanks! |
pikax helped me out on Discord with this snippet: type Props<T> = T extends new () => { $props: infer P } ? P : never I added a comment to your PR, I think it's a great addition but it should definitely be documented since these utility classes are meant for public consumption. |
What problem does this feature solve?
Make it easy to write component in TypeScript.
What does the proposed API look like?
ComponentProps
Extract props type from component. Equivalent to React's ComponentProps.
ComponentListeners
Extract event handlers type from component.
Usecases
Writing wrapper component
Writing event handlers safely
Improve JSX typing (by template literal types of TS4.1)
The text was updated successfully, but these errors were encountered: