Type inference
- number / string / boolean → primitive types
- null →
null - Object → nested interface or type
- Homogeneous array →
T[] - Heterogeneous array → union
(A | B)[] - Empty array →
unknown[]
Tips
- Choose
interfacewhen you need declaration merging or extension - Choose
typealias for unions, mapped or conditional types readonlyfor immutable API responses- Mark fields optional (
?) when the API may omit them - Pipe into
npx prettierif you need stricter formatting