Skip to content

Instantly share code, notes, and snippets.

@rekomat
Last active November 12, 2023 10:57
Show Gist options
  • Save rekomat/0e5f2b64390f4ef0c6499152a155cbbd to your computer and use it in GitHub Desktop.
Save rekomat/0e5f2b64390f4ef0c6499152a155cbbd to your computer and use it in GitHub Desktop.

Typescript Cheatsheet

Enums

Using objects instead of enums

export enum Position {
  Top = 'top',
  Bottom = 'bottom',
}
const Position = {
  Top: 'top',
  Bottom: 'bottom',
} as const;
type TPosition = typeof Position[keyof typeof Position];

Source

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