-
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
Conditional on property not propagated #59125
Comments
You can convert the type on your own |
I know that casting is an option, but it's generally more desirable to prove than promise something to a compiler. |
Duplicate of #42384. |
I don't think these are quite the same issue, since in that case it's about inferring which variant of a union type is active in the given branch, whereas in this case, there is no union type, only an object and its properties. |
It's about narrowing a property propagating to the parent type. You expect by checking the property |
Inheritance is involved nowhere here. Please don't speak if you have nothing of value to add. |
I did not mention inheritance anywhere. Please don't say I have nothing of value to add when you don't understand the problem at hand. π Checking a property like
|
The duplicate link is correct.
Not an acceptable way to interact with someone here. Please refer to the code of conduct:
|
I still fail to see how that issue is the same, but okay. Also, I think "Please don't speak if you have nothing of value to add." is good advice sometimes, especially to eager noobies, which this person appeared to me as. |
Yep, it's my first day using TypeScript, I'm such a noobie. |
π Search Terms
property undefined propagation
π Version & Regression Information
Not a regression as far as I can tell.
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240702#code/JYOwLgpgTgZghgYwgAgJICUIHc5QCbIDeAUMmcmAJ4AOEAXMgM5hSgDmA3KedVAPYAjOAOAAbYFQD8DEAFcAtgOhdyyKLgmVpTFuy4BfYsVCRYiFBhBtMjWaLBFuZKrQbNWVlT35CR4qjIKSlAGRgh8IMxq2Lh4AAp8fKIAKnw2dmAJScgAvMgAFFAx+IwMGMV4ANoAugCUZehW6fY1uQB8jqoA9F1oeBBwoqKUADQUABbAjMhYfHYEs1AA1nROyD1FYLJQINE4JQB0MGKm+QAe7chnB7yCwmKayACEOXmyIP3HIBB4tV5kPWQACFZGAxhAAG4QXagCYod78IY-ZAIOCMCBjCTIUDhKBFBBgYbIaD8KClNbhSIOaiJUQNJoQWwtaq5ZA1f7IGB8KAFSlRIr7Ah8GB7WKMWqdVTkYAiwoVG4+e7+SjPV7Id6fUA-CUkKV65A0pI3WSMcZywV-NaqQzWtabba7Q2iAxcIA
π» Code
π Actual behavior
It complains that the
probability
property may be undefined, even tho it was explicitly checked for that.π Expected behavior
It accepts the
push
as valid.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: