UNPKG

2.23 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/babylon`
3
4# Summary
5This package contains type definitions for babylon (https://github.com/babel/babylon).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babylon.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babylon/index.d.ts)
10````ts
11import { Expression, File } from "babel-types";
12
13export function parse(code: string, opts?: BabylonOptions): File;
14
15export function parseExpression(input: string, options?: BabylonOptions): Expression;
16
17export interface BabylonOptions {
18 /**
19 * By default, import and export declarations can only appear at a program's top level.
20 * Setting this option to true allows them anywhere where a statement is allowed.
21 */
22 allowImportExportEverywhere?: boolean | undefined;
23
24 /**
25 * By default, a return statement at the top level raises an error. Set this to true to accept such code.
26 */
27 allowReturnOutsideFunction?: boolean | undefined;
28
29 allowSuperOutsideMethod?: boolean | undefined;
30
31 /**
32 * Indicate the mode the code should be parsed in. Can be either "script" or "module".
33 */
34 sourceType?: "script" | "module" | undefined;
35
36 /**
37 * Correlate output AST nodes with their source filename. Useful when
38 * generating code and source maps from the ASTs of multiple input files.
39 */
40 sourceFilename?: string | undefined;
41
42 /**
43 * Array containing the plugins that you want to enable.
44 */
45 plugins?: PluginName[] | undefined;
46}
47
48export type PluginName =
49 | "estree"
50 | "jsx"
51 | "flow"
52 | "typescript"
53 | "classConstructorCall"
54 | "doExpressions"
55 | "objectRestSpread"
56 | "decorators"
57 | "classProperties"
58 | "exportExtensions"
59 | "asyncGenerators"
60 | "functionBind"
61 | "functionSent"
62 | "dynamicImport";
63
64````
65
66### Additional Details
67 * Last updated: Mon, 06 Nov 2023 22:41:04 GMT
68 * Dependencies: [@types/babel-types](https://npmjs.com/package/@types/babel-types)
69
70# Credits
71These definitions were written by [Troy Gerwien](https://github.com/yortus), and [Marvin Hagemeister](https://github.com/marvinhagemeister).
72
\No newline at end of file