Skip to content

Instantly share code, notes, and snippets.

@ampcpmgp
Created November 11, 2022 10:31
Show Gist options
  • Save ampcpmgp/c5cd1cfa1e093c03c66f64f42c952393 to your computer and use it in GitHub Desktop.
Save ampcpmgp/c5cd1cfa1e093c03c66f64f42c952393 to your computer and use it in GitHub Desktop.
type _Size = "x-small" | "small" | "medium" | "large" | "x-large";
type USToI<T extends string> = {
[P in T]: unknown;
};
export type Size<K extends keyof USToI<_Size>> = keyof Pick<USToI<_Size>, K>;
// Error!
// const size: Size<"small" | "large"> = "medium";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment