Hacker News new | ask | show | jobs
by kchamplewski 2395 days ago
> TypeScript doesn't count because all type information is stripped during runtime

What's the point of keeping this information around at runtime if you do all your type checks at compile time?

Based on this categorisation, Haskell for example isn't a strongly typed language, and yet Haskell's type checking is one of its biggest selling points, so this doesn't seem quite right.

3 comments

> What's the point of keeping this information around at runtime if you do all your type checks at compile time?

It forces you to write input validation code that stays in sync with your types. Otherwise bad input can invalidate all your type guarantees.

In practice, you don’t do all your type juggling at compile-time in even moderately complex libraries or applications. So TypeScript could certainly use better RTTI, I think. design:type metadata is insufficient.
Reflection is really useful. Right now the only way to differentiate types at runtime is testing for the existence of a key, which is kinda hacky.