3 ms·
Types are checked both statically and at runtime. Having only static checking like TS does means that when someone fits untyped code in via a type hole, they st
by pie_flavor 5y ago
Types are checked both statically and at runtime. Having only static checking like TS does means that when someone fits untyped code in via a type hole, they stand the same chance of getting it wrong as the untyped code did. I was convinced of the merits of this by dealing with nonnullable code in Kotlin vs C# - the former checks at runtime too, the latter does not, the latter makes it far harder to find and debug the lingering NullReferenceExceptions.
There is a common type, `mixed`. A common superclass fills that role in some OO languages, and not in others. The practical purpose of a common superclass is to provide builtin functions like C#'s object.ToString(). You don't need to do that when working with generics, and __toString is a magic function instead. So `mixed` fills that role perfectly fine.