Paths & optionality
A path reads a value out of the input: user.address.city. Because the input is typed, every segment is validated at compile time — a typo is a compile error, not a silent undefined.
| Operator | Effect |
|---|---|
. | read a value out of the input |
?. | required for optional or nullable segments |
?? | supply a fallback for null/undefined, strips optionality |
. : read a value out of the input
Every segment is validated — a typo is TF2002 with a "did you mean" suggestion, not a silent undefined.
typeflow
city: user.address.city?. : required for optional or nullable segments
If a segment may be missing (contact?:) or nullable, plain . access is refused (TF2003). Without a default, a possibly-undefined value becomes an optional field of the output type — the field is simply absent from the output JSON when its value is undefined.
typeflow
email: user.contact?.email?? : supply a fallback for null/undefined, strips optionality
The compiler also flags the opposite mistake: using ?? on a value that is never nullish is warning TF2013 — dead code.
typeflow
email: user.contact?.email ?? "unknown"Playground
{ "name": "Ada", "email": "unknown" }
inferred type
{ name: string; email: string }Next: Arithmetic & strings.