Skip to content

Proposal: Prettified type display in hover output #2457

@sQVe

Description

@sQVe

Hey! 👋

I've been thinking about type readability in hover/quickinfo output and wanted to float an idea.

The problem

Complex types can get pretty hard to parse visually, especially with intersection types or deeply nested objects. The prettify-ts extension for VS Code tackles this for tsserver and has gotten quite popular (~330 stars, ~50k installs), which suggests it's scratching a real itch for people.

Quick example

Given:

type User = { id: string; name: string };
type Timestamps = { createdAt: Date; updatedAt: Date };
type UserRecord = User & Timestamps & { role: "admin" | "user" };

const user: UserRecord = /* hover here */

Today:

const user: User & Timestamps & { role: "admin" | "user" }

Prettified:

const user: {
  id: string;
  name: string;
  createdAt: Date;
  updatedAt: Date;
  role: "admin" | "user";
}

The idea

Would it make sense to have this as an optional flag somewhere? Maybe a TypeFormatFlag, an LSP setting, or even a tsconfig option. Nothing too fancy, just a way to opt into expanded type display.

I totally understand if this is low priority while you're focused on feature parity! But if there's interest, I'd be happy to put together a PR.

Thanks for all the work on this project, I've been very happy using it so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions