import * as ts from "typescript" ; function isDeclaredAt ( symbol , moduleName ) { const declarations = symbol . getDeclarations ( ) ; if ( ! declarations ) { return false ; } return declarations . map ( declaration => declaration . getSourceFile ( ) . fileName ) . every ( fileName => fileName . indexOf ( `node_modules/${ moduleName }` ) !== - 1 ) ; } /**
 * Many design systems have declarations like
 *
 * ```ts
 * declare const Button: React.ComponentClass<ButtonProps & JSX.IntrinsicElements["button"]>
 * ```
 *
 * Which add hundreds of useless properties. This attempts to keep only those that are actually useful.
 */ export function isValidProperty ( symbol ) { if ( isDeclaredAt ( symbol , "@types/react" ) ) { const propertiesToInclude = new Set ( [ "disabled" , "placeholder" , "checked" ] ) ; return propertiesToInclude . has ( symbol . name ) ; } if ( symbol . name . indexOf ( "aria-" ) !== - 1 ) { return false ; } if ( ! /^[a-zA-Z]\w+$/ . test ( symbol . name ) ) { return false ; } return true ; }