1 import * as ts from 'typescript';
\r
2 /** Wraps an AST node. Can be used as a tree using `children` or a linked list using `next` and `skip`. */
\r
3 export interface NodeWrap {
\r
4 /** The real AST node. */
\r
6 /** The SyntaxKind of `node`. */
\r
8 /** All immediate children of `node` that would be visited by `ts.forEachChild(node, cb)`. */
\r
9 children: NodeWrap[];
\r
10 /** Link to the next NodeWrap, depth-first. */
\r
12 /** Link to the next NodeWrap skipping all children of the current node. */
\r
14 /** Link to the parent NodeWrap */
\r
17 export interface WrappedAst extends NodeWrap {
\r
18 node: ts.SourceFile;
\r
23 export interface ConvertedAst {
\r
24 /** nodes wrapped in a data structure with useful links */
\r
25 wrapped: WrappedAst;
\r
26 /** depth-first array of all nodes excluding SourceFile */
\r
27 flat: ReadonlyArray<ts.Node>;
\r
30 * Takes a `ts.SourceFile` and creates data structures that are easier (or more performant) to traverse.
\r
31 * Note that there is only a performance gain if you can reuse these structures. It's not recommended for one-time AST walks.
\r
33 export declare function convertAst(sourceFile: ts.SourceFile): ConvertedAst;
\r