Has anyone had a truly pleasant experience with Typescript in a medium to large project?
Has anyone had a truly pleasant experience with Typescript in a medium to large project?
Tried twice to wrap my head around what you are even talking about.
TypeScript is totally wonderful. It's also optionally typed.
I use it on a non trivial project with multiple teams.
Was introduced to it last year and it's fantastic compared to plain js.
This was generated by one line of code, simply applying the hoist-non-react-statics library as recommended by the official React docs https://reactjs.org/docs/higher-order-components.html#static...
JavaScript in many cases can be too dynamic to be properly typed. I'd rather have it than not - it has saved my ass a good number of times - but let's not pretend TS/Flow is totally wonderful.
At some point I hope to sit down and start filing bugs/sending PRs to fix many of the React Typescript types I find, but in the meantime there are several React modules I've replaced the with just `declare module 'react-thing'` to jus any-type it and move on.
It's about the one thing I can really ding intellij for at the moment.
It's bringing OOP back from having almost been forgotten, and with it, a reminder of proper library design and data types.
On the other hand, when writing server code targeting Node, with lots of dependencies on micro-libs, I've definitely had the experience of struggling with outdated or incorrect type definitions.
However, nowadays TypeScript has much better interoperability with untyped JS code. You can generally import an untyped JS module with the minimum of ceremony and have it Just Work (the type will be "any", so you don't get intellisense).
I find the best approach is to import types for the big libs you are using, like Express, and leave the micro-libs untyped. That way you get the benefit of types on your own code and your interactions with the framework, but can still leverage other code when you need to without giving yourself a headache.
Using yarn.lock means it never breaks unless we specifically choose to upgrade though, so it's still worth the increased productivity and safeness from TypeScript, which is awesome as a language especially combined with VS Code.
DT packages almost need _two_ version numbers that npm checks for semver breaks, but how to make that work is an open question and an interesting edge case in package management.
(I got some hate for one of my refactors, that I needed to get my own code to type correctly, that touched quite a few DT packages in the "middle" of an upstream major version, so I know this pain quite directly from both sides.)
It's not perfect, but we have found the types to be very nice when working on a large code base with lots of people. Dev development cycle remains quite fast.
In the worst case scenario, revert to local (checked-in) type definitions and fix it.
It never was a problem for me after more than 5 big TS projects.