-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Filter with "something is smallerType" don't work as negative #58996
Comments
This is independent of function positive(t: Something) {
return isAnimal(t)
}
// function positive(t: Something): t is Animal
function negative(t: Something) {
return !isAnimal(t)
}
// function negative(t: Something): boolean I'm surprised that #57465 didn't do this. Inside function negative(t: Something) {
if (!isAnimal(t)) {
((t));
//^? (parameter) t: Rock
} else {
((t));
//^? ^?(parameter) t: Animal
}
return !isAnimal(t)
} |
But we don't need |
Actually, it should be |
I certainly didn't mean that |
π Search Terms
filter is type narrow negative
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.5.2#code/C4TwDgpgBAggdgSwLYEMA2UC8UDeAoKKAIwCcIVgALALimBIFcIAaPAXwG489RIoAlAPYBjANZZcBYmQo0oAM3QBnFuy49w0AMqCkEKgjgBzCfGTooAHwEjR6+QzjDgCQXCgIlZ1GgAUS3X1KQyNaHT0DYwBKWgCI4OMPJVhEH0lCMmAGEnc4oJCAOlJyKnZuYTclYDoIKoBGMMDIk2x8QmLZWnomVjZyyurgWuAAJkb4kIk26RK5RTQVXvUKuCq6YKUASSUAeXFsAG0h+uYaqpGAXQL5BDQhkl9qzAA+JO90R6iorgB6H8IAYQAHoAfhS5jQBwu-VWgw22wA6iQ3C0oEdhnVTsdRlcbncIA8nq8AISed5+YBfX7-QHAsG+clWGxiKJQvBAA
π» Code
π Actual behavior
π Expected behavior
Additional information about the issue
Filtering is working only if "positive", but if the "is" is used as a negative then it don't type narrow.
The text was updated successfully, but these errors were encountered: