microsoft / microsoft/TypeScript

Allow customization of type display format in hover tooltips

Open
#59,370 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms
  • customization type display
  • Array or T[]
✅ Viability Checklist
⭐ Suggestion

In TypeScript, when hovering over a variable, the inferred type is displayed in a specific format.
For instance, an array of numbers is shown as number[].
However, some developers, including myself, prefer the alternative format Array<number> for readability and consistency with other generic types.

📃 Motivating Example

I have noticed that there is an WriteArrayAsGenericType flag in the Abstract Syntax Tree (AST) that can convert T[] to Array<T>.

I would like to request the addition of a configuration option in tsconfig.json to enable this flag, allowing developers to choose their preferred format for array types in hover tooltips.

For example:

{
  "compilerOptions": {
    "typeDisplayFormat": "generic" // Options could be "generic" for Array<number> or "shorthand" for number[]
  }
}
💻 Use Cases

Complex Type Readability: I frequently write functional code that can lead to complex types like Task<Maybe<Task<Maybe<T[]>>[]>>[]. The shorthand [] notation can make it difficult to understand the nested generic relationships. Displaying these types as Array<T> would significantly improve readability and comprehension.

Consistency: Most other generic types use angle brackets (e.g., Promise<T>, Map<K, V>), and only array types use the special shorthand (number[]). Aligning array types with this convention would ensure consistency across all types and improve clarity.

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

Start by tracing how hover tooltip types are formatted and where the AST's WriteArrayAsGenericType flag is used. Review how compilerOptions are defined and consumed, then determine the configuration and display behavior needed for generic versus shorthand array types. Done means the selected format appears consistently in hover tooltips without changing emitted JavaScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.