[babel 8] Use @babel/types for parser's return type#17117
[babel 8] Use @babel/types for parser's return type#17117nicolo-ribaudo merged 3 commits intobabel:mainfrom
@babel/types for parser's return type#17117Conversation
| @@ -1,177 +1,24 @@ | |||
| // Type definitions for @babel/parser | |||
There was a problem hiding this comment.
I left this file here to avoid accidental breaking changes, but now it's just re-exporting form the source.
17d82a2 to
12ab4f0
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58687 |
60a0832 to
212c282
Compare
| }; | ||
|
|
||
| export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes }; | ||
| export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, PluginConfig as ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes }; |
There was a problem hiding this comment.
Note: the difference in these two lines is that before it contained , ParserPlugin,, while after it contains , PluginConfig as ParserPlugin,.
| interface ParseError { | ||
| code: string; | ||
| reasonCode: string; | ||
| } | ||
|
|
||
| type ParseResult<Result> = Result & { | ||
| errors: ParseError[]; | ||
| }; | ||
|
|
There was a problem hiding this comment.
These two are just moved above.
| options?: ParserOptions | ||
| ): ParseResult<_babel_types.Expression>; | ||
|
|
||
| interface ParserOptions { |
There was a problem hiding this comment.
This is also just moved above (and renamed, but then the export keeps the old name).
|
I'll merge this, release a new 8.0.0 alpha, play around with it, and see if we are finally ready for the beta :) |
In Babel 7 we are already using
@babel/typesin@babel/parser/typings/babel-parser.ts. However, Babel 8 usespackage.json#exportsthus that file is ignored.By casting the type to the proper AST types in the
parse()function itself, we can also use the@babel/typesdefinitions in:One day we can actually de-duplicate the definitions, but it's a lot of work and it can wait :)