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