4 ms·
^ I see that you're not joking with this comment :D. Jokes aside, I'm adding facts TypeScript is statically typed because of the type annotations and how the c
by valand 6y ago
^ I see that you're not joking with this comment :D. Jokes aside, I'm adding facts
TypeScript is statically typed because of the type annotations and how the compiler checks the type compatibility between objects.
You may can consider TypeScript weakly-typed, because the TypeScript type information are not being encoded into the compilation result.
This is similar to C (being staticcally and weakly typed). You can print int as string and the compiler won't complain.
On the other hand, JavaScript is a dynamically typed and strongly typed language. It is strong as the types are encoded in the runtime. The proof is the keyword `typeof` and its ability to do Reflection.
Reference:
Static vs Dynamic: https://en.wikipedia.org/wiki/Type_system#Type_checking https://en.wikipedia.org/wiki/Type_system#Type_checking
Strong vs Weak: https://en.wikipedia.org/wiki/Strong_and_weak_typing https://en.wikipedia.org/wiki/Strong_and_weak_typing
- 59nadir 6y agoYou've misunderstood what "weakly typed" means. If a language implicitly converts values (like your C example) or otherwise lets execution move forward in the presence of what are or should be type errors, it's weakly typed. JavaScript has plenty of implicit conversions and will generally only halt execution if it literally cannot do something (like make a function out of `undefined` or the like), much like C, and is a weakly typed language.