TypeScript Concepts
Literal widening — preserving or broadening values
A mutable binding initialized with a literal often receives a broader type, allowing later assignments of the same primitive kind. A const binding can retain literal information, but properties of an ordinary const object remain mutable and often widen. Use explicit literal annotations or const assertions where exact literal types matter. Observed output: 'draft ready'. Local example verified with TypeScript 5.8.3, strict checking, ES2022/CommonJS and Node.js 22.16.0; declarations enabled.
Formal Syntax & Structure
typescript syntaxtypescript
let state = "ready"; const fixed = "ready";Working Example
Example Snippettypescript
let state = "ready";state = "draft";const config = { mode: "ready" } as const;const exact: "ready" = config.mode;console.log(state, exact);