-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Fixed JS completions type spread #45484
Conversation
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 is probably some room for debate here, but I think the expected behavior described in the bug is wrong. The completions offered here are arguably correct (the existing tests certainly weren’t written in error; they are clearly asserting the behavior that’s being reverted here); the problem is that isNewIdentifierLocation
is false
but should be true
. Flipping it to true
will keep the existing completions, but will prevent .
from triggering them, I think (needs to be manually tested).
Also, |
I checked on the In regards to the tests, the completions provided are actually incorrect as the code would be wrong and not really access the property. i.e. in |
If I recall correctly, the point of |
Discussed in the call, but to put in writing—the reason ({ | }) at this point you very well may be writing a new property declaration or even binding pattern, which is exactly what |
I'm not sure I agree with this part. The thing that's really being complained about is the fact that we're providing completions after a But otherwise, yes, the existing tests were written intentionally. |
Yeah, I missed that in the bug because I wasn’t reproing it successfully, but Armando clarified for me—I was claiming that there should be completions at |
This reverts commit 33829fa.
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.
Nice work!
((isCallExpression(node) || isFunctionLike(node)) && | ||
node.end === contextToken.pos && | ||
node.getChildCount(sourceFile) && | ||
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken)) { |
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.
I actually wonder if this whole second condition is even needed now... seems like the examples in the comments would be covered by the new condition you added. It doesn’t hurt to leave it in, so I probably wouldn’t change it this close to a release, but it might be worth running tests with it removed just to see if it can be cleaned up and simplified in the future.
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.
I tried removing it as well and a couple of tests failed so I decided to leave it in place. Errors were related to writing syntax like
const foo = {
bar: function (.| ) {}
}
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.
+1 on @andrewbranch's nodeIsMissing check.
@typescript-bot cherry-pick this to release-4.4 |
Heya @andrewbranch, I've started to run the task to cherry-pick this into |
Hey @andrewbranch, I've opened #45564 for you. |
* Fix and updated tests * Added test * Revert "Fix and updated tests" This reverts commit 33829fa. * Filter out empty access expression * PR feedback
Fixed #45436.
Also, fixes a couple of tests that I believe are incorrect.