Skip to content

Unexpected completions returned for function inside object literal #38840

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 May 29, 2020 · 2 comments · Fixed by #38897
Closed

Unexpected completions returned for function inside object literal #38840

mjbvz opened this issue May 29, 2020 · 2 comments · Fixed by #38897
Labels
Bug A bug in TypeScript
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 29, 2020

From microsoft/vscode#98686

TypeScript Version: 4.0.0-dev.20200529

Search Terms:

  • completion
  • suggest / suggestions
  • completionInfo

Code
For the JS:

const z = {
  z: function() {}
}

Inside the function parens, type .

Bug
Completions are returned. Also isNewIdentifierLocation is set to false.

No completions are returned when you type . in a top level function

Here are the completions:

[Trace  - 07:24:46.568] <semantic> Sending request: completionInfo (284). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/index.jsx",
    "line": 2,
    "offset": 16,
    "includeExternalModuleExports": true,
    "includeInsertTextCompletions": true,
    "triggerCharacter": "."
}
[Trace  - 07:24:46.597] <semantic> Response received: completionInfo (284). Request took 29 ms. Success: true 
Result: {
    "isGlobalCompletion": false,
    "isMemberCompletion": true,
    "isNewIdentifierLocation": false,
    "entries": [
        {
            "name": "apply",
            "kind": "method",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "arguments",
            "kind": "property",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "bind",
            "kind": "method",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "call",
            "kind": "method",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "caller",
            "kind": "property",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "length",
            "kind": "property",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "name",
            "kind": "property",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "prototype",
            "kind": "property",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "toString",
            "kind": "method",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "z",
            "kind": "warning",
            "kindModifiers": "",
            "sortText": "6"
        }
    ]
}
@a-tarasyuk
Copy link
Contributor

a-tarasyuk commented Jun 1, 2020

const f4 = {
    x: function (.props) {}
}

I think that's because .props parsed as a PropertyAccessExpression, not as Parameter like in the following case

const x = function (.props) {}

What would be the right direction to fix it?

cc @DanielRosenwasser @RyanCavanaugh

@DanielRosenwasser
Copy link
Member

Not sure off the top of my head, but I would look into how we've dealt with stuff like in

let x = {
    ./**/
}

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

Successfully merging a pull request may close this issue.

4 participants