Repository: TypeScript
Issue: Setting to hide inlay hints for implicitly-typed variables that are set to literals
Labels: Suggestion,In Discussion,Domain: Inlay Hints

# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

## 🔍 Search Terms

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

- inlay hints
- implicit variable

## ✅ Viability Checklist

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).


## ⭐ Suggestion

Change the `typescript.inlayHints.variableTypes.enabled` setting from a boolean to a enumeration, with options:

- none
- non-literals
- all

It may make sense to apply this same treatment to `typescript.inlayHints.propertyDeclarationTypes.enabled` as well.

## 📃 Motivating Example

<!--
  If you were announcing this feature in a blog post, what's a short explanation that shows
  a developer why this feature improves the language?
-->

Here is a screenshot of the snippet in my codebase that was the direct inspiration for this request:

<img width="1064" alt="image" src="https://user-images.githubusercontent.com/2101409/135153396-a2973f2b-3db5-432d-a3f1-ff37b01adce6.png">

The inlay hints are, to me, pretty noisy here.

1. It's obvious what the inferred type of the string literal and object literal will be. The function literal as well, though if I were to remove the type annotations I would be relying on _other_ inlay hints to help me there.
2. The hints for the object literal and function literal are almost useless, even if I wanted to be told the type. It does not take a particularly large object or complex function definition to hit the ellipsis limit for unnamed/unaliased object/function types.

However, I don't want to disable it for all implicitly-typed variables. This inlay hint from later in the same file is very non-obvious because it's behind a wordy function call:

<img width="865" alt="image" src="https://user-images.githubusercontent.com/2101409/135154294-c22269be-db09-46ed-a616-741b3ccdcd52.png">


## 💻 Use Cases

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

n/a? I think the motivating example section covers this.