Makes specified keys K required in each member of a union T.
K
T
This distributes over unions, ensuring each union member is processed individually. Only keys that exist in each member are affected.
The target type (can be a union)
Keys to make required (defaults to all union keys)
type Result = MakeRequired<{ a?: string; b?: number }>;// ^?// { a: string; b: number } Copy
type Result = MakeRequired<{ a?: string; b?: number }>;// ^?// { a: string; b: number }
type Result = MakeRequired<{ a?: string } | { b?: number }>;// ^?// { a: string } | { b: number } Copy
type Result = MakeRequired<{ a?: string } | { b?: number }>;// ^?// { a: string } | { b: number }
type Result = MakeRequired<{ a?: string } | { b?: number }, "a">;// ^?// { a: string } | { b?: number } Copy
type Result = MakeRequired<{ a?: string } | { b?: number }, "a">;// ^?// { a: string } | { b?: number }
Makes specified keys
Krequired in each member of a unionT.This distributes over unions, ensuring each union member is processed individually. Only keys that exist in each member are affected.