-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use type nodes if converting a regular function
Fixes some instances of TypeDoc falling into the type interning trap Closes #1454
- Loading branch information
Showing
5 changed files
with
187 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d528c69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why this is limited only to functions and not also for methods in classes/interfaces? Thanks!
d528c69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in classes/interfaces we have to deal with type parameters.
We could technically use type nodes for this as well, but then TypeDoc would have to duplicate the compiler's tracking of nodes, automatically resolve type parameters, and perform deduplication and normalization on the resolved types.
In most situations, TS 4.2 has made the difference not matter.
d528c69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see. But this seems to mean that all the parameters with aliased types (except in plain functions) are now being resolved if they map to intrinsic types. eg:
Gets documented as :
For me the use case is doing things like having a type alias called
Json
(which is literally just astring
) but which self-documents its semantics. Previously TypeDoc preserved the aliases in callables' parameters and elsewhere.Is this expected in TypeDoc 0.20.30, TypeScript 4.2.3? (If not, I'm happy to raise as an issue.)
PS thanks for the amazing work :)
d528c69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, yes... it's expected. I'd label an issue about that with design limitation most likely.
You can work around it by modifying your aliases slightly so that TS doesn't intern their usage.
d528c69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
type Numeric = number | Number;
etc is the least hacky solution I can find. Thanks for helping me think through this!