import astTypes = require("ast-types"); import nodePath = require("ast-types/lib/node-path"); import Collection = require("../Collection"); type ASTPath = nodePath.NodePath; type JSXElement = astTypes.namedTypes.JSXElement; export interface GlobalMethods { /** * Finds all JSXElements optionally filtered by name */ findJSXElements(name?: string): Collection.Collection; /** * Finds all JSXElements by module name. Given * * var Bar = require('Foo'); * * * findJSXElementsByModuleName('Foo') will find , without having to * know the variable name. */ findJSXElementsByModuleName(moduleName: string): Collection.Collection; } type Defined = T extends undefined ? never : T; type JSXElementChild = Defined[0]; export interface TraversalMethods { /** * Returns all child nodes, including literals and expressions. * This method only applies to JSXElement typed collections. */ childNodes(): Collection.Collection; /** * Returns all children that are JSXElements. * This method only applies to JSXElement typed collections. */ childElements(): Collection.Collection; } interface Filter { (path: ASTPath): boolean; } export interface FilterMethods { /** * Filter method for attributes. */ hasAttributes(attributeFilter: { [attributeName: string]: any }): Filter; /** * Filter elements which contain a specific child type */ hasChildren(name: string): Filter; } export interface MappingMethods { /** * Given a JSXElement, returns its "root" name. E.g. it would return "Foo" for * both and . */ getRootName(path: ASTPath): string; } export function register(): void; export const filters: FilterMethods; export const mappings: MappingMethods; export {}; // shut off automatic exporting