镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Unexpected completions returned for function inside object literal #38840

Description

@mjbvz

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"
        }
    ]
}

Activity

  1. a-tarasyuk commented on Jun 1, 2020

    @a-tarasyuk
    Contributor
    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 Daniel Rosenwasser (@DanielRosenwasser) Ryan Cavanaugh (@RyanCavanaugh)

  2. DanielRosenwasser commented on Jun 1, 2020

    @DanielRosenwasser
    Member

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

    let x = {
        ./**/
    }
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions