FindExportedDefinitionsResolver.d.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import type FileState from '../FileState.js';
  2. import type { ComponentNodePath, ResolverClass } from './index.js';
  3. interface FindExportedDefinitionsResolverOptions {
  4. limit?: number;
  5. }
  6. /**
  7. * Given an AST, this function tries to find the exported component definitions.
  8. *
  9. * The component definitions are either the ObjectExpression passed to
  10. * `React.createClass` or a `class` definition extending `React.Component` or
  11. * having a `render()` method.
  12. *
  13. * If a definition is part of the following statements, it is considered to be
  14. * exported:
  15. *
  16. * modules.exports = Definition;
  17. * exports.foo = Definition;
  18. * export default Definition;
  19. * export var Definition = ...;
  20. *
  21. * limit can be used to limit the components to be found. When the limit is reached an error will be thrown
  22. */
  23. export default class FindExportedDefinitionsResolver implements ResolverClass {
  24. limit: number;
  25. constructor({ limit }?: FindExportedDefinitionsResolverOptions);
  26. resolve(file: FileState): ComponentNodePath[];
  27. }
  28. export {};