Skip to content

Instantly share code, notes, and snippets.

@TobidieTopfpflanze
Created September 24, 2021 07:37
Show Gist options
  • Save TobidieTopfpflanze/f778ec12ab14d69198211f0e6370b4fc to your computer and use it in GitHub Desktop.
Save TobidieTopfpflanze/f778ec12ab14d69198211f0e6370b4fc to your computer and use it in GitHub Desktop.
TypeScript: depend type on given literal
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