TypeScript Syntax and Type Operators

! — definite assignment assertion

A definite assignment assertion on a declaration tells the checker to accept a binding or field even without ordinary initialization evidence. It is useful when initialization is guaranteed by an external mechanism, but it does not assign a runtime value. In an ES2022 class, an uninitialized field can still contain undefined. This declaration-site assertion is distinct from postfix ! on a value expression. Example output: "undefined". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.

Formal Syntax & Structure

typescript syntaxtypescript
class Cache { value!: string; }

Working Example

Example Snippettypescript
class Cache { value!: string; }const cache = new Cache();console.log(typeof cache.value);
TypeScript Reference