forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel-core.js.flow
175 lines (156 loc) Β· 4.54 KB
/
babel-core.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// @flow
declare module "@babel/core" {
import type { Node, File } from "@babel/types";
import type { Options as ParserOptions } from "@babel/parser";
import type {
Options as GeneratorOptions,
SourceMap,
} from "@babel/generator";
declare export type MatchPattern =
| string
| RegExp
| ((
filename: string | void,
context: {| callee: { name: string, ... } |} | void,
envName: string
) => boolean);
declare export type EntryTarget = string | any | Function;
declare export type EntryOptions = false | { ... };
declare export type Entry =
| EntryTarget
| [EntryTarget, EntryOptions]
| [EntryTarget, EntryOptions, string]
| ConfigItem;
declare type Options = {|
cwd?: string,
caller?: { name: string, ... },
filename?: string,
filenameRelative?: string,
code?: boolean,
ast?: boolean,
root?: string,
rootMode?: "root" | "upward" | "upward-optional",
envName?: string,
configFile?: string | boolean,
babelrc?: boolean,
babelrcRoots?: boolean | MatchPattern | Array<MatchPattern>,
plugins?: Array<Entry>,
presets?: Array<Entry>,
extends?: string,
env?: { [envKey: string]: Options, ... },
overrides?: Array<Options>,
test?: MatchPattern | Array<MatchPattern>,
include?: MatchPattern | Array<MatchPattern>,
exclude?: MatchPattern | Array<MatchPattern>,
ignore?: Array<MatchPattern>,
only?: Array<MatchPattern>,
inputSourceMap?: boolean | SourceMap,
sourceMaps?: boolean | "inline" | "both",
sourceFileName?: string,
sourceRoot?: string,
sourceType?: "script" | "module" | "unambiguous",
highlightCode?: boolean,
wrapPluginVisitorMethod?: (
key: string,
nodeType: string,
fn: Function
) => Function,
parserOpts?: ParserOptions,
generatorOpts?: GeneratorOptions,
retainLines?: boolean,
compact?: boolean | "auto",
minified?: boolean,
auxiliaryCommentBefore?: string,
auxiliaryCommentAfter?: string,
comments?: boolean,
shouldPrintComment?: (value: string) => boolean,
moduleIds?: boolean,
moduleId?: string,
getModuleId?: (name: string) => string,
moduleRoot?: string,
|};
declare type Result = {| code: string, map: ?SourceMap, ast: File |};
declare export function transform(
code: string,
options?: Options,
callback: (
Error,
typeof undefined
) => void | ((typeof undefined, Result) => void)
): void;
declare export function transformSync(
code: string,
options?: Options
): Result;
declare export function transformAsync(
code: string,
options?: Options
): Promise<Result>;
declare export function transformFile(
code: string,
options?: Options,
callback: (
Error,
typeof undefined
) => void | ((typeof undefined, Result) => void)
): void;
declare export function transformFileSync(
code: string,
options?: Options
): Result;
declare export function transformFileAsync(
code: string,
options?: Options
): Promise<Result>;
declare export function transformFromAst(
ast: Node,
code?: string,
options?: Options,
callback: (
Error,
typeof undefined
) => void | ((typeof undefined, Result) => void)
): void;
declare export function transformFromAstSync(
ast: Node,
code?: string,
options?: Options
): Result;
declare export function transformFromAstAsync(
ast: Node,
code?: string,
options?: Options
): Promise<Result>;
declare export function parse(
code: string,
options?: Options,
callback: (
Error,
typeof undefined
) => void | ((typeof undefined, File) => void)
): void;
declare export function parseSync(code: string, options?: Options): File;
declare export function parseAsync(
code: string,
options?: Options
): Promise<File>;
declare type ConfigItem = {|
value: { ... } | Function,
options: { ... } | void,
dirname: string,
name: string | void,
file: {| request: string, resolved: string |} | void,
|};
declare export function loadOptions(options?: Options): Options;
declare export function loadPartialConfig(options?: Object): any;
declare export function loadPartialConfigAsync(options?: Object): Promise<any>;
declare export function createConfigItem(
value:
| string
| { ... }
| Function
| [string | { ... } | Function, { ... } | void],
{| dirname?: string, type?: "preset" | "plugin" |}
): ConfigItem;
declare export * as types from "@babel/types";
}