Aliased discriminants with declarations in binding elements within parameters are not narrowing #56351
Labels
Help Wanted
You can do this
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
π Search Terms
discriminant alias condition binding element parameter narrowing narrow
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20231109#code/C4TwDgpgBAqgzhAigVwgJxAJQnZAbYAHgBUA+KAXgCgooAfKAbxttYEs4BlZAYx5zgAuKADMAhngQBuFqygATMcDHDkAO3kQRbNRHky5AXxYNmc2h258Bw4GlQHzi5cOKPahmVRHqewNgD2alDICCjoIAAUAJTC8EioGNi4BIRqyAC2AEbo5GZQaBDAyGjB+RZcvPxwQqISCAA0sgpKKiEaWjp6TR4yxlQ8QXDATC0uY2IAjA1QllU2s5XWNZNQhpQhYYlR0V4+an6BwcA4wJGME8LOUzNzy7V31XCrhnFbEcn4ROnZudFMLEGamGo2uV1aACZbksnsJHgIIWsNqEEhEYl5aECQWJClYnht4SsoAAyYmLPEIxxsERQSI4iAUmr-coTSYAOmAAQAogAPMBBCBqfwSdFQAD0YqgcAAFgF8PIoDkoAEANbNa4QjncvkCoVsEW7cWSjjKtUeKjGIA
π» Code
π Actual behavior
data1
is not narrowed downπ Expected behavior
data1
should be narrowed down just likedata2
is narrowed downAdditional information about the issue
The fix for this would be an extension to the recently landed #56173 . However, it's not straightforward to fix this right now.
isConstantReference
can't properly assess if the related parameter symbol is "const" or not and the code operates there on a pseudo reference of the whole binding pattern and not on the individual symbol. It would become much more straightforward if this would land: #56313The text was updated successfully, but these errors were encountered: