typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Pretty-print Type Aliases

Open kael-shipman opened this issue 4 years ago • 3 comments
trafficstars

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 avatar Nov 13 '21 18:11 kael-shipman

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.

Gerrit0 avatar Nov 14 '21 14:11 Gerrit0

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

kael-shipman avatar Nov 14 '21 21:11 kael-shipman

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

Gerrit0 avatar Nov 24 '21 21:11 Gerrit0

captainTorch's output in the PR looks great!

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

jgresham avatar Oct 07 '22 19:10 jgresham

Awesome. Thanks!

jgresham avatar Oct 10 '22 21:10 jgresham