Course lesson

Prevent Type Widening of Object Literals with TypeScript's const Assertions

A const assertion is a special type assertion that uses the const keyword instead of a specific type name. When using a const assertion on an object literal expression, all properties will become readonly properties and no literal types within the expression...

Duration
2 min
Access
Pro
Transcript
Available

A const assertion is a special type assertion that uses the const keyword instead of a specific type name. When using a const assertion on an object literal expression, all properties will become readonly properties and no literal types within the expression will be widened.

Additional Reading