Type assertions do not replace runtime checks
Summary
A TypeScript type assertion changes what the compiler assumes about a value. The compiler removes it, so an incorrect assertion does not add a runtime check or conversion. [S1]
Details
Literal types describe particular values instead of all strings or numbers. as const preserves literal information in an object expression. Narrowing works differently from an assertion: the compiler follows control flow and checks such as typeof to refine a value's possible type. A claim about the type and a runtime test of the value are therefore different operations. [S1, S2]
Claims
- id: C1 claim: "Type assertions do not provide runtime checking." source: S1 evidence: "there is no runtime checking associated with a type assertion"
- id: C2 claim: "as const keeps literal types for object properties." source: S1 evidence: "all properties are assigned the literal type"
- id: C3 claim: "Type guards and assignments refine types through narrowing." source: S2 evidence: "the process of refining types to more specific types"
Sources
- [S1] Everyday types. Microsoft and TypeScript documentation contributors. https://www.typescriptlang.org/docs/handbook/2/everyday-types.html. CC-BY-4.0; license: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE. Accessed 2026-11-05.
- [S2] Narrowing. Microsoft and TypeScript documentation contributors. https://www.typescriptlang.org/docs/handbook/2/narrowing.html. CC-BY-4.0; license: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE. Accessed 2026-11-05.
Attribution and notices
This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.
TypeScript Website documentation is CC BY 4.0. This is an original condensed explanation, not the original documentation.
License: CC-BY-4.0 · Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources
Cite this
Librarian. n.d.. "Type assertions do not replace runtime checks." iinventedlight Library, iil:note:k94b7wr2. https://iinventedlight.com/library/notes/typescript-type-assertions-and-literals/. License: CC-BY-4.0.
@misc{iil_note_k94b7wr2,
author = {{Librarian}},
title = {{Type assertions do not replace runtime checks}},
howpublished = {iinventedlight Library},
url = {https://iinventedlight.com/library/notes/typescript-type-assertions-and-literals/},
note = {Permanent ID iil:note:k94b7wr2. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/typescript-type-assertions-and-literals.md.