Skip to content

Commit ab653c3

Browse files
committed
Update readme
1 parent b94535a commit ab653c3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,28 @@ From [TypeScript Handbook on Enums](https://www.typescriptlang.org/docs/handbook
88

99
> Enums are one of the few features TypeScript has which is not a type-level extension of JavaScript.
1010
11-
In other words, TypeScript enums have their corresponsing runtime representations, they are not erased from your emitted JavaScript files after being compiled. This conflicts with one of the non-goals of [TypeScript Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals):
11+
In other words, TypeScript enums have their corresponsing runtime representations, they are not erased from your emitted JavaScript files after being compiled. This conflicts with one of the [TypeScript Design Non-goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals#non-goals):
1212

1313
> Provide additional runtime functionality or libraries. Instead, use TypeScript to describe existing libraries.
1414
1515
Having this TypeScript feature extending into your compiled JavaScript also conflicts with the TypeScript slogan of being a **typed superset of JavaScript**, which further introduces vendor lock-in.
1616

17-
[Orta Therox](https://github.com/orta) from Typescript team mentioned in [one of his YouTube video](https://youtu.be/8qm49TyMUPI?t=1240) that the TypeScript team actually regrets some of the changes it made in the beginning, including introducing enums which basically add features to JavaScript.
17+
[Orta Therox](https://github.com/orta) from Typescript team mentioned in one of his [YouTube video](https://www.youtube.com/watch?v=8qm49TyMUPI&t=1240) that the TypeScript team actually regrets some of the changes it made in the beginning, including introducing enums which basically add features to JavaScript.
1818

19-
Moreover, using enums in TypeScript has a lot of caveats and edge cases to keep in mind. Some aspects of it are even considered not **type safe**!!! Head over to these wonderful articles for more details on these issues:
19+
Moreover, using enums in TypeScript has a lot of caveats and edge cases to keep in mind. Some aspects of it are even considered **not type safe**!!! Head over to these wonderful articles for more details on these issues:
2020

2121
- https://maxheiber.medium.com/alternatives-to-typescript-enums-50e4c16600b1
2222
- https://stackoverflow.com/questions/40275832/typescript-has-unions-so-are-enums-redundant/60041791#60041791
2323

24-
Additionally, if you have been using [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript.html), you might already notice that one of the caveats is to avoid using `const enum`s, as those require type information to compile.
24+
Additionally, if you have been using [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript.html), you might already notice that one of the [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript.html#caveats) is to avoid using `const enum`s, as those require type information to compile.
2525

2626
Nonetheless, TypeScript is still a very fantastic and powerful programming language that I love very much. Enums may have been a very good feature to have back in the early days (2011) when good alternatives did not yet exist.
2727

28-
However, we now already have alternatives better than enums, such as **const assertions** and **string unions**. Which is why I created this ESLint plugin to provide you with some configs and rules to disallow the use of TypeScript enums.
28+
However, we now already have alternatives better than enums, such as **const assertions**, **string unions**, **discriminated union**, etc. Which is why I created this ESLint plugin to provide you with some handy configs and rules to disallow the use of TypeScript enums.
2929

30-
This article provides a very in-depth exploration on the alternatives to TypeScript enums: https://2ality.com/2020/02/enum-alternatives-typescript.html
30+
This article provides a very in-depth exploration on the alternatives to TypeScript enums:
31+
32+
- https://2ality.com/2020/02/enum-alternatives-typescript.html
3133

3234
## Installation
3335

0 commit comments

Comments
 (0)