4 ms·
> 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 a
by 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.