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

Pretty-print Type Aliases #1793

Closed
kael-shipman opened this issue Nov 13, 2021 · 5 comments
Closed

Pretty-print Type Aliases #1793

kael-shipman opened this issue Nov 13, 2021 · 5 comments
Labels
enhancement Improved functionality

Comments

@kael-shipman
Copy link

Search terms

pretty pretty-print type alias type aliases

Expected Behavior

This might just be a setting or something that I'm totally missing. If so, fine to just point me there. I could also see this being 100% intentional behavior. That seems reasonable, given the other information on the page, but if that's the case, I'd like to convert this to a feature request. For almost all of my types, the best way to understand them is to just show the pretty-printed type definition with comments stripped out, then offer the comments further below as you've done already. It would be great for this to be an option.

Given the typescript source:

 export type MyType = {
  one: string;
  two: string;
  three: string;
  four: string;
  names: {
    me: string;
    you: string;
  }
}

The generated docs should show:

T MyType: {
  one: string;
  two: string;
  three: string;
  four: string;
  names: {
    me: string;
    you: string;
  }
}

Actual Behavior

Given the above Typescript source, the generated docs show the following:

T MyType: { one: string; two: string; three: string; four: string; names: { me: string; you: string } }

Steps to reproduce the bug

  1. Clone https://github.com/kael-shipman/typedoc-bug
  2. run npm install
  3. run npm run docgen

Environment

  • Typedoc version: 0.22.8
  • TypeScript version: 4.4.4
  • Node.js version: 14.18.1
  • OS: Ubuntu Studio Linux 20.04.3
@kael-shipman kael-shipman added the bug Functionality does not match expectation label Nov 13, 2021
@Gerrit0 Gerrit0 added enhancement Improved functionality and removed bug Functionality does not match expectation labels Nov 14, 2021
@Gerrit0 Gerrit0 added this to Might be resolved in Theme Rebuild Nov 14, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 14, 2021

This is expected behavior right now. We don't have custom rendering to try to pretty print any types. It isn't just object types either, https://typedoc.org/api/modules.html#KeyToDeclaration is less than useful... I believe this is something that might be fixed with a theme update that's a work in progress.

@kael-shipman
Copy link
Author

Thanks for the explanation! Seems totally reasonable. Feel free to close this or merge it into the theme work.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 24, 2021

I'll leave this open until I've confirmed it's resolved :)

@jgresham
Copy link

jgresham commented Oct 7, 2022

captainTorch's output in the PR looks great!

Anyone else know of any work arounds until the PR gets released?

@jgresham
Copy link

Awesome. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality
Projects
No open projects
Theme Rebuild
Might be resolved
Development

No branches or pull requests

3 participants