Typedoc: Union array type being stripped

Created on 16 Sep 2016  路  4Comments  路  Source: TypeStrong/typedoc

A pretty simply array that can have both strings and numbers can be shown as (string | number)[], but is being output as string | number without any union'ing going on - specifically noticed with this -

function regex(regexp: RegExp): string | number | (string | number)[] {
}

Outputting as this -

regex(regexp: RegExp): string | number | string | number

Didn't find anything on searches for "union", but Friday rush so apologies if I missed something.

bug help wanted

All 4 comments

Stepping through the code, this reflection's type property is being set to a Union type and the type's isArray property is set to true, so it looks like it's an issue in the theme code not checking for isArray. I added a pull request to that repo to fix this issue.

@nicknisi Do you think there's a better way we can do some of this? I know there's a way to serialise the types into strings, do you think we can do that and remove the custom stringification process that TypeDoc does?

@blakeembrey I think we can for sure. TypeScript's checker has a typeToString method that gives us the exactly what we'd need for the type string. I'll try out making the switch.

I believe this was closed in TypeStrong/typedoc-default-themes#37

Thanks @nicknisi! :tada:

Was this page helpful?
0 / 5 - 0 ratings