-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 not working on type parameter with constraint #20974
Comments
We would need subtraction types to do this correctly. The correct type isn't |
@RyanCavanaugh makes sense. So this is basically a duplicate of #4183? |
Not a duplicate since this case wouldn't start working automatically |
This doesn't work until subtraction types are implemented. Ref: microsoft/TypeScript#20974
@weswigham Is this fixed by #22096 or #22348? |
#22096 should cover it. |
Oh, in case anyone happens to hit this again in the future: The new (more correct) behavior is dependent on the presence of the global |
TypeScript Version: 2.7.0-dev.20171230
Code
Expected behavior:
Because of the constraint the compiler knows the type of
param
can only bestring | undefined
. Asserting the type with a non-null assertion should result instring
and the code should compile without error.If this is working as intended, I'll write a lint rule to warn about non-null assertions on type parameters.
Actual behavior:
The text was updated successfully, but these errors were encountered: