Skip to content

Generic object literal completions include any random member you’re currently typing #35268

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

Closed
mjbvz opened this issue Nov 21, 2019 · 2 comments · Fixed by #35709
Closed

Generic object literal completions include any random member you’re currently typing #35268

mjbvz opened this issue Nov 21, 2019 · 2 comments · Fixed by #35709
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Nov 21, 2019

From microsoft/vscode#85185

TypeScript Version: 3.8.0-dev.20191121

Search Terms:

  • suggest / suggestions / completions / intellisense
  • optional
  • extends

Code
For the code:

interface Test {
    keyPath?: string;
    autoIncrement?: boolean;
}

function test<T extends Record<string, Test>>(opt: T) { }

test({
    a: {
        keyPath: '',
        a
    }
})

Trigger suggestions after a in the call to test.

Expected behavior:
Suggestion for autoIncrement returned.

Actual behavior:
No suggestion for autoIncrement. Only a single suggestion for a is returned

[Trace  - 18:58:01.966] <semantic> Sending request: completionEntryDetails (90). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/a.ts",
    "line": 11,
    "offset": 10,
    "entryNames": [
        "a"
    ]
}
@RyanCavanaugh
Copy link
Member

@andrewbranch I think you have a duplicate of this you've been looking at?

@andrewbranch
Copy link
Member

andrewbranch commented Nov 22, 2019

This is mostly solved by #34855, except the bogus a completion is still there. I think @DanielRosenwasser told me we attempt to filter out object literal completions that are exactly what you’ve already typed, but I’ve noticed them come up basically all the time, so either that filtering is very broken or does not indeed exist.

I’ll keep this open until #34855 is merged and then will fix the superfluous completion afterwards or separately.

@andrewbranch andrewbranch added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Nov 22, 2019
@andrewbranch andrewbranch changed the title No suggestions for optional property of extended type Generic object literal completions include any random member you’re currently typing Dec 16, 2019
@andrewbranch andrewbranch added the Fix Available A PR has been opened for this issue label Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants