Skip to content

Instantly share code, notes, and snippets.

@y-takagi
Last active April 16, 2021 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y-takagi/8e9f7657522f2add53f898ec4b586c2c to your computer and use it in GitHub Desktop.
Save y-takagi/8e9f7657522f2add53f898ec4b586c2c to your computer and use it in GitHub Desktop.
Typescript Cookbook

Typescript Cookbook

Yet another enum

export const signal = ['red', 'green', 'blue'] as const;
export type Signal = typeof signal[number];

export const color = { red: 0, green: 1, blue: 2 } as const;
export type Color = typeof color[keyof typeof color];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment