UNPKG

1.52 kBTypeScriptView Raw
1import { Expression, File } from "babel-types";
2
3export function parse(code: string, opts?: BabylonOptions): File;
4
5export function parseExpression(input: string, options?: BabylonOptions): Expression;
6
7export interface BabylonOptions {
8 /**
9 * By default, import and export declarations can only appear at a program's top level.
10 * Setting this option to true allows them anywhere where a statement is allowed.
11 */
12 allowImportExportEverywhere?: boolean | undefined;
13
14 /**
15 * By default, a return statement at the top level raises an error. Set this to true to accept such code.
16 */
17 allowReturnOutsideFunction?: boolean | undefined;
18
19 allowSuperOutsideMethod?: boolean | undefined;
20
21 /**
22 * Indicate the mode the code should be parsed in. Can be either "script" or "module".
23 */
24 sourceType?: "script" | "module" | undefined;
25
26 /**
27 * Correlate output AST nodes with their source filename. Useful when
28 * generating code and source maps from the ASTs of multiple input files.
29 */
30 sourceFilename?: string | undefined;
31
32 /**
33 * Array containing the plugins that you want to enable.
34 */
35 plugins?: PluginName[] | undefined;
36}
37
38export type PluginName =
39 | "estree"
40 | "jsx"
41 | "flow"
42 | "typescript"
43 | "classConstructorCall"
44 | "doExpressions"
45 | "objectRestSpread"
46 | "decorators"
47 | "classProperties"
48 | "exportExtensions"
49 | "asyncGenerators"
50 | "functionBind"
51 | "functionSent"
52 | "dynamicImport";