import ts from "typescript" ; import { extractTypeScriptPropTypes } from "../extractPropTypes" ; import { ComponentFinder , ResultType } from "./types" ; import { isExported , findReactPropType } from "./utils" ; export const functionDeclarationFinder = { extract ( node , program ) { if ( ! ts . isFunctionDeclaration ( node ) || ! isExported ( node ) ) { return [ ] ; } if ( ! node . name ) { return [ ] ; } const name = node . name . text ; const checker = program . getTypeChecker ( ) ; const type = checker . getTypeAtLocation ( node ) ; const propType = findReactPropType ( type , checker ) ; if ( ! propType ) { return [ ] ; } return [ { type : ResultType . ComponentInfo , componentInfo : { name , propTypes : extractTypeScriptPropTypes ( propType , checker ) , } , } , ] ; } , } ;