Optional fields in TS Interface

TS optional fields

Sat Jun 19 2021

Optional member in a TypeScript interface is the one that is not a mandatory field. We can skip those field while assigning values, everything else is mandatory.

To create a optional member we can use ? in front of the member and before the type.

..
firstName: string;
lastName?: string;
..

Comments