-
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
Error with this['prop'] type interacting with || operator #15376
Comments
There is not a way currently to remove null/undefined from a generic type. when We need a type operator to be applied to the generic type in these narrowing conditions to remove null/undefined when the type is instantiated. The underlying issue is tracked by #14366 |
But in this case shouldn't it know that |
The compiler can not make that assumption, class Bar extends Foo {
foo:undefined;
} now the result of the narrowing should be |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.2.1, 2.3.0
Code
Expected behavior:
Expected no errors because the type of the expression
foo || 'default'
should bestring
in all cases.Actual behavior:
When a type is derived indrectly from
this
it seems to break the type inference of the || operator.The text was updated successfully, but these errors were encountered: