3 ms·
It solves all the issues I have with Javascript, that are all related to its weak and dynamic type system: awkward, unwanted type conversions all around, tons o
by sacado2 8y ago
It solves all the issues I have with Javascript, that are all related to its weak and dynamic type system: awkward, unwanted type conversions all around, tons of "undefined is not a function", and lack of IDE integration. So, yes, it's definitely worth it, even for small projects. And it's not like it's hard to learn once you know javascript, anyway. It's nothing more than a superset of the language.
- Rebelgecko 8y agoTypescript has been great for me (someone who started with Javascript by writing code essentially through trial and error). One of the other benefits of TS I get surprised a lot less by what the "this" keyword evaluates to.
- aikah 8y ago> that are all related to its weak and dynamic type system It doesn't make JS strongly typed though. It's still possible to compare different types, it still allows type coercion,truthiness and what not. It add type definitions, but it does not turn Javascript into a strongly typed language.
- rictic 8y agoThis is true. There are tslint checks that will disallow truthiness in conditionals, and disallow many types of type coercion.
- jeremychone 8y agoTypeScript is a structural typing system, vs the normal nominal one we are used to. Now, I agree that even with this difference, still not a strong typing as it could be, however, get pretty close to it (with all of the added expressiveness added to it). So, all in all, for big app dev, Java vs TypeScript, from a typing point of view, it comes pretty close.
- alangpierce 8y agoIt actually does disallow various type coercion operations that you can do in JS, even when they're arguably useful. For example `1 == "1"` doesn't typecheck: https://www.typescriptlang.org/play/index.html#src=const%20x%3A%20number%20%3D%201%3B%0D%0Aconst%20s%3A%20string%20%3D%20'1'%3B%0D%0Aconsole.log(x%20%3D%3D%20s)%3B https://www.typescriptlang.org/play/index.html#src=const%20x... So while there are still things like truthy/falsy values, the type system is stronger (not just static) in some sense compared with JS.