From b40861747b73bb9a0826853751b7caa5cbf085ae Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 17:34:22 +0100 Subject: Properly render function generic types that don't extend another type --- packages/react-docs/src/components/signature.tsx | 21 +++++++++++++-------- packages/react-docs/src/types.ts | 2 +- packages/react-docs/src/utils/typedoc_utils.ts | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'packages') diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index bf9c8be24..4f10f4665 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -134,14 +134,19 @@ function renderTypeParameter( ): React.ReactNode { const typeParam = ( - {`<${typeParameter.name} extends `} - + {`<${typeParameter.name}`} + {!_.isUndefined(typeParameter.type) && ( + + {' extends '} + + + )} {`>`} ); diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index f9cb5e26a..29f5664f5 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -150,7 +150,7 @@ export interface Parameter { export interface TypeParameter { name: string; - type: Type; + type?: Type; } export interface Type { diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index f44945369..e3e9c11fb 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -419,7 +419,10 @@ export class TypeDocUtils { return func; } private _convertTypeParameter(entity: TypeDocNode, sectionName: string): TypeParameter { - const type = this._convertType(entity.type, sectionName); + let type; + if (!_.isUndefined(entity.type)) { + type = this._convertType(entity.type, sectionName); + } const parameter = { name: entity.name, type, -- cgit v1.2.3