Uh oh!
There was an error while loading. Please reload this page.
Include source node inferences in string literal completions - #54121
Conversation
Uh oh!
There was an error while loading. Please reload this page.
a236333 to
ef50d45Compare
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
Code LGTM though I'll leave it to Andrew as to whether or not this is the better approach (I assume it is)
A couple of my merged PRs related to completions are using a similar "double request" technique. One notable difference is that this PR here always performs the double request whereas those other PRs use the second request as a fallback - only if the first one didn't return anything useful. Out of curiosity, I wonder:
|
Jake Bailey (jakebailey)
commented
May 3, 2023
TypeScript Bot (@typescript-bot) user test tsserver |
Heya Jake Bailey (@jakebailey), I've started to run the diff-based top-repos suite (tsserver) on this PR at ef50d45. You can monitor the build here. Update: The results are in! |
Heya Jake Bailey (@jakebailey), I've started to run the diff-based user code test suite (tsserver) on this PR at ef50d45. You can monitor the build here. Update: The results are in! |
Heya Jake Bailey (@jakebailey), I've started to run the tarball bundle task on this PR at ef50d45. You can monitor the build here. |
Hey Jake Bailey (@jakebailey), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
TypeScript Bot (typescript-bot)
commented
May 3, 2023
Jake Bailey (@jakebailey) Here are the results of running the user test suite comparing Everything looks good! |
TypeScript Bot (typescript-bot)
commented
May 4, 2023
Jake Bailey (@jakebailey) Here are the results of running the top-repos suite comparing Everything looks good! |
I kinda already answered my own questions:
I think that there is a way to avoid the second request here by smartly providing |
| typeHasCallOrConstructSignatures, | ||
| }; | ||
| function getCandidateSignaturesForStringLiteralCompletions(call: CallLikeExpression, editingArgument: Node) { |
There was a problem hiding this comment.
nit: other "double requests" are performed outside of the checker - it's the caller's responsibility to "probe" both type of contextual types (with and without inference blocking). Is this a problem? Perhaps that other code should be moved to the checker?
Ron Buckton (rbuckton)
commented
May 5, 2023
Yes, the first request is returning candidates that result in
This is the simplest solution to the problem. In essence, we want completions that take into account what the user has already typed, but not to the extent that we filter out valid completions such as those that #48410 addressed. We are also considering a more comprehensive solution long term, but that may require more in-depth change to inference and needs further time for consideration and discussion. |
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
Let’s pull in the extra test cases from Mateusz Burzyński (@Andarist) and then I’m good with this.
Mateusz Burzyński (Andarist)
commented
May 19, 2023
Andrew Branch (@andrewbranch) perhaps it would be good to pull this into 5.1? I have some further improvements in mind for this, my tests might very well just get merged as part of those - I'm just waiting for this one to land to start working on a follow-up |
Andrew Branch (andrewbranch)
commented
May 19, 2023
5.2* It’s Ron Buckton (@rbuckton)’s PR to merge whenever he’s ready. |
Mateusz Burzyński (Andarist)
commented
Jun 16, 2023
Since this PR has conflicts and I was working on the code that created them, I resolved them cause I knew exactly how they should be resolved - but since I can't push to this branch I prepared a PR for you here: #54668 |
Mateusz Burzyński (Andarist)
commented
Jul 27, 2023
Ron Buckton (@rbuckton) friendly 🏓 |
Jake Bailey (jakebailey)
commented
Aug 15, 2023
Is there anything left to do here? It's got conflicts, but it's approved by two people. |
Ron Buckton (@rbuckton) did u check the PR in which i resolved the conflicts ( #54668 )? Iirc i already fixed it there but it has been a while so my memory around that is a little bit foggy |
This issue appears to be that we no longer skip type argument inference from arguments when checking for string literal completions, and end up inferring
That PR lists 5000+ file changes and is too large for GitHub to render in the UI, so I'm not sure what changes you may have made. At least, that was an immediate difference that I noticed between when this PR was drafted and main. The change is here: https://github.com/microsoft/TypeScript/pull/53996/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8L32511-R32515 |
Mateusz Burzyński (Andarist)
commented
Aug 31, 2023
We can compare that branch directly against The only difference is in this expectation. This is basically the same test case that was introduced in #53996 and it could be removed from this PR to avoid duplication. I understand that perhaps the current expactation from this PR might be considered better but it isn't noticeable for the majority of end users. So maybe it's worth landing this PR without fixing it (as the PR's focus was to fix a different case anyway) and to open an issue about it? The expected results are at least consistent right now between both markers (see here) and I think that the ideal result is that they always should be the same. The only reason why they are different here is that the code path used for object property values completions is quite different from the code path used for string completions directly at argument positions. It's not because they should behave differently - they just happen to behave differently (maybe because it's a design limitation since it might be more complex to do what argument completions do within objects but still). |
Ron Buckton (rbuckton)
commented
Aug 31, 2023
I had to make other changes than what you've illustrated to get the expectations from the tests I added to pass, reverting a number of places where |
23628eb to
c667870CompareRon Buckton (rbuckton)
commented
Aug 31, 2023
Or not, it looks like it's still not quite correct. |
There was a problem hiding this comment.
this file can be removed since this test already got its way to the main branch:
https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringCompletionsFromGenericConditionalTypesUsingTemplateLiteralTypes.ts
Mateusz Burzyński (Andarist)
commented
Sep 1, 2023
That's interesting! It turns out that for this one test the |
Uh oh!
There was an error while loading. Please reload this page.
Mateusz Burzyński (Andarist)
commented
Sep 4, 2023
I managed to get it working again without those reverts. The proposed change also brings back your expected results for the That change is somewhat significant and perhaps bikesheddable so it might be best to leave it for a follow-up PR that I can open once this one lands. |
Ron Buckton (rbuckton)
commented
Sep 8, 2023
Mateusz Burzyński (@Andarist):
The change in Andarist@26c1127 doesn't seem too complex, but I agree we can tackle it in a follow-on PR. Andrew Branch (@andrewbranch) can you take a quick look at this again before I merge? |
Ron Buckton (rbuckton)
commented
Sep 25, 2023
Andrew Branch (@andrewbranch), Jake Bailey (@jakebailey) can one of you take a look over the latest changes? |
I'll fix the merge conflict with checker shortly |
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
Still seems good to me.
This adopts the proposed fix mentioned in #49680 (comment). This is a different approach than the one taken by Mateusz Burzyński (@Andarist) in #52997, as that PR attempted to pre-filter results.
Fixes#49680
Supersedes #52997