I believe any language that supports "any" allows this. Doesn't Kotlin? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/
> If it's a union type, typically (Obj | undefined), everything will work fine until one day the object is undefined and everything blows up.
Not if you set strict: true in your typescript options, or you can separately enable just strictNullChecks
> Essentially Typescript Is too trusting. In Java or similar languages, if something comes in as Object you know all bets are off. If you cast and it succeeds you know 100% what kind of object it is. In Typescript it's possible for the type to look fine but be completely wrong, or worse, wrong in a subtle way. And there's no way to fix this without breaking interop with JavaScript.
Instead of casts that fail, typically you would use type guards to deal with this. That way you can isolate unsafe casting code to a single place.
> Since Java has always been strongly typed and has a ton of libraries available this isn't an issue in Kotlin.
DefinitelyTyped (http://definitelytyped.org/) has types for over 3500 popular libraries: https://www.npmjs.com/~types
> the runtime is about 10x faster.
Hmm. I see 1.5x-6x here, with average around 3-4x: https://benchmarksgame.alioth.debian.org/u64q/compare.php?la...