How is possible that this code compiles, it should fail with the type thrown after the first if
class Optional<T> {}
class Some<T> extends Optional<T> {
constructor(public t: T) {
super()
}
}
function div(n: number, d: number): Optional<number> {
if (d === 0.0) {
return "IMPOSSIBLE"
}
return new Some(d / n)
}
console.log(div(1, 0))