The original object type.
The keys within T that should be made required.
type Config = {
host?: string;
port?: number;
secure: boolean;
};
type Result = MakeRequired<Config, 'host' | 'port'>;
// {
// host: string;
// port: number;
// secure: boolean;
// }
type User = {
id?: string;
name: string;
email?: string;
};
type Result = MakeRequired<User, 'id'>;
// {
// id: string;
// name: string;
// email?: string;
// }
Constructs a new type from
Twhere the specified keysKbecome required, while all other keys preserve their original modifiers.This version correctly handles keys that were originally optional by using
Required<Pick<...>>, which removes the optional modifier in the same style as TypeScript's built-inRequired<T>.