A missing key and an observed null
Sample 1
{
"id": 101,
"email": "ada@example.test"
}Sample 2
{
"id": 102,
"email": null,
"phone": "555-0100"
}Expected TypeScript draft
export interface ApiUser {
id: number;
email: string | null;
phone?: string;
}Initial options: ApiUser; optional fields on; unknown[] fallback.
What to check: email is a union of string and null; phone is optional. Turn optional inference off to make phone required, which rejects Sample 1 as a complete ApiUser.
Absent keys and null values mean different things; neither proves the full contract.