as const keeps literal types from widening
Answer: Use as const to convert an entire object to type literals. Properties are assigned the literal type, not a more general version like string or number.
What as const changes
If you initialize a variable with an object, TypeScript assumes those properties might change later. An as const assertion on the object turns its values into type literals.
Const assertions also stop literal widening in general, give object literals readonly properties, and turn array literals into readonly tuples.
Limits
A const assertion applies only to a string, number, boolean, array, or object literal. Const contexts don't immediately convert an expression to be fully immutable.
See also
Claims
- id: C1 claim: as const converts the entire object to type literals. source: S1 evidence: "as const to convert the entire object to be type literals"
- id: C2 claim: The suffix keeps properties from widening to string or number. source: S1 evidence: "literal type instead of a more general version"
- id: C3 claim: Const assertions stop literal types from being widened. source: S2 evidence: "no literal types in that expression should be widened"
- id: C4 claim: Object literals in a const assertion get readonly properties. source: S2 evidence: "object literals get
readonlyproperties"
Sources
- [S1] Everyday Types (Literal Inference). Microsoft (TypeScript Handbook). https://www.typescriptlang.org/docs/handbook/2/everyday-types.html . License: CC-BY-4.0. Accessed 2026-11-17.
- [S2] TypeScript 3.4 release notes (const assertions). microsoft/TypeScript-Website (GitHub). https://github.com/microsoft/TypeScript-Website/blob/v2/packages/documentation/copy/en/release-notes/TypeScript%203.4.md . License: CC-BY-4.0. Accessed 2026-11-17.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Microsoft (TypeScript Handbook), Everyday Types (Literal Inference), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); microsoft/TypeScript-Website (GitHub), TypeScript 3.4 release notes (const assertions), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft (TypeScript Handbook), Everyday Types (Literal Inference), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); microsoft/TypeScript-Website (GitHub), TypeScript 3.4 release notes (const assertions), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE).
Cite this
iinventedlight. 2026. "as const keeps literal types from widening." iinventedlight Library, iil:note:zmb6mzmg, version of 2026-11-17. https://iinventedlight.com/library/notes/typescript-const-assertions/. License: CC-BY-4.0.
@misc{iil_note_zmb6mzmg,
author = {{iinventedlight}},
title = {{as const keeps literal types from widening}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/typescript-const-assertions/},
note = {Permanent ID iil:note:zmb6mzmg. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/typescript-const-assertions.md.