Hello everyone today I am here to discuss and here your comments on what typescript adds to JavaScript and what cases it should be used in.
In my personal opinion and just recently switching from JavaScript to typescript I can definitely say typescript is amazing and should be used in a lot of places.
One of the main places I think should use typescript is in npm packages as it can help debugging with type safety.
Although I do believe JavaScript still has a place being used to develop websites with pure html, css, and js. The reason i say this is because I believe it is easier it interface with then typescript as you skip the compiling step.
My main point is that if you use JavaScript for developing npm packages or just developing in general, you should give typescript a shot. If you need help developing a tsconfig file you can use my tsconfig as a baseline.
If you have anything else to add please let me know, as I would be glad to add more info to the post
Have a nice day and happy programming
Top comments (6)
TypeScript is a game-changer when you work in a professional environment!
As long as you code alone, you know pretty much everything about your app. You can easily get away without it. I am writing an Angular tutorial and guess what? In many examples, I don't use TypeScript, or I just use simple types.
When you work in a team or when you get some code from other teams the fun begins!
It is not only about you, you don't quite know what you will get from an API or the backend. You should look it up yourself, assuming you know where to look and the documentation is good enough. And even when you do look for info, you are likely to forget the shape of the response.
Angular ships with TypeScript and from anecdotal experience React is also embracing it.
TypeScript is an incredibly useful tool. It is up to you to use it at the right time and in the right context.
Typescript adds more features to javascript like interfaces, custom types enums and more
In my opinion typescript shines the most when working on big projects as it makes it harder to produce hard to catch bugs
Type checking should be another part of your testing pyramid, even below unit tests: you're testing your expressions for type soundness in order to avoid surprise type coercion.
I believe that's what the test pyramid refers to as 'staticliy typed test'
Also, you can test your types using the
// @ts-expect-error
pragma.