Skip to content

Show function return type inlay hints even for JS functions that have explicit type annotationsΒ #45928

@mjbvz

Description

@mjbvz

Suggestion

πŸ” Search Terms

  • inlay hints
  • return type
  • function like
  • JavaScript

⭐ Suggestion

Currently the javascript.inlayHints.functionLikeReturnTypes.enabled setting in VS Code adds inlay hints to JS functions that do not have an explicit @return annotation:

// Shown here
function foo() /* : number */ { 
    return 1;
}

// But not here here
/** @return {number} */
function foo()  { 
    return 1;
}

This feels inconsistent, since I now have to look in different locations for the type information

I propose adding a new option that always enables these return types in JS files, even if there is an @return type annotation.

In the example above, this would result in the inlay hints showing on both functions:

function foo() /* : number */ { 
    return 1;
}

/** @return {number} */
function foo()  /* : number */ { 
    return 1;
}

This lets me read the code more like standard TypeScript

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions