1 | // This file is auto-generated! Do not modify it directly.
|
---|
2 | /* eslint-disable @typescript-eslint/consistent-type-imports, @typescript-eslint/no-redundant-type-constituents */
|
---|
3 | import * as _babel_types from '@babel/types';
|
---|
4 |
|
---|
5 | type BABEL_8_BREAKING = false;
|
---|
6 | type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never;
|
---|
7 |
|
---|
8 | type Plugin =
|
---|
9 | | "asyncDoExpressions"
|
---|
10 | | IF_BABEL_7<"asyncGenerators">
|
---|
11 | | IF_BABEL_7<"bigInt">
|
---|
12 | | IF_BABEL_7<"classPrivateMethods">
|
---|
13 | | IF_BABEL_7<"classPrivateProperties">
|
---|
14 | | IF_BABEL_7<"classProperties">
|
---|
15 | | IF_BABEL_7<"classStaticBlock">
|
---|
16 | | IF_BABEL_7<"decimal">
|
---|
17 | | "decorators-legacy"
|
---|
18 | | "deferredImportEvaluation"
|
---|
19 | | "decoratorAutoAccessors"
|
---|
20 | | "destructuringPrivate"
|
---|
21 | | "deprecatedImportAssert"
|
---|
22 | | "doExpressions"
|
---|
23 | | IF_BABEL_7<"dynamicImport">
|
---|
24 | | "explicitResourceManagement"
|
---|
25 | | "exportDefaultFrom"
|
---|
26 | | IF_BABEL_7<"exportNamespaceFrom">
|
---|
27 | | "flow"
|
---|
28 | | "flowComments"
|
---|
29 | | "functionBind"
|
---|
30 | | "functionSent"
|
---|
31 | | "importMeta"
|
---|
32 | | "jsx"
|
---|
33 | | IF_BABEL_7<"jsonStrings">
|
---|
34 | | IF_BABEL_7<"logicalAssignment">
|
---|
35 | | IF_BABEL_7<"importAssertions">
|
---|
36 | | IF_BABEL_7<"importReflection">
|
---|
37 | | "moduleBlocks"
|
---|
38 | | IF_BABEL_7<"moduleStringNames">
|
---|
39 | | IF_BABEL_7<"nullishCoalescingOperator">
|
---|
40 | | IF_BABEL_7<"numericSeparator">
|
---|
41 | | IF_BABEL_7<"objectRestSpread">
|
---|
42 | | IF_BABEL_7<"optionalCatchBinding">
|
---|
43 | | IF_BABEL_7<"optionalChaining">
|
---|
44 | | "partialApplication"
|
---|
45 | | "placeholders"
|
---|
46 | | IF_BABEL_7<"privateIn">
|
---|
47 | | IF_BABEL_7<"regexpUnicodeSets">
|
---|
48 | | "sourcePhaseImports"
|
---|
49 | | "throwExpressions"
|
---|
50 | | IF_BABEL_7<"topLevelAwait">
|
---|
51 | | "v8intrinsic"
|
---|
52 | | ParserPluginWithOptions[0];
|
---|
53 |
|
---|
54 | type ParserPluginWithOptions =
|
---|
55 | | ["decorators", DecoratorsPluginOptions]
|
---|
56 | | ["estree", { classFeatures?: boolean }]
|
---|
57 | | IF_BABEL_7<["importAttributes", { deprecatedAssertSyntax: boolean }]>
|
---|
58 | | IF_BABEL_7<["moduleAttributes", { version: "may-2020" }]>
|
---|
59 | | ["optionalChainingAssign", { version: "2023-07" }]
|
---|
60 | | ["pipelineOperator", PipelineOperatorPluginOptions]
|
---|
61 | | ["recordAndTuple", RecordAndTuplePluginOptions]
|
---|
62 | | ["flow", FlowPluginOptions]
|
---|
63 | | ["typescript", TypeScriptPluginOptions];
|
---|
64 |
|
---|
65 | type PluginConfig = Plugin | ParserPluginWithOptions;
|
---|
66 |
|
---|
67 | interface DecoratorsPluginOptions {
|
---|
68 | decoratorsBeforeExport?: boolean;
|
---|
69 | allowCallParenthesized?: boolean;
|
---|
70 | }
|
---|
71 |
|
---|
72 | interface PipelineOperatorPluginOptions {
|
---|
73 | proposal: BABEL_8_BREAKING extends false
|
---|
74 | ? "minimal" | "fsharp" | "hack" | "smart"
|
---|
75 | : "fsharp" | "hack";
|
---|
76 | topicToken?: "%" | "#" | "@@" | "^^" | "^";
|
---|
77 | }
|
---|
78 |
|
---|
79 | interface RecordAndTuplePluginOptions {
|
---|
80 | syntaxType: "bar" | "hash";
|
---|
81 | }
|
---|
82 |
|
---|
83 | type FlowPluginOptions = BABEL_8_BREAKING extends true
|
---|
84 | ? {
|
---|
85 | all?: boolean;
|
---|
86 | enums?: boolean;
|
---|
87 | }
|
---|
88 | : {
|
---|
89 | all?: boolean;
|
---|
90 | };
|
---|
91 |
|
---|
92 | interface TypeScriptPluginOptions {
|
---|
93 | dts?: boolean;
|
---|
94 | disallowAmbiguousJSXLike?: boolean;
|
---|
95 | }
|
---|
96 |
|
---|
97 | // Type definitions for @babel/parser
|
---|
98 | // Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
---|
99 | // Definitions by: Troy Gerwien <https://github.com/yortus>
|
---|
100 | // Marvin Hagemeister <https://github.com/marvinhagemeister>
|
---|
101 | // Avi Vahl <https://github.com/AviVahl>
|
---|
102 | // TypeScript Version: 2.9
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Parse the provided code as an entire ECMAScript program.
|
---|
106 | */
|
---|
107 | declare function parse(
|
---|
108 | input: string,
|
---|
109 | options?: ParserOptions
|
---|
110 | ): ParseResult<_babel_types.File>;
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Parse the provided code as a single expression.
|
---|
114 | */
|
---|
115 | declare function parseExpression(
|
---|
116 | input: string,
|
---|
117 | options?: ParserOptions
|
---|
118 | ): ParseResult<_babel_types.Expression>;
|
---|
119 |
|
---|
120 | interface ParserOptions {
|
---|
121 | /**
|
---|
122 | * By default, import and export declarations can only appear at a program's top level.
|
---|
123 | * Setting this option to true allows them anywhere where a statement is allowed.
|
---|
124 | */
|
---|
125 | allowImportExportEverywhere?: boolean;
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * By default, await use is not allowed outside of an async function.
|
---|
129 | * Set this to true to accept such code.
|
---|
130 | */
|
---|
131 | allowAwaitOutsideFunction?: boolean;
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * By default, a return statement at the top level raises an error.
|
---|
135 | * Set this to true to accept such code.
|
---|
136 | */
|
---|
137 | allowReturnOutsideFunction?: boolean;
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * By default, new.target use is not allowed outside of a function or class.
|
---|
141 | * Set this to true to accept such code.
|
---|
142 | */
|
---|
143 | allowNewTargetOutsideFunction?: boolean;
|
---|
144 |
|
---|
145 | allowSuperOutsideMethod?: boolean;
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * By default, exported identifiers must refer to a declared variable.
|
---|
149 | * Set this to true to allow export statements to reference undeclared variables.
|
---|
150 | */
|
---|
151 | allowUndeclaredExports?: boolean;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * By default, Babel parser JavaScript code according to Annex B syntax.
|
---|
155 | * Set this to `false` to disable such behavior.
|
---|
156 | */
|
---|
157 | annexB?: boolean;
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * By default, Babel attaches comments to adjacent AST nodes.
|
---|
161 | * When this option is set to false, comments are not attached.
|
---|
162 | * It can provide up to 30% performance improvement when the input code has many comments.
|
---|
163 | * @babel/eslint-parser will set it for you.
|
---|
164 | * It is not recommended to use attachComment: false with Babel transform,
|
---|
165 | * as doing so removes all the comments in output code, and renders annotations such as
|
---|
166 | * /* istanbul ignore next *\/ nonfunctional.
|
---|
167 | */
|
---|
168 | attachComment?: boolean;
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * By default, Babel always throws an error when it finds some invalid code.
|
---|
172 | * When this option is set to true, it will store the parsing error and
|
---|
173 | * try to continue parsing the invalid input file.
|
---|
174 | */
|
---|
175 | errorRecovery?: boolean;
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Indicate the mode the code should be parsed in.
|
---|
179 | * Can be one of "script", "module", or "unambiguous". Defaults to "script".
|
---|
180 | * "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
---|
181 | * of ES6 import or export statements.
|
---|
182 | * Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
---|
183 | */
|
---|
184 | sourceType?: "script" | "module" | "unambiguous";
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Correlate output AST nodes with their source filename.
|
---|
188 | * Useful when generating code and source maps from the ASTs of multiple input files.
|
---|
189 | */
|
---|
190 | sourceFilename?: string;
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * By default, all source indexes start from 0.
|
---|
194 | * You can provide a start index to alternatively start with.
|
---|
195 | * Useful for integration with other source tools.
|
---|
196 | */
|
---|
197 | startIndex?: number;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * By default, the first line of code parsed is treated as line 1.
|
---|
201 | * You can provide a line number to alternatively start with.
|
---|
202 | * Useful for integration with other source tools.
|
---|
203 | */
|
---|
204 | startLine?: number;
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * By default, the parsed code is treated as if it starts from line 1, column 0.
|
---|
208 | * You can provide a column number to alternatively start with.
|
---|
209 | * Useful for integration with other source tools.
|
---|
210 | */
|
---|
211 | startColumn?: number;
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * Array containing the plugins that you want to enable.
|
---|
215 | */
|
---|
216 | plugins?: ParserPlugin[];
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * Should the parser work in strict mode.
|
---|
220 | * Defaults to true if sourceType === 'module'. Otherwise, false.
|
---|
221 | */
|
---|
222 | strictMode?: boolean;
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * Adds a ranges property to each node: [node.start, node.end]
|
---|
226 | */
|
---|
227 | ranges?: boolean;
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * Adds all parsed tokens to a tokens property on the File node.
|
---|
231 | */
|
---|
232 | tokens?: boolean;
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * By default, the parser adds information about parentheses by setting
|
---|
236 | * `extra.parenthesized` to `true` as needed.
|
---|
237 | * When this option is `true` the parser creates `ParenthesizedExpression`
|
---|
238 | * AST nodes instead of using the `extra` property.
|
---|
239 | */
|
---|
240 | createParenthesizedExpressions?: boolean;
|
---|
241 |
|
---|
242 | /**
|
---|
243 | * The default is false in Babel 7 and true in Babel 8
|
---|
244 | * Set this to true to parse it as an `ImportExpression` node.
|
---|
245 | * Otherwise `import(foo)` is parsed as `CallExpression(Import, [Identifier(foo)])`.
|
---|
246 | */
|
---|
247 | createImportExpressions?: boolean;
|
---|
248 | }
|
---|
249 |
|
---|
250 | type ParserPlugin = PluginConfig;
|
---|
251 |
|
---|
252 |
|
---|
253 | declare const tokTypes: {
|
---|
254 | // todo(flow->ts) real token type
|
---|
255 | [name: string]: any;
|
---|
256 | };
|
---|
257 |
|
---|
258 | interface ParseError {
|
---|
259 | code: string;
|
---|
260 | reasonCode: string;
|
---|
261 | }
|
---|
262 |
|
---|
263 | type ParseResult<Result> = Result & {
|
---|
264 | errors: ParseError[];
|
---|
265 | };
|
---|
266 |
|
---|
267 | export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes };
|
---|