# `Required<Type>`

> The `Required<Type>` utility type in TypeScript makes all properties of a type required.

## How do I make all properties required in TypeScript?

The utility type that constructs a type with all properties of `Type` set to required, removing the `?` modifier. It is the opposite of `Partial<Type>`.

- Topic: Utility Types
- Type: utility type

## Example

Wrong:

```ts
function withDefaults(o: Options) {
  return o as Required<Options>;
}
```

Right:

```ts
function withDefaults(o: Options): Required<Options> {
  return {
    retries: o.retries ?? 3,
    timeout: o.timeout ?? 5000,
  };
}
```

The cast only hides missing fields; building the object with `??` defaults makes every field really present.

## Common mistakes

- Casting a partial object to `Required<T>` and reading `undefined` at runtime.

## Key points

- `Required<T>` is shallow, nested optional properties stay optional.
- Values typed as `Required<T>` are filled with real defaults at runtime, not created by a cast.

## Interview questions

### How do I make only some properties required?

Combine helpers: `Omit<T, 'id'> & Required<Pick<T, 'id'>>` makes only `id` required.

### Does Required remove undefined from every property?

No. A property declared without `?` but typed `string | undefined` keeps `undefined`, because `Required` only removes the optional modifier.

## Related cards

- [`Partial<T>`](https://wonderium.dev/ts/partial.md)
- [Optional](https://wonderium.dev/ts/optional.md)
- [Mapped Types](https://wonderium.dev/ts/mapped-types.md)
- [`Readonly<T>`](https://wonderium.dev/ts/readonly.md)
- [`Pick<T, Keys>`](https://wonderium.dev/ts/pick.md)

---

- Level: [TypeScript](https://wonderium.dev/ts.md)
- HTML version: https://wonderium.dev/ts/required
- Last updated: 2026-11-25
