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

[Semantic sugar] type aliases are lost using IntelliSense #90061

Closed
Sgt-Nukem opened this issue Feb 5, 2020 · 5 comments
Closed

[Semantic sugar] type aliases are lost using IntelliSense #90061

Sgt-Nukem opened this issue Feb 5, 2020 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@Sgt-Nukem
Copy link

When using a type alias in an interface (as semantic sugar) ... (A)

... this sugar is lost when using IntelliSense's "blue bulb" click -> "Implement interface XY" function. (C)

(See (B) for concrete type alias used here)

Appendix: Also, this semantic sugar is lost in IntelliSense hover tooltips -- see (D), where semantic sugar type "UUID" gets de-aliased down to "string" in the tooltip.

image

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 5, 2020

Please provide repo steps with example code (as text)

/needsMoreInfo

@vscodebot vscodebot bot added the info-needed Issue requires more information from poster label Feb 5, 2020
@vscodebot
Copy link

vscodebot bot commented Feb 5, 2020

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

@yume-chan
Copy link
Contributor

It (at least your figure D) should be caused by a limitation of TypeScript (see microsoft/TypeScript#34778).

Basically TypeScript will not record you are using a type aliases, only the resolved type.

@Sgt-Nukem
Copy link
Author

Sgt-Nukem commented Feb 12, 2020

Please provide repo steps with example code (as text)

Minimal Repo:

export type UrlString = string;
export type UUID = string;

export interface I_IdToUrlMapper {
	mapIdToUrl(id: UUID): UrlString
	mapUrlToId(url: UrlString): UUID
}

export class IdToUrlMapper implements I_IdToUrlMapper {

}

Now click the "blue bulb" that appears after clicking "IdToUrlMapper" (underlined in red) and choose "Implement interface 'I_IdToUrlMapper'" --> the resulting code is stripped off of any semantic sugar type aliases:

mapIdToUrl(id: string): string { throw new Error('Method not implemented.'); } mapUrlToId(url: string): string { throw new Error('Method not implemented.'); }

N.B.: Why is the code formatting here not working as expected?

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 12, 2020

Thanks! Opened microsoft/TypeScript#36761 to track upstream

@mjbvz mjbvz closed this as completed Feb 12, 2020
@mjbvz mjbvz added typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Feb 12, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants