Skip to content

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 3, 2022

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

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 3, 2022
@typescript-bot
Copy link
Collaborator

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)) {
Copy link
Contributor Author

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 🤷‍♂️

@RyanCavanaugh RyanCavanaugh requested a review from ahejlsberg March 8, 2022 18:58
@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Mar 11, 2022
@typescript-bot typescript-bot removed the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 11, 2022
@sandersn sandersn requested a review from weswigham March 11, 2022 17:40
@weswigham weswigham merged commit 04238e6 into microsoft:main Mar 11, 2022
@Andarist Andarist deleted the fix/dependent-parameters-obj-methods branch March 11, 2022 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Control flow analysis for dependent parameters doesn't work for methods
5 participants