Consider the following example: (In strict-null-checks) mode
const fn: (p: { x: number } | null) => void = (p: { x: number }) => console.log(p.x);
fn(null);
This code produces no errors in typescript, but has a runtime type exception.
Seems to me like Typescript should have enforced target parameter type (here {x: number } | null) to be assignable to source parameter type (here { x: number }), so that, for example null wouldn't be passed where something else was expected and cause an error.
Why is this not enforcing that? Is that a bug in typescript? Or something in the configuration that I'm missing?