TypeScript: Handbook - Enums
typescriptlang.org · 2,430 words · saved by 1 readers
How TypeScript enums work
Enums are one of the few features TypeScript has which is not a type-level extension of JavaScript. Enums allow a developer to define a set of named constants. Using enums can make it easier to document intent, or create a set of distinct cases. TypeScript provides both numeric and string-based enums. Numeric enums We’ll first start off with numeric enums, which are probably more familiar if you’re coming from other languages. An enum can be defined using the enum keyword. ts enum Direction { Up = 1 , Down , Left , Right , } Try Above, we have a numeric enum where Up is initialized with 1 . Al
related reading
- Defining an Enum - The Rust Programming Languagedoc.rust-lang.org
- TypeScript: Documentation - The Basicstypescriptlang.org
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- Enums and Pattern Matching - The Rust Programming Languagedoc.rust-lang.org
- TypeScript: Documentation - Classestypescriptlang.org
- TypeScript: Documentation - TypeScript 3.7typescriptlang.org
- TypeScript: Documentation - Object Typestypescriptlang.org
- TypeScript Structured Concurrencythecandidstartup.org
- Shikishiki.style
- David Zearing - HackMDhackmd.io
- TypeScript: Documentation - Genericstypescriptlang.org
- Reading 8: Defining ADTs with Interfaces, Generics, Enums, and Functionsweb.mit.edu