-
-
Notifications
You must be signed in to change notification settings - Fork 734
TypeDoc expands very complex type aliases instead of referring to them #1867
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
Comments
This is a design limitation right now - TypeDoc relies on TypeScript to determine what type it should display when dealing with generics. Since TypeScript (since TS 4.2) preserves the alias name if the object type was created in type space, rather than with a type query type, this is likely a bug/missed edge case in the improvements for smarter type alias preservation. I've opened microsoft/TypeScript#47828 to track that. class Generic<T> {
method(): T extends string ? 123 : 456
}
// Child.method should be documented as returning 123, not
// "T extends string ? 123 : 456" or "string extends string ? 123 : 456"
// Implementing this without re-implementing the whole type checker means relying on TS.
class Child extends Generic<string> {} If you hover over the function signature, you'll see the same display as what TypeDoc renders. |
I also ran tests on different versions of TypeScript, and the result was the same. Let me know if it turns out to be useful: https://github.com/Mirdukkk/typedoc-issue (docs-ts-*.json) |
This is unfortunately something that can't really be fixed in TypeDoc. microsoft/TypeScript#47828 needs to happen, and once it does TypeDoc will automatically pick up the change |
Problem
When TypeDoc generates documentation in JSON, bumping into complex object/template literal types, it takes them apart piece by piece, instead of creating a reference type.
Actual Behavior
TypeDoc creates a huge union type, parsing type alias into all its possible values:

At the same time, the type to which it should refer is declared correctly and exported:

And this type declaration works file:
As a result, the documentation looks like this:

Expected Behavior
But the documentation is expected to look like this:

TypeDoc was expected to create a reference to the type:
Steps to reproduce the bug
Reproduction repo: https://github.com/Mirdukkk/typedoc-issue
Don't forget to put any tsconfig that would compile three files: index.ts, work.ts and types.ts.
See also
perhaps the bug reason is here: #1258 (comment)
Environment
Search terms
type aliases
expands
reffer
The text was updated successfully, but these errors were encountered: