-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Suggestion] A way to mark .d.ts
files that they are strictNullCheck
compliant
#14810
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
.d.ts
files that they are strictNullCheck
complient.d.ts
files that they are strictNullCheck
compliant
We've discussed something like this at some point in the past - the problem is that you now make the task of using anything from that library extremely onerous. Anything returned from the API must now unconditionally be checked or non-null asserted. What's more, inputs to your API are now potentially too lax. There'd also be the question of what to do with object members - properties would presumably be optional, but would methods? |
One thing to note is that Our analysis of libraries also showed that most APIs do not change, and that the library definition with no null/undefined annotations is likely usable with Our recommendation is to flip We believe this is a point in time, and moving forward new libraries will be null-aware. We have enforces this on DT new definitions for instance. |
We could really use this to make #9041 ergonomic |
Without a clear distinction between input and output positions, this is kind of useless - from a read position you want to keep |
A project often depends on other libraries which come with their own
.d.ts
files. For example:Library:
lib_a.d.ts
When my project turns on
strictNullChecks
it is not clear to me if thelib_a.d.ts
can be trusted. Because if it was compiled withoutstrictNullChecks
than my project should interpret it as:Library:
lib_a.d.ts
but if it was compiled with
strictNullChecks
than thelib_a.d.ts
should be trusted as is.In real life there are often many library dependencies, and I would like to turn on
strictNullChecks
in my project before I have to wait that all of the third party libraries are ready.Straw-man syntax would be:
Library:
lib_a.d.ts
The TS compiler would than adjusted the types on the fly as it reads the libraries because it knows with what options they have been compiled.
The text was updated successfully, but these errors were encountered: