Hacker News new | ask | show | jobs
by Vinnl 1608 days ago
This basically comes down to: avoid TypeScript features that clash with TypeScript's design goals. Specifically, the one to:

> Avoid adding expression-level syntax.

https://github.com/Microsoft/TypeScript/wiki/TypeScript-Desi...

And that makes sense to me. IMHO it's best to consider TypeScript as a tool that aims to help you write JavaScript by catching common errors; it's more like a linter than a separate language in that regard, and is what sets it apart from something like CoffeeScript, and helps it avoid falling into the same traps.

2 comments

> it's more like a linter than a separate language

I wish people wouldn't think like this; it's very possible to write perfectly acceptable JavaScript that's fundamentally terrible TypeScript. By "fundamentally terrible", I mean unnecessarily untypeable, or unnecessarily difficult to type. If you're just writing your usual JavaScript without thinking about the types just figuring you'll "lint" it later with tsc to catch some bugs, if you aren't thinking in TypeScript from the jump, you're likely to make your life much more unpleasant down the line. It's similar to the relationship between C and C++.

That's pretty much what I mean. A good linter will influence how you write code; e.g. over time, you'll have internalised to initialise a variable before using it, to name a dumb example. TypeScript is similar: yes, you'll write "regular" JavaScript, but no longer "without thinking about the types". TS very much influences how you write JS, and it makes you better for it.
Yes, I think if they could the would remove namespaces and enums