[@babel/traverse]: Fixed type of path when using enter & exit visitor.

This commit is contained in:
Cameron Martin
2018-11-27 17:39:51 +00:00
parent 3fd74d83b5
commit 289c533aad
2 changed files with 7 additions and 3 deletions
@@ -4,10 +4,14 @@ import * as t from "@babel/types";
// Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
const MyVisitor: Visitor = {
Identifier: {
enter() {
enter(path) {
// $ExpectType NodePath<Identifier>
path;
console.log("Entered!");
},
exit() {
exit(path) {
// $ExpectType NodePath<Identifier>
path;
console.log("Exited!");
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ export type Visitor<S = Node> = VisitNodeObject<Node> & {
[P in Node["type"]]?: VisitNode<S, Extract<Node, { type: P; }>>;
};
export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<P>;
export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;