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

InstructorMarius Schulz

Share this video with your friends

Send Tweet

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 array literal expression, the resulting type will be a readonly tuple type and no literal types within the expression will be widened.