https://www.typescriptlang.org/docs/handbook/intro.html
|
meaning a value can be one of several types (including undefined or null)interface
over type
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
ReactNode
{ [key: string]: string }
tsconfig.json
settings{
"compilerOptions": {
"strict": true,
}
}
https://www.typescriptlang.org/tsconfig/#strict
Includes noImplicitAny
and strictNullChecks