Object shapes
Required
Removes `?` from every property, one level deep.
What it is
The mirror of `Partial`, written with `-?`. The minus sign is the whole mechanism: modifiers in a mapped type can be added with `+?` and removed with `-?`, and `Required` is the standard library using the second. It also strips `undefined` from the property type, which is a separate effect people rarely expect.
Examples
Required<{ a?: string; b?: number }>→{ a: string; b: number; }Required<{ a?: string | undefined }>→{ a: string; }`undefined` goes too — `-?` removes it from the type, not only the `?` from the key.
Required<{ a: string }>→{ a: string; }
Each resolved type above was printed by TypeScript 5.9.3, not written by hand.
What it does not do
- It does not make a property non-null. `Required<{ a?: string | null }>` still has `null` in it — only `undefined` is removed.
- It is not deep either. The symmetry with `Partial` holds all the way to the limitation.
Takeaway
`-?` does two things at once: it removes the optionality and it removes `undefined`. Most confusion about `Required` is the second one arriving unannounced.