From abb9875eef16aec4d5f7740a0b19f2eb7ee56fb9 Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Tue, 25 Jun 2019 16:34:20 +0200 Subject: [PATCH] fix: fix showing type annotations for ts --- src/templates/Documentation.js | 6 +++--- src/types.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/templates/Documentation.js b/src/templates/Documentation.js index dace88e..88468a6 100644 --- a/src/templates/Documentation.js +++ b/src/templates/Documentation.js @@ -71,8 +71,7 @@ const ANNOTATION_OPTIONAL = '@optional'; const ANNOTATION_INTERNAL = '@internal'; const ANNOTATION_EXTENDS = '@extends'; -const getTypeName = (flowType: TypeAnnotation) => - flowType.raw || flowType.name || ''; +const getTypeName = (type: TypeAnnotation) => type.raw || type.name || ''; const hasAnnotation = (item: any, annotation: string) => // eslint-disable-next-line no-nested-ternary @@ -89,6 +88,7 @@ const PropTypeDoc = ({ name, description, flowType, + tsType, type, required, defaultValue, @@ -100,7 +100,7 @@ const PropTypeDoc = ({ const typeName = // eslint-disable-next-line no-nested-ternary - flowType ? getTypeName(flowType) : type ? getTypeName(type) : null; + flowType || tsType || type ? getTypeName(flowType || tsType || type) : null; return ( diff --git a/src/types.js b/src/types.js index 57ebb4f..0516a7f 100644 --- a/src/types.js +++ b/src/types.js @@ -50,6 +50,7 @@ export type Docs = { value: string | number, }, flowType?: TypeAnnotation, + tsType?: TypeAnnotation, type?: TypeAnnotation, }, },