-
Notifications
You must be signed in to change notification settings - Fork 12.8k
non-strictNullChecks projects producing .d.ts files that cannot be used from a strictNullChecks projects #8995
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
This has been discussed before in #8405. I have a comment with reference to the paragma proposal in #8405 (comment) |
Thanks for the reference Mohammed. While issue is similar, there is a major difference with what I am describing here. This is not "point-in-time migration request". The setup we have in google, works as follows, there are a number of projects - some are copies of external TS projects - angular2, RxJS, etc, and some are internal projects that depend on those. Each project (what I call a "compilation unit") above calls the TS compiler once. To speed up compilation and modularity, the project dependencies are not consumed through the original While we want all projects in our control to have Say RxJs has to compile with function f(foo: Foo): void; meaning my API accepts Application A compiles against RxJs and wants to pass null to f. f(null) Because the The pragma indeed is a messy solution, maybe a better solution would be |
the problem is One thing to note, I do still think this is a point-in-time still, an app can not really switch to strict-null until all its dependencies do, or at least be annotated in a strict-null-friendly fashion. our analysis showed that in a typical .d.ts most of the declarations do hold in strict-null checks, i.e. |
+1 on this request. We need a way to mark which d.ts file are already strict-null check adopted, and which ones not. |
TypeScript Version:
nightly (1.9.0-dev.20160217)
Code
The produced 'a.d.ts' is:
Imagine a and b are different complication units and interface through
a.d.ts
. The code works as expected in TS 1.8.Now imagine B decides to turn on strict null checks first.
Expected behavior:
The code should compile. B is stricter internally, but its compilation flags should not change the interpretations of existing
.d.ts
files.Actual behavior:
b.ts is rejected because
f
ina.d.ts
is interpreted as accepting onlyFoo
, but really it is acceptingFoo | null
.Vaguely remember an option for
.d.ts
containing a pragma was discussed, but I did not see it land, so I am not sure there are plans to work on that, or there are good reasons for not implementing it.The text was updated successfully, but these errors were encountered: