mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
[@babel/traverse]: Fixed type of path when using enter & exit visitor.
This commit is contained in:
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user