4 ms·
Just like Generics in Java, Typescript only exists at compile time. Talking about what Typescript doesn't do at runtime is moot.
by damagednoob 6y ago
Just like Generics in Java, Typescript only exists at compile time. Talking about what Typescript doesn't do at runtime is moot.
- lmm 6y agoTypescript permits you to write code that does implicit unsafe casts at runtime. Type-safe languages don't. Java Generics don't let you implicitly do unsafe casts[1]; erased generics mean the unsafe cast wouldn't necessarily fail visibly at runtime (though there are warnings and linters to alert you to that, and techniques to work around it), but it would enforce that it was explicit in the code (and you would then know to add extra test coverage etc.). [1] You can implicitly do unsafe casts using arrays, but arrays aren't really using generics, they're a special-case builtin.