TypeScript Syntax and Type Operators
? — optional object property
The question mark permits an object property to be absent. A read can yield undefined under strict null checking, so consumers must handle that possibility. With exactOptionalPropertyTypes enabled, explicitly writing undefined requires the declared property type to permit it; omission and undefined assignment are distinct. The modifier does not create a property at runtime. Example output: "default". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.
Formal Syntax & Structure
typescript syntaxtypescript
type Settings = { label?: string };Working Example
Example Snippettypescript
type Settings = { label?: string };function label(settings: Settings) { return settings.label ?? "default"; }console.log(label({}));