@@ -147,7 +147,7 @@ export function extractExports(
147147 const unknownExports : Array < string > = [ ] ;
148148 for ( const exportSymbol of exportSymbols ) {
149149 if ( exportSymbol . name === 'default' ) {
150- validateComponentType ( componentName , exportSymbol , checker ) ;
150+ validateComponentType ( checker . getDeclaredTypeOfSymbol ( exportSymbol ) , checker ) ;
151151 componentSymbol = exportSymbol ;
152152 } else if ( exportSymbol . name === `${ componentName } Props` ) {
153153 propsSymbol = exportSymbol ;
@@ -167,18 +167,7 @@ export function extractExports(
167167 return { componentSymbol, propsSymbol } ;
168168}
169169
170- function validateComponentType ( componentName : string , symbol : ts . Symbol , checker : ts . TypeChecker ) {
171- const declaration = extractDeclaration ( symbol ) ;
172- let type : ts . Type ;
173- if ( ts . isExportAssignment ( declaration ) ) {
174- // export default Something;
175- type = checker . getTypeAtLocation ( declaration . expression ) ;
176- } else if ( ts . isFunctionDeclaration ( declaration ) ) {
177- // export default function Something() {...}
178- type = checker . getTypeAtLocation ( declaration ) ;
179- } else {
180- throw new Error ( `Unknown default export for ${ componentName } ` ) ;
181- }
170+ function validateComponentType ( type : ts . Type , checker : ts . TypeChecker ) {
182171 if (
183172 // React.forwardRef
184173 type . getSymbol ( ) ?. name !== 'ForwardRefExoticComponent' &&
0 commit comments