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

Union arguments are unexpectedly expanded #1472

Closed
arnog opened this issue Jan 19, 2021 · 3 comments
Closed

Union arguments are unexpectedly expanded #1472

arnog opened this issue Jan 19, 2021 · 3 comments
Labels
bug Functionality does not match expectation

Comments

@arnog
Copy link

arnog commented Jan 19, 2021

Search terms

unions, arguments

type Union = "a" | "b";
class A {
 foo(a: Union) { /*...*/ }
}

Expected Behavior

The reflections generated by Typedoc preserve the reference to theUnion type:

type Union = "a" | "b";
class A {
 foo(a: Union { /*...*/ }
}

Actual Behavior

The reflections generated by Typedoc "expand" the union, and lose reference to the Union type:

type Union = "a" | "b";
class A {
 foo(a: "a" | "b") { /*...*/ }
}

Environment

  • Typedoc version: 0.20.16. This did not happen in 0.19.

In case that matters, I'm seeing this when using in the JSON output.

@arnog arnog added the bug Functionality does not match expectation label Jan 19, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 19, 2021

This was caused by the switch in 0.20 to use the type checker more to get types - particularly to resolve method types with generic classes. I suspect TypeScript 4.2 will fix this - https://devblogs.microsoft.com/typescript/announcing-typescript-4-2-beta/#smarter-type-alias-preservation

@arnog
Copy link
Author

arnog commented Jan 19, 2021

Right, that makes sense...

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 3, 2021

TypeScript 4.2 contained some changes which makes this specific case better. If you update your TS version, you should see that union types are better about preserving their names if they are aliased somewhere.

@Gerrit0 Gerrit0 closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants