I ❤️ TypeScript


I ❤️ TypeScript.

But it contains 4 features that I avoid:

1. The "private" and "protected" keywords on classes. Largely redundant since JS has native support via #.

2. Enums. An object marked "as const" accomplishes the same thing. And unions are often a simpler, lighter-weight solution.

3. Namespaces. This feature predates ES Modules. ES modules are sufficient for encapsulation.

4. Decorators. Confusing since TS decorators predate JS' decorators, and differ from the stage 3 JS decorators proposal.

Finally, there's a common problem with all 4 of these features - TS is supposed to be JS with static types. If we remove the types, what's left should be valid JS.

The 4 features above break this rule.

View original on X