Skip to content

Consider adding setting that only shows inlay hint parameter names for simple literals (string, number, bool) #45295

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

Open
mjbvz opened this issue Aug 2, 2021 · 6 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Aug 2, 2021

Suggestion

πŸ” Search Terms

  • inlay hints
  • parameter names
  • typescript.inlayHints.parameterNames.enabled

βœ… Viability Checklist

N/A, tooling related

⭐ Suggestion

Add a new setting that only shows inlay hints for simple literals. This would include:

  • string
  • number
  • bool
  • regexp literal?
  • null?
  • undefined?

Currently the "typescript.inlayHints.parameterNames.enabled": "literals" setting also shows parameter name hints for function, array, and object literals

I imagine this new setting would be called something like: "typescript.inlayHints.parameterNames.enabled": "simpleLiterals", although better names welcome

@a-tarasyuk
Copy link
Contributor

@mjbvz Is it possible to have an array as an option? To allow users to choose what literals should be handled. Or adding simpleLiterals option to handle "string", "number", "bool" would be enough?

"literals" | ["string", "number", "bool", "regexp", "null", "undefined"]

@mjbvz
Copy link
Contributor Author

mjbvz commented Aug 3, 2021

Yes, we just would need to make sure VS Code's settings editor can render it nicely

One option is to have settings per type: typescript.inlayHints.paramterNames.showStings, typescript.inlayHints.paramterNames.showNumber, ....

This is what we do for the suggest settings in VS Code, such as editor.suggest.showEnumMembers

The other option would be to have a single setting with checkboxes. This is similar to what the gitLens extension does:

Screen Shot 2021-08-03 at 2 25 42 PM


On the TS side, we could provide the setting in whatever format is most convenient for you

On the VS Code side, I think I'd prefer the first approach for discoverability. This is getting a bit beyond the original issue's scope, but the main options I'd personally want are:

  • objects
  • functions
  • simple literals: string, number, bool, regexp, undefined, null

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Aug 5, 2021
@a-tarasyuk
Copy link
Contributor

@mjbvz Thanks for the detailed clarification.

Currently option"literals" handles the following expressions/literals

string, number, bool, regexp, undefined, null, [], {}, () => {}, function () {}, ``

New options:

"literals" - Current behavior shouldn't be changed
"simple literals" - string, number, bool, regexp, undefined, null
"functions" - () => {}, function () {}
"objects" - {}

Which option should handle []?

@jessetrinity
Copy link
Contributor

"simple literals" - string, number, bool, regexp, undefined, null

Suggestion:
"primitive literals" - string, number, bool, undefined, null

@a-tarasyuk
Copy link
Contributor

@mjbvz I can try to create a POC with one option "primitiveLiterals" which will handle only string, number, bool, undefined, null. The option "literals" will work without changes. Does that make sense?

@mjbvz
Copy link
Contributor Author

mjbvz commented Aug 13, 2021

Yes that sounds great. I think that would become the new default for VS Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
4 participants