-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Non-null assertion doesn't work for mapped types #23849
Comments
@weswigham can you take a look. |
I'm going to guess that when we look at |
Another question is why this is irreproducible in the playground? |
@bowenni because as it turns out, this is a regression introduced by #23592, I believe (since, looking at the playground, it clearly worked in 2.8). Update: Our conditional type constraint comparison logic was incorrect, but not for the stated reason. The distributivity is handled correctly, but how we got the constraint for an indexed access is off. We saw |
Thank you Wesley for the explanation! |
And I've got a fix up at #23884 😉 |
TypeScript Version:
Reproducible in 2.7.2 and 2.9.0-dev.20180502.
Irreproducible in 2.6.2
Search Terms:
Mapped types, Non-null assertion
Code
Expected behavior:
No errors.
Actual behavior:
In 2.7.2:
error TS2322: Type '{ [key in A]: {} | undefined; }[A]' is not assignable to type '{}'.
Type '{} | undefined' is not assignable to type '{}'.
Type 'undefined' is not assignable to type '{}'.
In 2.9.0-dev.20180502:
error TS2322: Type 'NonNullable<{ [key in A]: {} | undefined; }[A]>' is not assignable to type '{}'.
Type '{} | undefined' is not assignable to type '{}'.
Type 'undefined' is not assignable to type '{}'.
Playground Link:
I cannot reproduce the error in the playground.
From command line, I'm running
node_modules/.bin/tsc -strict test.ts
to reproduce it.Related Issues:
#19608
@rkirov
The text was updated successfully, but these errors were encountered: