-
say, we have a context |
Beta Was this translation helpful? Give feedback.
Answered by
danielpza
May 19, 2021
Replies: 2 comments 3 replies
-
I may have one or two examples to point to, but could you first provide a more complete example of what you are trying to achieve and can't do? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Perhaps this is what you want https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types type ContextType<T extends Context<any>> = T extends Context<infer R> ? R : never;
type MyContext = Context<number>
const value: ContextType<MyContext> // number |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
zhaoyao91
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perhaps this is what you want https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types