UNPKG

1.52 kBTypeScriptView Raw
1import * as types from "ast-types";
2import { parse } from "./lib/parser";
3import { Options } from "./lib/options";
4export {
5/**
6 * Parse a string of code into an augmented syntax tree suitable for
7 * arbitrary modification and reprinting.
8 */
9parse,
10/**
11 * Convenient shorthand for the ast-types package.
12 */
13types, };
14/**
15 * Traverse and potentially modify an abstract syntax tree using a
16 * convenient visitor syntax:
17 *
18 * recast.visit(ast, {
19 * names: [],
20 * visitIdentifier: function(path) {
21 * var node = path.value;
22 * this.visitor.names.push(node.name);
23 * this.traverse(path);
24 * }
25 * });
26 */
27export { visit } from "ast-types";
28/**
29 * Options shared between parsing and printing.
30 */
31export { Options } from "./lib/options";
32/**
33 * Reprint a modified syntax tree using as much of the original source
34 * code as possible.
35 */
36export declare function print(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
37/**
38 * Print without attempting to reuse any original source code.
39 */
40export declare function prettyPrint(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
41/**
42 * Convenient command-line interface (see e.g. example/add-braces).
43 */
44export declare function run(transformer: Transformer, options?: RunOptions): void;
45export interface Transformer {
46 (ast: types.ASTNode, callback: (ast: types.ASTNode) => void): void;
47}
48export interface RunOptions extends Options {
49 writeback?(code: string): void;
50}