microsoft / microsoft/TypeScript

[Feature Request] [Typescript Extension] Less redundant inlay hints for arrow function vars/consts

Open
#62,953 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: LS: Inlay Hints Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Example ts file without inlay hints:
```ts
//No inlay hints
import { createContext, useContext } from "solid-js";
import type { Application } from "pixi.js";

export const PixiContext = createContext();

export const usePixi = () => useContext(PixiContext)!;
```

Example ts file with all inlay hints:
```ts
//All inlay hints
import { createContext, useContext } from "solid-js";
import type { Application } from "pixi.js";

export const PixiContext /*: Context | undefined>*/ = createContext();

export const usePixi /*: () => Application*/ = () /*: Application<...*/ => useContext(PixiContext)!;
```

My suggestion is to extend the `TypeScript › Inlay Hints › Variable Types: Suppress When Type Matches Name` setting to also hide the inlay hint for a variable/constant when its value is an **arrow function** that already displays its own return type inlay hint.

Example ts file with my suggestion:
```ts
//Feature suggestion
import { createContext, useContext } from "solid-js";
import type { Application } from "pixi.js";

export const PixiContext /*: Context | undefined>*/ = createContext();

export const usePixi = () /*: Application*/ => useContext(PixiContext)!;
```

This would avoid redundant type information when the variable name and the function's return type provide sufficient context.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin by locating the TypeScript inlay-hints implementation and the “Variable Types: Suppress When Type Matches Name” setting. Compare the existing arrow-function return-type hint with the requested variable-hint suppression, then add coverage showing redundant variable hints are hidden while return hints remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.