TypeScript
Use "good" TypeScript practices:
assign a type when declaring variables (if type is not already correctly inferred)
β
const doc = {...} // no type; can have any fields/valuesβ
const doc: TDoc = {...} // type = TDoc ({ id: number, ... })
narrow-scoped types when possible [1]
β
type side = stringallows "left", "right", "askdjf", "jdklfjal", ...
β
type side = "left" | "right"allows "left" or "right" only
minimal-to-no
anyorunknowntypes [1]β
const item: any = {...}β
const item: unknown = {...}
Last updated