Skip to content

Improve some completions on generic object literals #34855

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

Merged
merged 5 commits into from
Dec 11, 2019

Conversation

andrewbranch
Copy link
Member

Fixes some fallout from #33937. Using the intersection was the wrong approach as it led to some nasty effects with conditional and indexed access types:

Screen Shot 2019-10-31 at 10 32 43 AM

This is still not a perfect solution, as it offers too many completions in some cases, like this:

image

I’m planning to iterate on this and hopefully get rid of the invalid ones without un-fixing #30507, but I believe @DanielRosenwasser wants to look at this for 3.7.2.

Fixes #34825

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 31, 2019

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at bf0be61. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/51933/artifacts?artifactName=tgz&fileId=D10848D263A9E95490CF83E1E738665FD543415D3CCEC9BE8CAF06BDEB7E718902&fileName=/typescript-3.8.0-insiders.20191031.tgz"
    }
}

and then running npm install.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, something went wrong when looking for the build artifact. (You can check the log here).

@DanielRosenwasser
Copy link
Member

How do I run this in the playground @orta?

@weswigham
Copy link
Member

weswigham commented Nov 1, 2019

You can't - the trigger for the playground builds is borked - Github's broke some experimental API that was in use (that's what the bot's last comment is on about).

@orta
Copy link
Contributor

orta commented Nov 6, 2019

I've triggered it manually: url should be at the end of the build logs

https://www.typescriptlang.org/play/index.html?ts=3.8.0-pr-34855-2

@sandersn sandersn self-assigned this Dec 9, 2019
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Code and behaviour looks correct. Are there existing tests for the no-type-argument case? I expected to see some since the code now only applies in that case.

////): void;
////
////f<'foo'>({ a: { /*1*/ } });
////f<string>({ a: { /*2*/ } });
Copy link
Member

Choose a reason for hiding this comment

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

Why no tests without type arguments? The new code seems to apply exclusively in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

completionsGenericIndexedAccess2 is without type arguments, which tests the primary way that #33937 was a regression. Almost all the existing tests from #33937 / #32100 are without type arguments, but they weren’t complex enough to fail. This test was to ensure that the new clever stuff doesn’t apply when there is an explicit type argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autocompletion failing in 3.7.1-rc
6 participants