From 53f1e21c9afe854e4c2b4cb1c7e6249e3bbc7c23 Mon Sep 17 00:00:00 2001 From: merceyz Date: Tue, 23 Jul 2019 02:18:19 +0200 Subject: [PATCH] fix(parser): treat ComponentType as elementType --- src/parser.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index 2fe2925..08c60ce 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -256,16 +256,18 @@ export function parseFromProgram( declaration && ts.isPropertySignature(declaration) && declaration.type && - ts.isTypeReferenceNode(declaration.type) && - declaration.type.typeName.getText() === 'React.ElementType' + ts.isTypeReferenceNode(declaration.type) ) { - return t.propTypeNode( - symbol.getName(), - getDocumentation(symbol), - declaration.questionToken - ? t.unionNode([t.undefinedNode(), t.elementNode('elementType')]) - : t.elementNode('elementType'), - ); + const name = declaration.type.typeName.getText(); + if (name === 'React.ElementType' || name === 'React.ComponentType') { + return t.propTypeNode( + symbol.getName(), + getDocumentation(symbol), + declaration.questionToken + ? t.unionNode([t.undefinedNode(), t.elementNode('elementType')]) + : t.elementNode('elementType'), + ); + } } const type = declaration