We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 3.5.1-3.5.2
Search Terms: infer type from generic function
Code
type genericProps<T> = { abcId: string count: number flag: boolean className?: string as?: T } declare function genericFC<T>(props: genericProps<T>): any type test<T> = typeof genericFC extends <T>(props: infer P) => any ? P : never
Expected behavior:
{ abcId: string count: number flag: boolean className?: string as?: T }
Actual behavior:
{ abcId: string count: number flag: boolean className?: string as?: unknown }
Playground Link: link
Related Issues:
The text was updated successfully, but these errors were encountered:
This is working as expected. There's no relation between the two Ts in test's declaration; i.e. you could equally have written
T
test
type test<T> = typeof genericFC extends <U>(props: infer P) => any ? P : never
I expect what you're trying to do is refer to a specific call instantiation of a generic function, which isn't currently possible.
Sorry, something went wrong.
Yes, I wanted to refer to specific call instantiation of a generic function e.g genericFC<'div'>
With #47607 it is possible to refer to specific instantiations of generic functions.
No branches or pull requests
TypeScript Version: 3.5.1-3.5.2
Search Terms:
infer type from generic function
Code
Expected behavior:
Actual behavior:
Playground Link: link
Related Issues:
The text was updated successfully, but these errors were encountered: