-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Turning on strictNullChecks also errors on libraries that haven't turned it on #12615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Vinnl This doesn't look like an issue with the definition, it looks like an issue with your code. Although the library could be updated to support You can either wrap it in an |
@blakeembrey Actually, I'm using RxJS 5, which does seem to expect it. I'm inclined to agree that updating libraries to support Thanks for your suggestions though, with those we can make do for now. |
Gotcha, thanks for pointing that out. Yeah, it's a tricky situation and it would throw in that case from the library. Not sure if you were planning to handle the catch, but I'd say that catch is there for runtime issues anyway (it's not super useful for type checking to accept |
@mhegazy I just noticed this was labelled In fact, I think the use case "libraries using different TSConfig settings than the projects they're used in" is something that might need to be dealt with in general. Effectively, TypeScript with different config settings are almost different languages. |
@Vinnl I think you've misunderstood something. This isn't an issue with TypeScript, and it is a question. If you have an issue with the way the definition or library has been written, take it up with the authors (which happen to be RxJS, not TypeScript). It can be handled by TypeScript, but this is purely a definition issue which are not written by the TypeScript team - those are written by module authors. Edit: I did mention above, though, that passing |
You can see my reply in #14810 (comment) for a similar issue. |
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
Expected behavior:
The above code to just compile.
Actual behavior:
A compilation error:
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.The text was updated successfully, but these errors were encountered: