How JSON maps to TypeScript types
JSON has only six kinds of value, and each maps to a TypeScript type. Strings become string, numbers become number, true and false become boolean, null stays null, arrays become T[] and objects become interfaces. TypeScript has no separate integer type, so 42 and 349.5 are both number.
JSON has no date type. Dates arrive as strings such as 2026-10-10T09:30:00Z and are typed as string; convert them to Date objects deliberately when you parse a response. Large integers are another trap: JSON.parse turns every number into a JavaScript double, which is exact only up to 2⁵³ − 1 (9,007,199,254,740,991). 64-bit IDs beyond that are silently rounded, so APIs should send them as strings and your types should say string.
Optional and nullable mean different things. note?: string says the key may be absent; note: string | null says the key is always present but may be null. JSON cannot contain undefined at all, because JSON.stringify drops such keys, so an API that omits empty fields and one that sends null need different types. With the exactOptionalPropertyTypes compiler option, TypeScript also tells a missing key apart from one explicitly set to undefined.