forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.js.flow
135 lines (126 loc) · 3.76 KB
/
babel.js.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
type _SourceMap = {
version: number,
file?: string,
sources: Array<string>,
names: Array<string>,
mappings: string,
sourcesContent?: Array<string>,
};
// based on babylon v6.13.1
type BabylonOptions = {
allowImportExportEverywhere?: boolean,
allowReturnOutsideFunction?: boolean,
allowSuperOutsideMethod?: boolean,
sourceType?: 'script' | 'module',
sourceFilename?: 'string',
plugins?: Array<
'jsx' | 'flow' | 'doExpressions' | 'objectRestSpread' | 'decorators' |
'classProperties' | 'exportExtensions' | 'asyncGenerators' |
'functionBind' | 'functionSent' | 'dynamicImport'
>,
};
// based on babel-generator v6.18.0
type GeneratorOptions = {
auxiliaryCommentBefore?: string,
auxiliaryCommentAfter?: string,
shouldPrintComment?: (comment: string) => boolean,
retainLines?: boolean,
retainFunctionParens?: boolean,
comments?: boolean,
compact?: boolean | 'auto',
minified?: boolean,
concise?: boolean,
quotes?: 'single' | 'double',
filename?: string,
sourceMaps?: boolean,
sourceMapTarget?: string,
sourceRoot?: string,
sourceFileName?: string,
};
type InlinePlugin = string | {} | () => {};
// based on https://babeljs.io/docs/usage/options/ -- 2016-11-11
type __TransformOptions = {
filename?: string,
filenameRelative?: string,
presets?: Array<string | Object>,
plugins?: Array<string | Object | [InlinePlugin] | [InlinePlugin, mixed]>,
parserOpts?: BabylonOptions,
generatorOpts?: GeneratorOptions,
highlightCode?: boolean,
only?: string | RegExp | Array<string | RegExp>,
ignore?: string | RegExp | Array<string | RegExp>,
auxiliaryCommentBefore?: boolean,
auxiliaryCommentAfter?: boolean,
sourceMaps?: boolean,
inputSourceMap?: ?Object,
sourceMapTarget?: string,
sourceFileName?: string,
sourceRoot?: string,
moduleRoot?: string,
moduleIds?: boolean,
moduleId?: string,
getModuleId?: (moduleName: string) => string,
resolveModuleSource?: (source: string, filename: string) => string,
code?: boolean,
babelrc?: boolean,
ast?: boolean,
compact?: boolean | 'auto',
minified?: boolean,
comments?: boolean,
shouldPrintComment?: (comment: string) => boolean,
retainLines?: boolean,
extends?: string,
};
type _TransformOptions =
__TransformOptions & {env?: {[key: string]: __TransformOptions}};
declare class _Ast {}
type TransformResult = {
ast: _Ast,
code: ?string,
map: ?_SourceMap,
};
type VisitFn = <State>(path: Object, state: State) => any;
declare module 'babel-core' {
declare type SourceMap = _SourceMap;
declare type Ast = _Ast;
declare type TransformOptions = _TransformOptions;
declare function transform(
code: string,
options?: _TransformOptions,
): TransformResult;
declare function traverse<State>(
ast: _Ast,
visitor: {[key: string]: VisitFn<State> |
{enter?: VisitFn<State>, exit?: VisitFn<State>}},
scope?: ?Object,
state?: State,
parentPath?: ?Object,
): void;
declare var types: {[key: string]: Function};
declare function transformFromAst(
ast: _Ast,
code?: ?string,
babelOptions?: _TransformOptions,
): TransformResult;
}
type RawMapping = {
generated: {column: number, line: number},
name?: string,
original?: {column: number, line: number},
source?: string,
};
declare module 'babel-generator' {
declare type RawMapping = RawMapping;
declare function exports(
ast: _Ast,
options?: GeneratorOptions,
): TransformResult & {rawMappings: ?Array<RawMapping>};
}