5 ms·
While I'm in favor of TS, I'm in favor of it for practical reasons. Since the new ESLint is going to be highly modular, TS would shine in defining these module
by nine_k 4y ago
While I'm in favor of TS, I'm in favor of it for practical reasons.
Since the new ESLint is going to be highly modular, TS would shine in defining these modules' interfaces in a robust way. Whether to use TS deeper down, or whether to enforce the use of TS across the codebase, is another question. Prototyping is often easier and faster with plain JS, while typing well-defined parts later may be helpful for maintenance purposes.
- madeofpalk 4y ago> Prototyping is often easier and faster with plain JS I disagree, especially in the realm of AST-crawling, that having type hints in the IDE has been extremely beneficial in moving fast.
- nine_k 4y agoI have very often seen prototype code crafted in a REPL, not in an IDE. That's where the fluidity comes in handy. Type-level refactoring tools don't seem to be very powerful at the moment, too; without them, you can end up with some legwork when you change a design decision (a frequent thing while prototyping), even if you carefully aliased every type (which is legwork in its own right, because trivial cases like 2-tuples are plentiful). Fortunately, TS allows you to gradually type your code, and rely on inference in many cases (not as much as Haskell, but still).
- jakear 4y agoWhat you want is a prototyping REPL, in your IDE, that gives you type hints, type aware autocomplete, and inline type errors, but knows to back the fuck off when you want to just run the code and perform simple type-stripping rather than erroring out and telling you to fix types or GTFO. Bonus points if it comes in notebook form so you get a nice convenient run button, a solid multiline text editor, and markdown-powered persistence format. Thankfully, this already exists: https://marketplace.visualstudio.com/items?itemName=jakearl.handydandy-notebook https://marketplace.visualstudio.com/items?itemName=jakearl.... . And it supports every language your shell does! (I made it)
- Xelynega 4y agoDoesn't JSDoc(which the original post wants to use) also allow you to robustly define interfaces?
- graftak 4y agoJsdoc has the same issue as regular comments. It’s not the source of truth but someone’s hopefully up to date version of the truth.
- Xelynega 4y agoAFAIK the only thing jsdoc "can't do" that typescript can is "generic types", which is just syntactic sugar for having a base type that all others inherit from.
- runarberg 4y agoYou’re wrong. TypeScript allows annotating types within JSDoc comments, and knows how to read it. Writing in JavaScript and using TypeScript as a type checker is a perfectly feasible option that many have picked (including this eslint rewrite). https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html https://www.typescriptlang.org/docs/handbook/jsdoc-supported...