Skip to content

Improve tooltip for generic rest arguments in TypeScript #29514

Description

I'm not sure if this should be a feature request or a bug report.

The Issue

Here is a code sample the illustrates the issue (you will have to read this to understand the rest of the post):

// the outer function `fun` accepts a callback function
// the callback function accepts a set of generic parameters
// the outer function `fun` returns a function that accepts the same parameters as the callback
function fun<A extends any[]>(cb: (...args: A) => any) {
  return (...args: A) => {};
}

// create a callback function to pass to `fun`
function callback(foo: string, bar: number) { }

// call `fun` and pass in `callback` 
// The value returned by `fun` will be a function that accepts the same parameters as `callback`.
// myVar will be of type: (foo: string, bar: number) => void
const myVar = fun(callback); 

If you type in this code into VSCode and hover over myVar, you will see that everything works fine. The parameters are shown alongside their types:

image

However, if you try to call the function by typing myVar( , the tooltip doesn't provide the expected information:

What I would expect to see is:

myVar(foo: string, bar: number): void

What I actually see is:

myVar(...args: [string, number]): void

image

The primary issue with the way it's currently implemented is that you cannot see the parameter names when you are calling the function, instead you only see the parameter types.

Activity

  1. ghost changed the title [-]Improve tool tip for generic rest arguments[/-] [+]Improve tool tip for generic rest arguments in TypeScript[/+] on Jan 19, 2019
  2. ghost changed the title [-]Improve tool tip for generic rest arguments in TypeScript[/-] [+]Improve tooltip for generic rest arguments in TypeScript[/+] on Jan 19, 2019
  3. removed their assignment
    on Jan 21, 2019
  4. dragomirtitian commented on Jan 23, 2019

    @dragomirtitian
    Contributor

    Isn't this a duplicate of #26563?

  5. added
    DuplicateAn existing issue was already created
    and removed
    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
    SuggestionAn idea for TypeScript
    on Jan 23, 2019
  6. RyanCavanaugh commented on Jan 23, 2019

    @RyanCavanaugh
    Member

    Oops, yes. Thanks!

  7. 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

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions