8 ms·
What other features does TypeScript have? Genuinely curious, I haven't used TS much so I'm probably missing a bunch.
by sebzim4500 3y ago
What other features does TypeScript have? Genuinely curious, I haven't used TS much so I'm probably missing a bunch.
- nayuki 3y agoEnum, namespace, type-oriented programming (e.g. https://type-level-typescript.com/ https://type-level-typescript.com/ ), easy de-sugaring down to earlier versions of ECMAScript (e.g. converting async-await to switch statements). Plus, whatever you can find under the "Reference" section: https://www.typescriptlang.org/docs/ https://www.typescriptlang.org/docs/
- dschuessler 3y agoEnums are one example. They are compiled to objects existing at runtime rather than stripped out like types.
- FireInsight 3y agoHow do you express option/enum types without enums? And if you do that, isn't it more of an unsupported way of doing things than using the native enum type?
- jauco 3y agoI guess unions of string or number literals? type Option = “foo” | “bar"
- iainmerrick 3y agoYes, exactly this. For most purposes it's simpler and better than TS enums.
- dabber 3y agoconst assertions work well: https://devblogs.microsoft.com/typescript/announcing-typescript-3-4/#const-assertions https://devblogs.microsoft.com/typescript/announcing-typescr.... There is an example in the "Objects vs Enums" section of the Enum docs, at the bottom of the page: https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums https://www.typescriptlang.org/docs/handbook/enums.html#obje...
- dabber 3y agoThere aren't many. Enums[0] are probably the most common. [0] https://www.typescriptlang.org/docs/handbook/enums.html https://www.typescriptlang.org/docs/handbook/enums.html