Description
TypeScript Version: 2.0.10
When I've turned on strictNullChecks
for my project, I get errors on TypeScript projects a depend on that haven't turned that on.
For example, RxJS 5 has not enabled strictNullChecks:
Code
// fromEvent expects the first parameter to be of type EventTargetLike - but, since it's compiled without strictNullChecks, null is valid as well.
Observable.fromEvent(document.getElementById('button'), 'click')
Expected behavior:
The above code to just compile.
Actual behavior:
A compilation error:
Error TS2345: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'EventTargetLike'.
Type 'null' is not assignable to type 'EventTargetLike'.
I'm not sure what the best solution is. I don't think they're shipping their own tsconfig, as far as I can see. In any case, that could be problematic as well, if they're using a different version of TypeScript - I guess TypeScript should remain forwards compatible as well.
Perhaps the generated .d.ts
files could, during compilation, be modified to add | null
to every type to at least ensure compatibility with dependent projects that have enabled strict null checks.