Sitelet https://web.archive.org/web/20210607101703/https://github.com/microsoft/TypeScript/issues/16665
Skip to content
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

Include Default Parameter Values in Signature Help #16665

Open
mjbvz opened this issue Jun 21, 2017 · 16 comments
Open

Include Default Parameter Values in Signature Help #16665

mjbvz opened this issue Jun 21, 2017 · 16 comments

Comments

@mjbvz
Copy link
Contributor

@mjbvz mjbvz commented Jun 21, 2017

From microsoft/vscode#28925

TypeScript Version: 2.4.0

Feature Request
signatureHelp current shows when a parameter is optional but does not include any information about that parameter's default value:

function foo(x = 10) { }
foo(|)

Result of TSServer signatureHelp on foo

[Trace  - 5:42:22 PM] Response received: signatureHelp (378). Request took 20 ms. Success: true 
Result: {
    "items": [
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "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": "x",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "x",
                            "kind": "parameterName"
                        },
                        {
                            "text": "?",
                            "kind": "punctuation"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "number",
                            "kind": "keyword"
                        }
                    ],
                    "isOptional": true
                }
            ],
            "documentation": [],
            "tags": []
        }
    ],
    "applicableSpan": {
        "start": {
            "line": 3,
            "offset": 5
        },
        "end": {
            "line": 3,
            "offset": 5
        }
    },
    "selectedItemIndex": 0,
    "argumentIndex": 0,
    "argumentCount": 0
}

When the default value is a simple literal type, it would be helpful to display this default value in the signature help. This information could be included in the displayParts response

@sustained
Copy link

@sustained sustained commented Jun 28, 2017

👍

@billti
Copy link
Member

@billti billti commented Aug 8, 2018

See feedback request here for also showing this information via the JsDoc comments: https://developercommunity.visualstudio.com/content/problem/230423/jsdoc.html

@edwinclement08
Copy link

@edwinclement08 edwinclement08 commented Sep 25, 2019

Any Update on this?

@Yehonal
Copy link

@Yehonal Yehonal commented Dec 3, 2019

Updates?

@ivoiv
Copy link

@ivoiv ivoiv commented Dec 18, 2019

Also interested in updates.

@qiulang
Copy link

@qiulang qiulang commented Feb 28, 2020

Hi #27442 was closed but how do I show default value ? I tried ctrl+shift+space on optional parameter but it did bot show the default value at all.

@relsqui
Copy link

@relsqui relsqui commented Feb 28, 2020

@qiulang it's not implemented. that bug was closed because it's a duplicate of this one, but this one is still open and unaddressed.

@Zeal0us
Copy link

@Zeal0us Zeal0us commented Mar 10, 2020

This would be great. It's something you kind of just expect to be there, and could cause someone not familiar to assume that the default is undefined, which may be confusing in certain contexts.

@alystair
Copy link

@alystair alystair commented Mar 24, 2020

Also applicable to JS, not just TS

@amitsainii
Copy link

@amitsainii amitsainii commented May 21, 2020

Any Updates on this?

@alystair
Copy link

@alystair alystair commented May 21, 2020

Make sure you give a 👍 reaction to the issue - I feel that would help it get recognized more than simply bumping with comments

@patriciavandermeer
Copy link

@patriciavandermeer patriciavandermeer commented Jun 11, 2020

this is really frustrating as the work around are all pretty hacky and make the jsdocs less helpful in other ways :(

@negebauer
Copy link

@negebauer negebauer commented Jun 11, 2020

Would like to have this for jsdocs also

@delmarwichnieski
Copy link

@delmarwichnieski delmarwichnieski commented Aug 5, 2020

for JSDoc JavaScript IntelliSense too

@cougdoble
Copy link

@cougdoble cougdoble commented Jan 14, 2021

any update on this?

@csandman
Copy link

@csandman csandman commented Jun 2, 2021

Not sure if there has been any activity on this but I am also quite interested in this. I've been forced to add the default as a part of my description for each variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet