TypeScript · Types and shapes
Optional property
The property may be missing or undefined. Do not use it for values that are always present but sometimes empty.
Syntax
name?: stringExample
Example
type Profile = { name: string; bio?: string };
const profile: Profile = { name: "Ada" };More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.