File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
typescript/src/react/post-processors Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export class ReactComponentPostProcessor extends PostProcessor {
3636 variable . type . returnType instanceof LCETypeDeclared &&
3737 ( variable . type . returnType . fqn . globalFqn === '"react".React.JSX.Element' ||
3838 variable . type . returnType . fqn . globalFqn === '"react".JSX.Element' ) ) ||
39- ( variable . type instanceof LCETypeDeclared && variable . type . fqn . globalFqn === '"react".React.FC' )
39+ ( variable . type instanceof LCETypeDeclared && isReactFunctionComponentType ( variable . type . fqn . globalFqn ) )
4040 ) {
4141 const component = new LCEReactComponent ( variable . fqn , variable . variableName , [ ] ) ;
4242 if ( variable . metadata . has ( JSXDependencyContextProcessor . JSX_DEPENDENCY_METADATA ) ) {
@@ -62,3 +62,19 @@ export class ReactComponentPostProcessor extends PostProcessor {
6262 }
6363 }
6464}
65+
66+ /**
67+ * returns whether the provided fqn belongs to an interface/type describing a React function component
68+ */
69+ function isReactFunctionComponentType ( globalFqn : string ) : boolean {
70+ switch ( globalFqn ) {
71+ case '"react".React.FC' :
72+ case '"react".React.ExoticComponent' :
73+ case '"react".React.NamedExoticComponent' :
74+ case '"react".React.ForwardRefExoticComponent' :
75+ case '"react".React.MemoExoticComponent' :
76+ return true ;
77+ default :
78+ return false ;
79+ }
80+ }
You can’t perform that action at this time.
0 commit comments