Skip to content

Instantly share code, notes, and snippets.

@obaranovskyi
Created January 15, 2022 04:45
Show Gist options
  • Save obaranovskyi/9d4ea2d9058fa0d5f1d9dab5e0b92d97 to your computer and use it in GitHub Desktop.
Save obaranovskyi/9d4ea2d9058fa0d5f1d9dab5e0b92d97 to your computer and use it in GitHub Desktop.
const roles = ['read', 'write', 'readAndWrite'] as const;
type Roles = typeof roles[number];
// equals to this
// type Roles = "read" | "write" | "readAndWrite"
// or even like this
type RolesInCapital = Capitalize<typeof roles[number]>;
// equals to this
// type RolesInCapital = "Read" | "Write" | "ReadAndWrite"
@kiss758
Copy link

kiss758 commented Jan 15, 2022

I don't ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment