DEBUGGING PLAYBOOK · REVIEWED 2026-10-08
A field exists in only some records
Inferring a type from the first record alone can make every field incorrectly required. This sample shows the difference between absence and null.
Sample input
[{"id":1,"name":"Ada"},{"id":2}]Steps and checks
- Load both records and generate TypeScript.
- Check that id is number and name has the optional marker ?. The second record does not contain name.
- Add "name":null to the second record and regenerate. name is required with a string | null union, since both records now contain it.
Reference result
export type Root = Array<{
"id": number;
"name"?: string;
}>;
Avoid a misleading conclusion
Optional means absent; null is an explicit value. Empty arrays provide no evidence about their future items and infer unknown. A sample cannot describe every possible API response.
What to do next
Review the generated type against the API contract and add missing cases before use. Generated TypeScript does not validate incoming data at runtime.
Related case and technical reference · Report an error or missing edge case