Skip to content
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

When using aliased intersection types, intellisense shows the constituent types and not the alias name #35537

Closed
alshdavid opened this issue Dec 6, 2019 · 5 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@alshdavid
Copy link

alshdavid commented Dec 6, 2019

TypeScript Version: 3.7 && playground
Search Terms:
intersection type alias

Code
When using a intersection type with an alias, you expect the intellisense label to show the name of the alias, not the constituent types.

In the following example, I would expect to see the label as "C", however TypeScript reports the type label as "A & B"

image

However, when using interfaces which extend multiple interfaces, you see the interface name:
image

Expected behavior:
Type alias intellisense should function the same as interface intellisense

Playground Link:

Intersection types with type alias

Interfaces

@alshdavid alshdavid changed the title When using union types, the type alias is not displayed When using union types that have an assigned alias, intellisense show the constituent types and not the alias name Dec 6, 2019
@alshdavid alshdavid changed the title When using union types that have an assigned alias, intellisense show the constituent types and not the alias name When using aliased union types, intellisense show the constituent types and not the alias name Dec 6, 2019
@alshdavid alshdavid changed the title When using aliased union types, intellisense show the constituent types and not the alias name When using aliased union types, intellisense shows the constituent types and not the alias name Dec 6, 2019
@MartinJohns
Copy link
Contributor

Relevant / duplicate (?): #34556

@jcalz
Copy link
Contributor

jcalz commented Dec 6, 2019

Please note that you're talking about intersection types (&) and not union types (|).

@alshdavid alshdavid changed the title When using aliased union types, intellisense shows the constituent types and not the alias name When using aliased intersection types, intellisense shows the constituent types and not the alias name Dec 7, 2019
@alshdavid
Copy link
Author

Thanks for the heads up, I have updated the ticket accordingly

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Dec 9, 2019
@RyanCavanaugh
Copy link
Member

This is the intended behavior. When you over over C you see C's definition; saying "C is C" is not a useful hover. Interfaces don't have a useful right-hand-side thing to show here, so interface C is sort of the best we can do.

When you invoke foo, you see the alias as expected, which is the place where it is useful:
image

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

5 participants