About 2,550,000 results
Open links in new tab
  1. How do the different enum variants work in TypeScript?

    References to computed members cannot be inlined, of course. Conversely, a non-computed enum member is once whose value is known at compile-time. References to non-computed members are …

  2. typescript - Use enum as restricted key type - Stack Overflow

    Can an enum be used as a key type instead of only number or string? Currently it seems like the only possible declaration is { [key: number]: any }, where key can be of type number or string. Is it

  3. typescript - Difference between string enums and string literal types ...

    Similarly, you could change an enum value easily using refactoring tools, instead of changing a string everywhere. Edit: In VS 2017 and TypeScript >=3.2.4, intellisense works with string literal types:

  4. Enum as Parameter in TypeScript - Stack Overflow

    Jun 11, 2015 · Here is an example that allows passing an enum with a typechecked value of that enum using a generic. It's really a response to a slightly different question here that was marked as a …

  5. TypeScript Enum alternative following the use of --erasableSyntaxOnly ...

    Jul 3, 2025 · TypeScript has added the erasableSyntaxOnly flag, that doesn't let you use Enums. Have looked for several alternative options. Like: What's the best practice to implement an alternative to

  6. How to build a type from enum values in TypeScript?

    Mar 13, 2019 · 122 How to build a type from enum values in TypeScript? An enum can hold string and number values. For strings: you can create a string union from enum values using a template string

  7. typescript - What is the difference (pros/cons) between using an enum ...

    Nov 12, 2019 · const enum LanguageEnum { English, Spanish } type LanguageAlias = "English" | "Spanish"; let l: LanguageAlias = "English"; let la: LanguageEnum = Language.English The goal of …

  8. How to create enum like type in TypeScript? - Stack Overflow

    Oct 2, 2012 · I'm working on a definitions file for the Google maps API for TypeScript. And I need to define an enum like type eg. google.maps.Animation which contains two properties: BOUNCE and …

  9. TypeScript - How can omit some items from an Enum in TypeScript ...

    Feb 18, 2018 · TypeScript - How can omit some items from an Enum in TypeScript? Asked 7 years, 9 months ago Modified 1 year, 4 months ago Viewed 110k times

  10. types - How to merge two enums in TypeScript - Stack Overflow

    Suppose I have two enums as described below in Typescript, then How do I merge them enum Mammals { Humans, Bats, Dolphins } enum Reptiles { Snakes, Alligators, Lizards } e...