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