Can someone explain why the code below allows for null in typescript, even though number is specified as the type:
// Not sure why null is accepted here when I've specified number as the type
const foo = (): number => 1 || null
// Even when enforcing non-nullable
const foo2 = (): NonNullable<number> => 1 || null
// Here tough, it works: null is not a number
const foo3 = (i: number): number => i || null
It seems to be the case with undefined as well.