TypeScript

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

Key Concepts

  • Unions: | meaning a value can be one of several types (including undefined or null)
  • Generics: provide variables to types. Or, a type that can be used with multiple other types

Recommendations

  • Prefer interface over type
  • Priority: mapped types over unions over enums
export const Animal = {
  CAT: "CAT",
  DOG: "DOG",
} as const;

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

FAQs

  • React children: ReactNode
  • Objects with arbitrary keys: index signatures - { [key: string]: string }
{
  "compilerOptions": {
    "strict": true,
  }
}

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

Includes noImplicitAny and strictNullChecks