Sometimes, we want to make a single property optional in TypeScript.
In this article, we’ll look at how to make a single property optional in TypeScript.
How to make a single property optional in TypeScript?
To make a single property optional in TypeScript, we can use the Optional type.
For instance, we write
type MakePersonInput = Optional<Person, "nickname">;
to create the MakePersonInput type that makes the nickname property in the Person interface optional.
Conclusion
To make a single property optional in TypeScript, we can use the Optional type.
