UNPKG

2.59 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
11// Type definitions for babylon 6.16
12// Project: https://github.com/babel/babylon, https://babeljs.io
13// Definitions by: Troy Gerwien <https://github.com/yortus>
14// Marvin Hagemeister <https://github.com/marvinhagemeister>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16// TypeScript Version: 2.8
17
18import { File, Expression } from 'babel-types';
19
20export function parse(code: string, opts?: BabylonOptions): File;
21
22export function parseExpression(input: string, options?: BabylonOptions): Expression;
23
24export interface BabylonOptions {
25 /**
26 * By default, import and export declarations can only appear at a program's top level.
27 * Setting this option to true allows them anywhere where a statement is allowed.
28 */
29 allowImportExportEverywhere?: boolean | undefined;
30
31 /**
32 * By default, a return statement at the top level raises an error. Set this to true to accept such code.
33 */
34 allowReturnOutsideFunction?: boolean | undefined;
35
36 allowSuperOutsideMethod?: boolean | undefined;
37
38 /**
39 * Indicate the mode the code should be parsed in. Can be either "script" or "module".
40 */
41 sourceType?: 'script' | 'module' | undefined;
42
43 /**
44 * Correlate output AST nodes with their source filename. Useful when
45 * generating code and source maps from the ASTs of multiple input files.
46 */
47 sourceFilename?: string | undefined;
48
49 /**
50 * Array containing the plugins that you want to enable.
51 */
52 plugins?: PluginName[] | undefined;
53}
54
55export type PluginName =
56 'estree' |
57 'jsx' |
58 'flow' |
59 'typescript' |
60 'classConstructorCall' |
61 'doExpressions' |
62 'objectRestSpread' |
63 'decorators' |
64 'classProperties' |
65 'exportExtensions' |
66 'asyncGenerators' |
67 'functionBind' |
68 'functionSent' |
69 'dynamicImport';
70
71````
72
73### Additional Details
74 * Last updated: Tue, 06 Jul 2021 18:05:41 GMT
75 * Dependencies: [@types/babel-types](https://npmjs.com/package/@types/babel-types)
76 * Global values: none
77
78# Credits
79These definitions were written by [Troy Gerwien](https://github.com/yortus), and [Marvin Hagemeister](https://github.com/marvinhagemeister).
80
\No newline at end of file