Properly render function generic types that don't extend another type

This commit is contained in:
Fabio Berger
2018-09-25 17:34:22 +01:00
parent b73df28454
commit b40861747b
3 changed files with 18 additions and 10 deletions

View File

@@ -134,14 +134,19 @@ function renderTypeParameter(
): React.ReactNode {
const typeParam = (
<span>
{`<${typeParameter.name} extends `}
<Type
type={typeParameter.type}
sectionName={sectionName}
typeDefinitionByName={typeDefinitionByName}
docsInfo={docsInfo}
isInPopover={isInPopover}
/>
{`<${typeParameter.name}`}
{!_.isUndefined(typeParameter.type) && (
<span>
{' extends '}
<Type
type={typeParameter.type}
sectionName={sectionName}
typeDefinitionByName={typeDefinitionByName}
docsInfo={docsInfo}
isInPopover={isInPopover}
/>
</span>
)}
{`>`}
</span>
);

View File

@@ -150,7 +150,7 @@ export interface Parameter {
export interface TypeParameter {
name: string;
type: Type;
type?: Type;
}
export interface Type {

View File

@@ -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,