Skip to content
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

Add a regression test for completion list in object literal involving inferred obj with optional members #48910

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 1, 2022

This is just a regression test.

I was investigating a case that I've discovered some time ago but I discovered that it got fixed in 4.6. So I've decided to check if my issue was fixed directly or if, perhaps, it was fixed accidentally - and in general, I've wanted to check how it was fixed ;p

I was able to narrow down the fix to this PR: https://github.com/microsoft/TypeScript/pull/46743/files and I've confirmed locally that removing this single line of code brings the issue back. As we can see - the fixed issue by this PR is a different one, so I think that it's worth adding my case as a regression PR.

I've prepared a TS 4.5 playground demonstrating the issue. You can compare it with the TS 4.6 playground where the issue is gone.

I don't really understand the fix - didn't have time to dig into this deeper. Perhaps @a-tarasyuk or @andrewbranch would understand why does it help for this case too.

@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.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 1, 2022
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synthesized mapped type member symbols don’t have declarations which is why they’re affected by that fix. The function changed in the fix attempts to filter out completions for f({ blah/**/ where the blah you’re typing is the only place that causes a blah member to exist.

It seems we’ll be unable to determine that when the object literal member is being inferred to a mapped type, so while the fix made things better for hover and pressed, I would expect that it makes things worse for additional keys, giving a completion item that simply matches whatever you’re currently typing.

But checking, that doesn’t seem to be the case:

image

So I don’t know exactly what’s going on there, but I’m glad it’s all working 😄

@andrewbranch andrewbranch merged commit 63a941d into microsoft:main May 2, 2022
@Andarist Andarist deleted the regression-test/inferred-obj-optional-members branch May 3, 2022 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants