Skip to content

Commit

Permalink
fix(parser): treat ComponentType as elementType
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Jul 23, 2019
1 parent d0b0a82 commit 53f1e21
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53f1e21

Please sign in to comment.