Thinking on slowly moving a large scale project over to TypeScript and curious if those that have done the same are still happy with the switch or if there are any cautionary tales before committing to TypeScript.
The main concern is that the overhead of defining types for everything (interfaces, objects, etc) is hard to do well, can lead to code bloat, causes too many workarounds, and provides a false sense of safety.
Would love to hear any success or horror stories that have come with a large code base moving over to TypeScript.
Top comments (7)
Maybe yes, but it is too late -- TypeScript has a vendor lock-in (vs JSDoc).
What TypeScript does for me is Type Hinting. Using JavaScript, in many cases, is like walking in the dark, unless the author is kind enough to write a JSDoc for me.
When I use JavaScript, I write a lot of JSDoc as well. Even though it is not as strong and easy as TypeScript.
Also, it seems to me that TypeScript tries to break compatibility with JSDoc, at least in VSCode. Must be a hidden plot of Microsoft.
When I go back to JavaScript, I use JSDoc, but it is not cross-compatible with TypeScript. (
*.ts
cannot always read JSDoc. JSDoc cannot read*.d.ts
)It's a tough one. It definitely does add overhead and as you said sometimes it requires some pretty silly workarounds. On the other hand, it can improve the code quality and readability when used in moderation.
I suggest using it on something relatively small and not critical at first. See whether it suits your use case and what kind of ROI you can get out of it.
Beware of letting the hype cloud your thinking (I know it happens to me when I am not careful:)).
Good luck!
Defining type is often not an important task, so it leads to code where definitions usually does not match with the actual JavaScript. This leads to unpredictable results.
What we did was we left our mature framework as it is, and we rewrote entire framework in a new version in which everything was written in typescript. This is only possible if you have unit tests for old mature framework which you can run against new framework.
The only problem with this is, you have to do dual patching, any code changes in old code must also be applied to new TypeScript version. Well if old code is mature, the patches will be less and you can also keep your production code away from TypeScript till it is 100% ready.
We have done it and it took over 2 years, but finally it was worth it.
Yes, it's something that I always wanted.
I started coding using C and C#, so they TS works is pretty similar. Also I like to code using the POO behavior and also reutilize the code in a optimized way.
In summary, I won't ever come back to JS without using TS.
I've started a new project and chose Typescript for the first time. It's is a bit of a learning curve but I've been saved so many times already when debugging that I think it is worth it. I also think the code base is more documented.
I would never go back and I don't see typing as an overhead because it saves so much time debugging. I also don't see it as code bloat because it's just useful information to have.
It definitely pays off, just don't obsess over it.
For greenfield maybe ReasonML would be more interesting, but large code base might not be feasible.