3 ms·
In the one that it is statically typed on compile time, but what gets executed is not because the javascript vm is not statically typed.
by joking 6y ago
In the one that it is statically typed on compile time, but what gets executed is not because the javascript vm is not statically typed.
- filleduchaos 6y agoWhat you might be trying to say is that TypeScript is not _strongly_ or _soundly_ typed. "Only statically typed at compile time" is a meaningless statement because "checks types at compile time" is the whole definition of static typing.
- gwillz 6y agoThe JVM also does erasure of generics. Yes, it's not _all_ types but it too relies heavily on compile time typings.
- 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.