typescript-estree
Version:
A parser that converts TypeScript source code into an ESTree compatible form
50 lines (49 loc) • 1.67 kB
TypeScript
/**
* @fileoverview Converts TypeScript AST into ESTree format.
* @author Nicholas C. Zakas
* @author James Henry <https://github.com/JamesHenry>
* @copyright jQuery Foundation and other contributors, https://jquery.org/
* MIT License
*/
import ts from 'typescript';
import { ESTreeNode } from './temp-types-based-on-js-source';
export declare function resetASTMaps(): void;
export declare function getASTMaps(): {
esTreeNodeToTSNodeMap: WeakMap<object, any>;
tsNodeToESTreeNodeMap: WeakMap<object, any>;
};
interface ConvertAdditionalOptions {
errorOnUnknownASTType: boolean;
useJSXTextNode: boolean;
shouldProvideParserServices: boolean;
}
interface ConvertConfig {
node: ts.Node;
parent?: ts.Node | null;
inTypeMode?: boolean;
allowPattern?: boolean;
ast: ts.SourceFile;
additionalOptions: ConvertAdditionalOptions;
}
/**
* Extends and formats a given error object
* @param {Object} error the error object
* @returns {Object} converted error object
*/
export declare function convertError(error: any): {
index: number;
lineNumber: number;
column: number;
message: string;
};
/**
* Converts a TypeScript node into an ESTree node
* @param {Object} config configuration options for the conversion
* @param {TSNode} config.node the ts.Node
* @param {ts.Node} config.parent the parent ts.Node
* @param {ts.SourceFile} config.ast the full TypeScript AST
* @param {Object} config.additionalOptions additional options for the conversion
* @returns {ESTreeNode|null} the converted ESTreeNode
*/
export default function convert(config: ConvertConfig): ESTreeNode | null;
export {};