Syntax

TypeScript Optional Property Syntax

In TypeScript, optional property: marks an object property as optional — interface User { email?: string; }

Quick Answer

Syntax
interface User { email?: string; }
TypeScriptSyntax

Optional Property

Code example
interface User { email?: string; }

Marks an object property as optional.

Learn More

How to optional property in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Optional Property Syntax

Use interface User { email?: string; }.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for optional property?

Use this pattern: interface User { email?: string; }

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify