JavaScript will never be fully type-safe without fundamental changes, which will probably never happen.
JavaScript will never be fully type-safe without fundamental changes, which will probably never happen.
Disagree that full type safety would require a lot of runtime checks. That's not the experience I've had in ReasonML.
Why would this be the case?
Many type-safe languages throw an exception if you attempt to access an element in an array that is out of bounds but javascript just returns undefined.
Typescript ignores the fact that accessing an arbitrary element of an array could return undefined. If it did not ignore this fact then it would force you to deal with the potential undefined value retrieved from any array access (i.e you'd need to write a runtime check)
In some instances it makes sense to use a special NonEmptyList type that guarantees there is always at least one element, so you don't need to check.