-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all missing babel-core
option properties and alphabetize for better maintainability.
#19428
Changes from 1 commit
1b92e6a
721f420
012dc2a
061825f
a2f49b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,12 @@ export { t as types }; | |
export type Node = t.Node; | ||
export import template = require('babel-template'); | ||
export const version: string; | ||
import traverse, { Visitor } from "babel-traverse"; | ||
import traverse, { Visitor, NodePath } from "babel-traverse"; | ||
export { traverse, Visitor }; | ||
import { BabylonOptions } from "babylon"; | ||
export { BabylonOptions }; | ||
import { GeneratorOptions } from "babel-generator"; | ||
export { GeneratorOptions }; | ||
|
||
// A babel plugin is a simple function which must return an object matching | ||
// the following interface. Babel will throw if it finds unknown properties. | ||
|
@@ -40,7 +42,6 @@ export function transformFileSync(filename: string, opts?: TransformOptions): Ba | |
export function transformFromAst(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult; | ||
|
||
export interface TransformOptions { | ||
|
||
/** Include the AST in the returned object. Default: `true`. */ | ||
ast?: boolean; | ||
|
||
|
@@ -164,8 +165,7 @@ export interface TransformOptions { | |
/** An optional callback that can be used to wrap visitor methods. | ||
* NOTE: This is useful for things like introspection, and not really needed for implementing anything. | ||
*/ | ||
wrapPluginVisitorMethod?(pluginAlias: string, visitorType: string, callback: Function): Function; | ||
|
||
wrapPluginVisitorMethod?(pluginAlias: string, visitorType: string, callback: (path: any, state: any) => void): (path: any, state: any) => void ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's why the parent type should be used - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're on it, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated 👍 |
||
} | ||
|
||
export interface BabelFileResult { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
NodePath
isn't used. Did you want to use it forwrapPluginVisitorMethod
?The rest looks great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over from my trying to get
wrapPluginVisitorMethod
to have better specified types – was going to ask about that actually. The callback function it takes and the function it returns can take anyNodePath
variant. I couldn't come up with a way to add concrete typing to those functions without enumerating every templated type, like is done inbabel-traverse
. Do you have a better way to do this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple
NodePath
(AKANodePath<Node>
) is okay in this case.