|
|
|
|
|
|
|
|
|
|
|
import { File, Expression } from '@babel/types'; |
|
|
|
|
|
declare class Position { |
|
|
line: number; |
|
|
column: number; |
|
|
index: number; |
|
|
constructor(line: number, col: number, index: number); |
|
|
} |
|
|
|
|
|
type SyntaxPlugin = "flow" | "typescript" | "jsx" | "pipelineOperator" | "placeholders"; |
|
|
type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"; |
|
|
interface ParseErrorSpecification<ErrorDetails> { |
|
|
code: ParseErrorCode; |
|
|
reasonCode: string; |
|
|
syntaxPlugin?: SyntaxPlugin; |
|
|
missingPlugin?: string | string[]; |
|
|
loc: Position; |
|
|
details: ErrorDetails; |
|
|
pos: number; |
|
|
} |
|
|
type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>; |
|
|
|
|
|
type BABEL_8_BREAKING = false; |
|
|
type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never; |
|
|
|
|
|
type Plugin$1 = |
|
|
| "asyncDoExpressions" |
|
|
| IF_BABEL_7<"asyncGenerators"> |
|
|
| IF_BABEL_7<"bigInt"> |
|
|
| IF_BABEL_7<"classPrivateMethods"> |
|
|
| IF_BABEL_7<"classPrivateProperties"> |
|
|
| IF_BABEL_7<"classProperties"> |
|
|
| IF_BABEL_7<"classStaticBlock"> |
|
|
| IF_BABEL_7<"decimal"> |
|
|
| "decorators-legacy" |
|
|
| "deferredImportEvaluation" |
|
|
| "decoratorAutoAccessors" |
|
|
| "destructuringPrivate" |
|
|
| "deprecatedImportAssert" |
|
|
| "doExpressions" |
|
|
| IF_BABEL_7<"dynamicImport"> |
|
|
| IF_BABEL_7<"explicitResourceManagement"> |
|
|
| "exportDefaultFrom" |
|
|
| IF_BABEL_7<"exportNamespaceFrom"> |
|
|
| "flow" |
|
|
| "flowComments" |
|
|
| "functionBind" |
|
|
| "functionSent" |
|
|
| "importMeta" |
|
|
| "jsx" |
|
|
| IF_BABEL_7<"jsonStrings"> |
|
|
| IF_BABEL_7<"logicalAssignment"> |
|
|
| IF_BABEL_7<"importAssertions"> |
|
|
| IF_BABEL_7<"importReflection"> |
|
|
| "moduleBlocks" |
|
|
| IF_BABEL_7<"moduleStringNames"> |
|
|
| IF_BABEL_7<"nullishCoalescingOperator"> |
|
|
| IF_BABEL_7<"numericSeparator"> |
|
|
| IF_BABEL_7<"objectRestSpread"> |
|
|
| IF_BABEL_7<"optionalCatchBinding"> |
|
|
| IF_BABEL_7<"optionalChaining"> |
|
|
| "partialApplication" |
|
|
| "placeholders" |
|
|
| IF_BABEL_7<"privateIn"> |
|
|
| IF_BABEL_7<"regexpUnicodeSets"> |
|
|
| "sourcePhaseImports" |
|
|
| "throwExpressions" |
|
|
| IF_BABEL_7<"topLevelAwait"> |
|
|
| "v8intrinsic" |
|
|
| ParserPluginWithOptions[0]; |
|
|
|
|
|
type ParserPluginWithOptions = |
|
|
| ["decorators", DecoratorsPluginOptions] |
|
|
| ["discardBinding", { syntaxType: "void" }] |
|
|
| ["estree", { classFeatures?: boolean }] |
|
|
| IF_BABEL_7<["importAttributes", { deprecatedAssertSyntax: boolean }]> |
|
|
| IF_BABEL_7<["moduleAttributes", { version: "may-2020" }]> |
|
|
| ["optionalChainingAssign", { version: "2023-07" }] |
|
|
| ["pipelineOperator", PipelineOperatorPluginOptions] |
|
|
| ["recordAndTuple", RecordAndTuplePluginOptions] |
|
|
| ["flow", FlowPluginOptions] |
|
|
| ["typescript", TypeScriptPluginOptions]; |
|
|
|
|
|
type PluginConfig = Plugin$1 | ParserPluginWithOptions; |
|
|
|
|
|
interface DecoratorsPluginOptions { |
|
|
decoratorsBeforeExport?: boolean; |
|
|
allowCallParenthesized?: boolean; |
|
|
} |
|
|
|
|
|
interface PipelineOperatorPluginOptions { |
|
|
proposal: BABEL_8_BREAKING extends false |
|
|
? "minimal" | "fsharp" | "hack" | "smart" |
|
|
: "fsharp" | "hack"; |
|
|
topicToken?: "%" | "#" | "@@" | "^^" | "^"; |
|
|
} |
|
|
|
|
|
interface RecordAndTuplePluginOptions { |
|
|
syntaxType: "bar" | "hash"; |
|
|
} |
|
|
|
|
|
type FlowPluginOptions = BABEL_8_BREAKING extends true |
|
|
? { |
|
|
all?: boolean; |
|
|
enums?: boolean; |
|
|
} |
|
|
: { |
|
|
all?: boolean; |
|
|
}; |
|
|
|
|
|
interface TypeScriptPluginOptions { |
|
|
dts?: boolean; |
|
|
disallowAmbiguousJSXLike?: boolean; |
|
|
} |
|
|
|
|
|
type Plugin = PluginConfig; |
|
|
|
|
|
type SourceType = "script" | "commonjs" | "module" | "unambiguous"; |
|
|
interface Options { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowImportExportEverywhere?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowAwaitOutsideFunction?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowReturnOutsideFunction?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowNewTargetOutsideFunction?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowSuperOutsideMethod?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowUndeclaredExports?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowYieldOutsideFunction?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
annexB?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attachComment?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errorRecovery?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sourceType?: SourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sourceFilename?: string; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startIndex?: number; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startLine?: number; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startColumn?: number; |
|
|
|
|
|
|
|
|
|
|
|
plugins?: Plugin[]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strictMode?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
ranges?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
tokens?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createParenthesizedExpressions?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createImportExpressions?: boolean; |
|
|
} |
|
|
|
|
|
type ParserOptions = Partial<Options>; |
|
|
type ParseError = ParseError$1<object>; |
|
|
type ParseResult<Result extends File | Expression = File> = Result & { |
|
|
comments: File["comments"]; |
|
|
errors: null | ParseError[]; |
|
|
tokens?: File["tokens"]; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
declare function parse(input: string, options?: ParserOptions): ParseResult<File>; |
|
|
declare function parseExpression(input: string, options?: ParserOptions): ParseResult<Expression>; |
|
|
|
|
|
declare const tokTypes: { |
|
|
|
|
|
[name: string]: any; |
|
|
}; |
|
|
|
|
|
export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, PluginConfig as ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes }; |
|
|
|