by chris_engel · 7y ago · 0 comments
I get that TS may be a good idea if you deal with teams of mediocre devs to prevent they do stupid things but by talking with a couple of JS devs and looking at my own JS experience it seems like the desire of using TS vanishes if you reach a certain experience ans confidence using vanilla JS. It looks like the most people who embrace TS see JS as some kind of inferior thing, anyways - but that might just be a wrong observation by me.
Perhaps spending some time looking at how certain libraries write their type definitions will help you learn how to use them, if you're constantly fighting you are probably missing some fundamental concept that TS operates with. TS has also gotten much better at expressing more complex types over time and there are still more things on the roadmap.
For me TS only grows more useful as the size of the codebase increases. It allows safe refactorings you could only dream of in a large JS codebase.
Would you, perchance, be able to share an example of such an error? We generally strive to improve error clarity where possible~
> I found out that using JSdoc comments and relying on the linting abilities of my IDE
Ah. Well, spoiler alert: if your IDE is vscode or VS that JSDoc is actually still getting typechecked by TypeScript ;)
I don't consider myself a mediocre dev but I can still do stupid things and TS tells me before I run it.
> It looks like the most people who embrace TS see JS as some kind of inferior thing
JS does feel inferior once you use TS.
You sound like you're just used to your workflow if you had to pull hairs out by just using TS.
In my experience Javascript code bases end up being "add new code only", because changing anything is just too dangerous, because type errors are so hard to find. So after a while of several people working on the code base it just becomes a bloated spaghetti mess that cannot be untangled, because refactoring is nigh impossible.
But the problem is still that you cannot make any such change to existing large Javascript codebase, because you don't have the kind of tools that you need in order to do so with any confidence that you won't have an enormous amount of uncaught runtime errors when you're done. This is what a static type system gives you.
apart from the generalization i tend to agree
from uncle bob's article [1]:
> My own prediction is that TDD is the deciding factor. You don’t need static type checking if you have 100% unit test coverage. And, as we have repeatedly seen, unit test coverage close to 100% can, and is, being achieved. What’s more, the benefits of that achievement are enormous.
I've worked on high mantainable big JS projects (+40 devs) with 80%-90% test coverage. plus we were using GraphQL so inputs were valid types somehow.
if I start a new project today I would use only these technics (valid inputs + integration test) with no typed lang.
[1] http://blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.htm...