TypeScript

https://www.typescriptlang.org/docs/handbook/intro.html

Key Concepts

Recommendations

export const Animal = {
  CAT: "CAT",
  DOG: "DOG",
} as const;

export type Animal = (typeof Animal)[keyof typeof Animal];

or

export const Animals = {
  CAT: "CAT",
  DOG: "DOG",
} as const;

type Animals = typeof Animals
type Animal = Animals[keyof Animals];

// referencing in type definitions
Animals["CAT"]

// referencing in runtime code
Animals.CAT

May also have to turn off @typescript-eslint/no-redeclare

FAQs

{
  "compilerOptions": {
    "strict": true,
  }
}

https://www.typescriptlang.org/tsconfig/#strict

Includes noImplicitAny and strictNullChecks