How the type inference works
- Parse the JSON via
JSON.parse. - Walk the tree and produce a "shape" for each value — primitive, array, object or union.
- Merge sibling shapes (array elements, objects with the same key set) into a single canonical shape. Missing keys → optional. Different primitive types → union.
- Emit one
export interfaceper distinct object shape, plus a rootinterface Rootortype Rootdepending on the JSON root type.
This is deterministic — the same JSON input always produces the same TypeScript output, byte-for-byte.