Skip to content

Commit 53f1e21

Browse files
committedJul 23, 2019
fix(parser): treat ComponentType as elementType
1 parent d0b0a82 commit 53f1e21

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎src/parser.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,18 @@ export function parseFromProgram(
256256
declaration &&
257257
ts.isPropertySignature(declaration) &&
258258
declaration.type &&
259-
ts.isTypeReferenceNode(declaration.type) &&
260-
declaration.type.typeName.getText() === 'React.ElementType'
259+
ts.isTypeReferenceNode(declaration.type)
261260
) {
262-
return t.propTypeNode(
263-
symbol.getName(),
264-
getDocumentation(symbol),
265-
declaration.questionToken
266-
? t.unionNode([t.undefinedNode(), t.elementNode('elementType')])
267-
: t.elementNode('elementType'),
268-
);
261+
const name = declaration.type.typeName.getText();
262+
if (name === 'React.ElementType' || name === 'React.ComponentType') {
263+
return t.propTypeNode(
264+
symbol.getName(),
265+
getDocumentation(symbol),
266+
declaration.questionToken
267+
? t.unionNode([t.undefinedNode(), t.elementNode('elementType')])
268+
: t.elementNode('elementType'),
269+
);
270+
}
269271
}
270272

271273
const type = declaration

0 commit comments

Comments
 (0)
Please sign in to comment.