-
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
Fix/dependent parameters obj methods #48110
Fix/dependent parameters obj methods #48110
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
@@ -24315,7 +24315,7 @@ namespace ts { | |||
} | |||
|
|||
function getCandidateDiscriminantPropertyAccess(expr: Expression) { | |||
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference)) { | |||
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still different function-like types - but I couldn't repro this with like class methods etc and for some types (like getters/setters it doesn't make sense in the first place).
The issue is manifesting itself only if parameters are declared in the most straightforward way, so like in here:
const obj = { method(a, b) {} }
and when "dependent parameters" are flowing into them from an assignment to a particular type or something (there are no "inline" types declared for them). I couldn't reproduce this behavior with classes anyhow, nor with constructors - as param types don't seem to "flow" into them, they have to be declared explicitly. I might have missed some way to make those actually flow, maybe there is some combination of features that allows that I didn't think of 🤷♂️
fixes #47190 (comment) reported by @jcalz , fixes #48160
I've first committed the failing test case and then added a fix on top of that so you can exactly see what has changed for those new test cases:
27359b0...b15f40a