webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
79 stars 9 forks source link

Parsing TypeScript members at the class-level doesn't retain types or defaults #66

Closed bigtimebuddy closed 3 years ago

bigtimebuddy commented 3 years ago

Trying to reorganize the documentation in PixiJS so that member documentation is at the class-level. Historically with JSDoc these were added in the constructor when the property was initialized.

Here's an example of what I'd like to do:

class MyClass {
  /** Run in debug mode. */
  public debug: boolean = false;
}

I would expect the output from webdoc to infer the type and default from the TypeScript definition, but it does not.

This, however, works fine:

class MyClass {
  /**
   * Run in debug mode.
   * @type {boolean}
   * @default false
   */
  public debug: boolean = false;
}

One quick note: access-modifiers are handled correctly (public, private, protected).

ShukantPal commented 3 years ago

Inference improvements

ShukantPal commented 3 years ago

Just confirmed with a unit test.

ShukantPal commented 3 years ago

Turns out the issue was very simple. The symbol parser was inferring these perfectly fine, but the transformer was not mapping the defaultValue and dataType to the documents.

This raises the question if other things from SymbolSignature are not being mapped. Will look into this more closely tomorrow and then get it merged.