Typedoc: Complex types are documented as 'object' or 'any'

Created on 28 Jan 2019  路  7Comments  路  Source: TypeStrong/typedoc

Expected Behavior

Function defined as

expandNodes(items: {nodeOrLink: {id: string}, type: string, expandedType: string | null}[]){
...
}

should be documented as

expandNodes(items: {nodeOrLink: {id: string}, type: string, expandedType: string | null}[]): void

Actual Behavior

Function defined as

expandNodes(items: {nodeOrLink: {id: string}, type: string, expandedType: string | null}[]){
...
}

is documented as

expandNodes(items: object[]): void

Steps to reproduce the bug

Run typedoc with a ts file containing a class containing the above function. (TypeScript strict mode is on, in case that makes a difference.)

Environment

  • Typedoc version: 0.14.2
  • Node.js version: 10.15
  • OS: Windows 10
  • TypeScript version 3.2.2

If this is due to a typedoc setting or something then I apologize but I couldn't find such a setting documented anywhere.

bug

Most helpful comment

These all appear to be fixed in 0.20.

image

image

image

All 7 comments

Perhaps related: #953, #901

Yes, it does look like it might be the same bug, although excludeNotExported doesn't seem to make any difference to me.

Does anyone have a work-around for this? I have a bunch of types which are declared through a generic wrapper given an object literal, this makes their generated documentation much less useful.

  • Similar problem with explicit type definition :
type CastContext<C> = {
    cast: typeof UNICAST
    client ?: C
} | {
    cast: typeof MULTICAST
    clients: C[]
} | {
    cast: typeof BROADCAST
}

is rendered as

CastContext<C>: object | object | object

instead of the detailed description of each object

  • Another example :
export const UNICAST: unique symbol = Symbol('UNICAST')

is correctly rendered as :

UNICAST: keyof symbol = Symbol('UNICAST')

however, if I refer to it with typeof :

export type Capabilities = typeof UNICAST | typeof MULTICAST | typeof BROADCAST;

it is rendered as :

Capabilities: unique symbol | unique symbol | unique symbol

which is somewhat useless

Another similar problem I ran into in https://github.com/ubclaunchpad/new/issues/22:

export const clubConfig: {
  memberCount: number;
  currentTeams: Team[];
  featuredTeams: Team[];
} = {
  /**
   * The current or most recent active Launch Pad teams and their primary project.
   * 
   * Each element must satisfy [[`Team`]].
   */
  currentTeams: [ ... ]

generates the documentation without taking into account currentTeams: Team[]:

image

Huh, that's interesting. Looks to me like we are completely ignoring the type annotation, which is definitely an issue... and I thought we did look at that...

These all appear to be fixed in 0.20.

image

image

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KevinEady picture KevinEady  路  3Comments

atomsoftwarestudios picture atomsoftwarestudios  路  4Comments

cfischer picture cfischer  路  4Comments

0815fox picture 0815fox  路  3Comments

euberdeveloper picture euberdeveloper  路  3Comments