TypeScript enums
Short answer
Enums define a set of named constants. TypeScript supports numeric and string enums; they exist as real objects at runtime. Union and literal types are often a lighter alternative. [S1][S2]
Points
- Members after an initializer auto-increment for numeric enums. [S1]
- Prefer string enums when you care about readable runtime values. [S1]
- Union types combine existing types; each piece is a union member. [S2]
Claims
- id: C1 claim: Enums define a set of named constants. source: S1 evidence: "Enums allow a developer to define a set of named constants"
- id: C2 claim: TypeScript has numeric and string enums. source: S1 evidence: "TypeScript provides both numeric and string-based enums"
- id: C3 claim: Enums exist as real runtime objects. source: S1 evidence: "real objects that exist at runtime"
- id: C4 claim: Union types combine existing types into members. source: S2 evidence: "each of these types as the union’s members"
Sources
- [S1] TypeScript: Handbook - Enums. Microsoft (TypeScript Handbook). https://www.typescriptlang.org/docs/handbook/enums.html . License: CC BY 4.0 (microsoft/TypeScript-Website). Accessed 2026-11-05.
- [S2] Everyday Types. TypeScript (Microsoft). https://www.typescriptlang.org/docs/handbook/2/everyday-types.html . License: CC BY 4.0 (microsoft/TypeScript-Website). Accessed 2026-11-05.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
Source notice: TypeScript Handbook / Website docs © Microsoft. Licensed under Creative Commons Attribution 4.0 International (https://github.com/microsoft/TypeScript-Website/blob/v2/LICENSE).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft (TypeScript Handbook), TypeScript: Handbook - Enums, CC BY 4.0 (microsoft/TypeScript-Website); TypeScript (Microsoft), Everyday Types, CC BY 4.0 (microsoft/TypeScript-Website).
Cite this
iinventedlight. 2026. "TypeScript enums: named constants, numeric or string." iinventedlight Library, iil:note:gqfg9rnh, version of 2026-11-04. https://iinventedlight.com/library/notes/typescript-enums/. License: CC-BY-4.0.
@misc{iil_note_gqfg9rnh,
author = {{iinventedlight}},
title = {{TypeScript enums: named constants, numeric or string}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/typescript-enums/},
note = {Permanent ID iil:note:gqfg9rnh. 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-enums.md.