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