getMemberValuePath.d.ts 1.3 KB

1234567891011121314151617181920
  1. import type { NodePath } from '@babel/traverse';
  2. import type { CallExpression, ClassDeclaration, ClassExpression, ClassMethod, Expression, ObjectExpression, ObjectMethod, TaggedTemplateExpression, VariableDeclaration } from '@babel/types';
  3. import type { StatelessComponentNode } from '../resolver/index.js';
  4. type SupportedNodes = CallExpression | ClassDeclaration | ClassExpression | ObjectExpression | StatelessComponentNode | TaggedTemplateExpression | VariableDeclaration;
  5. export declare function isSupportedDefinitionType(path: NodePath): path is NodePath<SupportedNodes>;
  6. /**
  7. * This is a helper method for handlers to make it easier to work either with
  8. * an ObjectExpression from `React.createClass` class or with a class
  9. * definition.
  10. *
  11. * Given a path and a name, this function will either return the path of the
  12. * property value if the path is an ObjectExpression, or the value of the
  13. * ClassProperty/MethodDefinition if it is a class definition (declaration or
  14. * expression).
  15. *
  16. * It also normalizes the names so that e.g. `defaultProps` and
  17. * `getDefaultProps` can be used interchangeably.
  18. */
  19. export default function getMemberValuePath(componentDefinition: NodePath<SupportedNodes>, memberName: string): NodePath<ClassMethod | Expression | ObjectMethod> | null;
  20. export {};