You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
8.1 KiB

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