forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 3
/
babel-packages.js.flow
159 lines (144 loc) 路 4.45 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
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;
}