TypeScript 签名帮助未选择部分完成函数的正确重载,

b1zrtrql  于 2个月前  发布在  TypeScript
关注(0)|答案(3)|浏览(37)

microsoft/vscode#80570

TypeScript 版本: 3.7.0-dev.20190907
搜索词:

  • SignatureHelp
  • 参数提示
    代码

对于代码

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

addEventHandler('onPlayerQuit')
  1. 在调用 addEventHandler 的关闭 ' 后触发签名帮助

预期行为:

返回第二个重载的签名帮助

实际行为:

返回两个重载的签名帮助。我们最终显示了 onPlayerJoin 的第一个

btxsgosb

btxsgosb1#

这是完整的tsserver请求:

[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
}
o0lyfsai

o0lyfsai2#

@uniqueiniquity 这是一个我们周三讨论过的签名帮助问题的例子吗?

swvgeqrz

swvgeqrz3#

我提到的问题与现有的sig help会话的行为更相关,而不是触发一个新的会话。不过,我也同意在这里tsserver应该根据触发位置的上下文返回selectedItemIndex: 1

相关问题