TypeScript
/Intermediate
Required<T>
Definition
A built-in utility type that constructs a new type where all properties of the given Type `T` are set to required, removing any `?` modifiers.
Explain Like I'm New
The exact opposite of `Partial`. It looks at a form where everything is optional, and forcefully stamps 'REQUIRED' over every single field.
Real World Example
When a user provides an optional configuration object `ConfigOptions`, but inside your library's core logic, you merge it with defaults to guarantee every setting exists. Your internal functions will type the merged config as `Required<ConfigOptions>`.
Common Use Cases
- •Default prop merging
- •Strict internal function signatures
Interactive Example
Loading Code Playground...
Interview Questions
basic
- What is the opposite of `Partial`?
intermediate
- How does `Required` handle properties that were originally typed as `string | undefined`?