Created
September 24, 2021 07:37
-
-
Save TobidieTopfpflanze/f778ec12ab14d69198211f0e6370b4fc to your computer and use it in GitHub Desktop.
TypeScript: depend type on given literal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type SelectorType = "option1" | "option2"; | |
export type SelectType<S extends SelectorType> = S extends "option1" | |
? Type1 | |
: S extends "option2" | |
? Type2 | |
: never; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment