Skip to content

[Suggestion] Display the name of type alias in quick-info consistently #13095

Closed
@HerringtonDarkholme

Description

@HerringtonDarkholme

I have tried my best to search existing issues. Pardon me if it is still duplicated.

Currently quick-info will always display the name of an interface no matter if it is imported from other modules or declared in the same file. This greatly shortens quick-info message length.

Type alias behaves partly like interface: if type alias is declared in a non-module file, quick-info displays its alias name.

type Alias<K> = {
  property1: K
} | {
  property2: number
}

var a: Alias<string> // popup as Alias<string>

Online example

However, an import statement will make type alias displayed as its type literal expansion.

import 'test'
type Alias<K> = {
  property1: K
} | {
  property2: number
}

var a: Alias<string> // displayed as `{property1: string}|{property2: number}`

example

When used with mapped types, type alias' full expansion soon becomes very lengthy. For my extreme case, one type can have 7500+ lines of code after expansion.

After mapped types have more adoption, displaying type alias, in my speculation, might be a real world usability issue. It might even strangulate language service if the type is too large to show. For example, #12904 is using mapped type for MongoDB API. While all the typing looks proper and valid to me, the quick-info for MongoFilter<Person> is quite daunting. Also, compiler error reports the alias name, not expansion.

It would be fine if TypeScript can show alias name in quick-info consistently and concisely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Quick Infoe.g. hover text, tool-tips, and tooltips.SuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions