/
babel-packages.js.flow
304 lines (269 loc) 路 7.84 KB
/
babel-packages.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
declare module "@babel/template" {
declare type PublicOpts = {
placeholderWhitelist?: ?Set<string>,
placeholderPattern?: ?(RegExp | false),
preserveComments?: ?boolean,
syntacticPlaceholders?: ?boolean,
};
declare type PublicReplacements = { [string]: mixed } | Array<mixed>;
declare type TemplateBuilder<T> = {
ast: {
(tpl: string, opts: ?PublicOpts): T,
(tpl: Array<string>, ...args: Array<mixed>): T,
},
(opts: PublicOpts): TemplateBuilder<T>,
(tpl: string, opts: ?PublicOpts): (?PublicReplacements) => T,
(tpl: Array<string>, ...args: Array<mixed>): (?PublicReplacements) => T,
};
declare type Smart = TemplateBuilder<
Array<BabelNodeStatement> | BabelNodeStatement
>;
declare type Statement = TemplateBuilder<BabelNodeStatement>;
declare type Statements = TemplateBuilder<Array<BabelNodeStatement>>;
declare type Expression = TemplateBuilder<BabelNodeExpression>;
declare type Program = TemplateBuilder<BabelNodeProgram>;
declare export default Smart & {
smart: Smart,
statement: Statement,
statements: Statements,
expression: Expression,
program: Program,
};
}
declare module "@babel/helper-optimise-call-expression" {
declare export default function optimiseCallExpression(
callee: BabelNodeExpression,
thisNode: BabelNodeExpression,
args: $ReadOnly<Array<BabelNodeExpression | BabelNodeSpreadElement>>,
optional: boolean
): BabelNodeCallExpression | BabelNodeOptionalCallExpression;
}
declare module "@babel/helper-get-function-arity" {
declare export default function helperGetFunctionArity(
node: BabelNodeFunction
): number;
}
declare module "@babel/helper-annotate-as-pure" {
declare export default function annotateAsPure(
pathOrNode:
| BabelNode
| {
node: BabelNode,
}
): void;
}
declare module "@babel/code-frame" {
declare type Location = {
column: number,
line: number,
};
declare type NodeLocation = {
end?: Location,
start: Location,
};
declare export interface Options {
/**
* Syntax highlight the code as JavaScript for terminals. default: false
*/
highlightCode?: boolean;
/**
* The number of lines to show above the error. default: 2
*/
linesAbove?: number;
/**
* The number of lines to show below the error. default: 3
*/
linesBelow?: number;
/**
* Forcibly syntax highlight the code as JavaScript (for non-terminals);
* overrides highlightCode.
* default: false
*/
forceColor?: boolean;
/**
* Pass in a string to be displayed inline (if possible) next to the
* highlighted location in the code. If it can't be positioned inline,
* it will be placed above the code frame.
* default: nothing
*/
message?: string;
}
declare export function codeFrameColumns(
rawLines: string,
loc: NodeLocation,
opts?: Options
): string;
/**
* Create a code frame, adding line numbers, code highlighting, and pointing to a given position.
*/
declare export default function codeFrame(
rawLines: string,
lineNumber: number,
colNumber?: number | null,
opts?: Options
): string;
}
declare module "@babel/helper-validator-identifier" {
declare function isReservedWord(word: string, inModule: boolean): boolean;
declare function isStrictReservedWord(
word: string,
inModule: boolean
): boolean;
declare function isStrictBindOnlyReservedWord(word: string): boolean;
declare function isStrictBindReservedWord(
word: string,
inModule: boolean
): boolean;
declare function isKeyword(word: string): boolean;
declare function isIdentifierStart(code: number): boolean;
declare function isIdentifierChar(code: number): boolean;
declare function isIdentifierName(name: string): boolean;
}
declare module "@babel/helper-validator-option" {
declare class OptionValidator {
descriptor: string;
constructor(descriptor: string): OptionValidator;
validateTopLevelOptions(options: Object, TopLevelOptionShape: Object): void;
validateBooleanOption<T>(
name: string,
value?: boolean,
defaultValue?: T
): boolean | T;
validateStringOption<T>(
name: string,
value?: string,
defaultValue?: T
): string | T;
invariant(condition: boolean, message: string): void;
formatMessage(message: string): string;
}
declare function findSuggestion(
str: string,
arr: $ReadOnlyArray<string>
): string;
}
declare module "@babel/helper-function-name" {
declare export default function helperFunctionNamefunction(
options: any,
localBinding?: boolean
): any;
}
declare module "@babel/helper-split-export-declaration" {
declare export default function splitExportDeclaration(
exportDeclaration: any
): any;
}
declare module "@babel/traverse" {
declare module.exports: any;
}
declare module "@babel/generator" {
declare module.exports: any;
}
declare module "@babel/highlight" {
import typeof { Chalk } from "chalk";
declare type Options = {
forceColor?: boolean,
};
/**
* Whether the code should be highlighted given the passed options.
*/
declare function shouldHighlight(options: Options): boolean;
/**
* The Chalk instance that should be used given the passed options.
*/
declare function getChalk(options: Options): Chalk;
/**
* Highlight `code`.
*/
declare export default function highlight(
code: string,
options?: Options
): string;
declare export { getChalk, shouldHighlight };
}
declare module "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" {
declare module.exports: any;
}
declare module "@babel/helper-module-transforms" {
declare module.exports: any;
}
declare module "@babel/plugin-transform-classes" {
declare module.exports: any;
}
declare module "@babel/helper-compilation-targets" {
declare module.exports: any;
}
declare module "@babel/helper-string-parser" {
declare export type StringContentsErrorHandlers = EscapedCharErrorHandlers & {
unterminated(
initialPos: number,
initialLineStart: number,
initialCurLine: number
): void,
};
declare export function readStringContents(
type: "single" | "double" | "template",
input: string,
pos: number,
lineStart: number,
curLine: number,
errors: StringContentsErrorHandlers
): {
pos: number,
str: string,
containsInvalid: boolean,
lineStart: number,
curLine: number,
};
declare export type EscapedCharErrorHandlers = HexCharErrorHandlers &
CodePointErrorHandlers & {
strictNumericEscape(pos: number): void,
};
declare export function readEscapedChar(
input: string,
pos: number,
lineStart: number,
curLine: number,
inTemplate: boolean,
errors: EscapedCharErrorHandlers
): {
pos: number,
ch: string | null,
lineStart: number,
curLine: number,
};
declare type HexCharErrorHandlers = IntErrorHandlers & {
invalidEscapeSequence(pos: number, startPos: number): void,
};
declare export type IntErrorHandlers = {
numericSeparatorInEscapeSequence(pos: number): void,
unexpectedNumericSeparator(pos: number): void,
// It can return "true" to indicate that the error was handled
// and the int parsing should continue.
invalidDigit(pos: number, radix: number): boolean,
};
declare export function readInt(
input: string,
pos: number,
radix: number,
len?: number,
forceLen: boolean,
allowNumSeparator: boolean | "bail",
errors: IntErrorHandlers
): {
n: null | number,
pos: number,
};
declare export type CodePointErrorHandlers = HexCharErrorHandlers & {
invalidCodePoint(pos: number): void,
};
declare export function readCodePoint(
input: string,
pos: number,
throwOnInvalid: boolean,
errors: CodePointErrorHandlers
): {
code: any,
pos: number,
};
}