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