[Typescript] Make your optional fields required in TypeScript
In this post, let's see how to make all the optional fields to be required with the help of Required
.
type User = { name: string; age?: number; gender?: string; }; const user: Required<User> = { name: "John Doe", age: 23, gender: "male" }; console.log(user);