-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] Display the name of type alias in quick-info consistently #13095
Comments
This is a bit tricky due to implementation details. Internally types are interned, and aliases are eagerly resolved, so a resolved definition of When a type alias exists in the global scope, we store the first-seen alias with the type itself. This is a good heuristic (namely, aliases from lib.d.ts always "win" over user definitions of the same type). But we don't store the names of module-declared aliases because the same type alias might have different local names in different modules. We could potentially keep a per-module type->alias lookup. |
I was wrong about how the alias storage works - we don't care if it's global or not. Instead the problem is that the type-to-string code checks that the alias is reachable from the global scope, rather than the scope of the quickinfo request. It may be an issue of just using the correct reachability analysis depending on the QI invocation location. Investigate as Bug and see what happens |
Heads up I submitted a PR that would fix this at #23638. |
Nice to have but there is a lot of implementation complexity behind this. Still open to targeted PRs but I don't think we can make any specific promises here. |
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.Online example
However, an
import
statement will make type alias displayed as its type literal expansion.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.
The text was updated successfully, but these errors were encountered: