Description
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>
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}`
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.