typescript-language-server / typescript-language-server

TypeScript & JavaScript Language Server

Home Page:https://www.npmjs.com/package/typescript-language-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to display only type alias in hover information without expanding

magnusdr opened this issue · comments

Summary

When hovering over functions or variables in TypeScript, the IDE (e.g., Visual Studio Code) often displays the expanded form of complex types, especially when these types are defined as interfaces or type aliases with many properties. This can make the hover information overly verbose and difficult to read, particularly when dealing with large, complex types.

For example, I have a function defined as follows:

function getVehicle(
  args: { id: string },
  context: ServerContext
): Promise<Vehicle>

Here, Vehicle is a complex type with many properties. When I hover over getVehicle, instead of seeing Promise<Vehicle>, I see Promise<{...hundreds of props}>, which clutters the hover information.

Screenshot 2024-01-29 at 11 47 08

Suggested Feature

I propose an option in the plugin configuration that allows developers to choose between viewing the expanded type or just the type alias in hover information.

Example
A possible implementation could be a configuration option like "typescript.hover.expandedTypes": "none" or "typescript.hover.expandedTypes": "simple".

Rationale
This feature would be particularly beneficial in large codebases where types are often quite complex. By allowing developers to view just the type alias, it would simplify the process of understanding code, reduce information overload, and improve overall developer experience.

VSCode doesn't use this server. Please report this in VSCode repo instead.