Skip to content

Signature help not select correct overload for partially completed function #33328

Open

Description

@mjbvz

From microsoft/vscode#80570

TypeScript Version: 3.7.0-dev.20190907

Search Terms:

  • SignatureHelp
  • parameter hints

Code
For the code

declare function addEventHandler(event: "onPlayerJoin", x: number): void;
declare function addEventHandler(event: "onPlayerQuit", y: string): void;

addEventHandler('onPlayerQuit')
  1. Trigger signature help after the closing ' in the call to addEventHandler

Expected behavior:
Signature help for the second overload is returned

Actual behavior:
Signature help for both overloads is returned. We end up showing the one for onPlayerJoin first

Screen Shot 2019-09-09 at 11 24 08 AM

Activity

  1. mjbvz commented on Sep 9, 2019

    @mjbvz
    ContributorAuthor

    Here's the complete tsserver request:

    [Trace  - 11:25:14 AM] <semantic> Sending request: signatureHelp (47). Response expected: yes. Current queue length: 0
    Arguments: {
        "file": "/Users/matb/projects/san/x.ts",
        "line": 4,
        "offset": 30,
        "triggerReason": {
            "kind": "invoked"
        }
    }
    [Trace  - 11:25:14 AM] <semantic> Response received: signatureHelp (47). Request took 5 ms. Success: true 
    Result: {
        "items": [
            {
                "isVariadic": false,
                "prefixDisplayParts": [
                    {
                        "text": "addEventHandler",
                        "kind": "functionName"
                    },
                    {
                        "text": "(",
                        "kind": "punctuation"
                    }
                ],
                "suffixDisplayParts": [
                    {
                        "text": ")",
                        "kind": "punctuation"
                    },
                    {
                        "text": ":",
                        "kind": "punctuation"
                    },
                    {
                        "text": " ",
                        "kind": "space"
                    },
                    {
                        "text": "void",
                        "kind": "keyword"
                    }
                ],
                "separatorDisplayParts": [
                    {
                        "text": ",",
                        "kind": "punctuation"
                    },
                    {
                        "text": " ",
                        "kind": "space"
                    }
                ],
                "parameters": [
                    {
                        "name": "event",
                        "documentation": [],
                        "displayParts": [
                            {
                                "text": "event",
                                "kind": "parameterName"
                            },
                            {
                                "text": ":",
                                "kind": "punctuation"
                            },
                            {
                                "text": " ",
                                "kind": "space"
                            },
                            {
                                "text": "\"onPlayerJoin\"",
                                "kind": "stringLiteral"
                            }
                        ],
                        "isOptional": false
                    },
                    {
                        "name": "x",
                        "documentation": [],
                        "displayParts": [
                            {
                                "text": "x",
                                "kind": "parameterName"
                            },
                            {
                                "text": ":",
                                "kind": "punctuation"
                            },
                            {
                                "text": " ",
                                "kind": "space"
                            },
                            {
                                "text": "number",
                                "kind": "keyword"
                            }
                        ],
                        "isOptional": false
                    }
                ],
                "documentation": [],
                "tags": []
            },
            {
                "isVariadic": false,
                "prefixDisplayParts": [
                    {
                        "text": "addEventHandler",
                        "kind": "functionName"
                    },
                    {
                        "text": "(",
                        "kind": "punctuation"
                    }
                ],
                "suffixDisplayParts": [
                    {
                        "text": ")",
                        "kind": "punctuation"
                    },
                    {
                        "text": ":",
                        "kind": "punctuation"
                    },
                    {
                        "text": " ",
                        "kind": "space"
                    },
                    {
                        "text": "void",
                        "kind": "keyword"
                    }
                ],
                "separatorDisplayParts": [
                    {
                        "text": ",",
                        "kind": "punctuation"
                    },
                    {
                        "text": " ",
                        "kind": "space"
                    }
                ],
                "parameters": [
                    {
                        "name": "event",
                        "documentation": [],
                        "displayParts": [
                            {
                                "text": "event",
                                "kind": "parameterName"
                            },
                            {
                                "text": ":",
                                "kind": "punctuation"
                            },
                            {
                                "text": " ",
                                "kind": "space"
                            },
                            {
                                "text": "\"onPlayerQuit\"",
                                "kind": "stringLiteral"
                            }
                        ],
                        "isOptional": false
                    },
                    {
                        "name": "y",
                        "documentation": [],
                        "displayParts": [
                            {
                                "text": "y",
                                "kind": "parameterName"
                            },
                            {
                                "text": ":",
                                "kind": "punctuation"
                            },
                            {
                                "text": " ",
                                "kind": "space"
                            },
                            {
                                "text": "string",
                                "kind": "keyword"
                            }
                        ],
                        "isOptional": false
                    }
                ],
                "documentation": [],
                "tags": []
            }
        ],
        "applicableSpan": {
            "start": {
                "line": 4,
                "offset": 17
            },
            "end": {
                "line": 4,
                "offset": 31
            }
        },
        "selectedItemIndex": 0,
        "argumentIndex": 0,
        "argumentCount": 1
    }
    
  2. mjbvz commented on Apr 9, 2020

    @mjbvz
    ContributorAuthor

    Ben Lichtman (@uniqueiniquity) Is this an example of the signature help issue we talked about on Wednesday?

  3. uniqueiniquity commented on Apr 9, 2020

    @uniqueiniquity
    Contributor

    Not quite - the issue I mentioned was more related to the behavior of an existing sig help session, rather than triggering a new one. I agree with the desire here for tsserver to return selectedItemIndex: 1 based on the context of the trigger location, though.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions