Closed
Description
export function f(n: i32 | null): i32 {
return n; // Should be an error
}
// This function should never return true true since 'f' returns 'i32' which is not nullable.
// But it does return true!
export function test(): boolean {
return f(null) === null;
}
Since f
is a compile error for string | null
orClassName | null
, I think it should be an error for i32 | null
too.
Instead, it compiles with no error, and it can apparently return a value its return type didn't declare, tested by calling test()
from JS which returns true
.
EDIT: This isn't a compile error for string | null
either, but I think it should be.