Skip to content

Commit

Permalink
Remove NarrowNode from walk.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
susiwen8 committed Feb 13, 2020
1 parent 1d85e7c commit de6edeb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions acorn-walk/dist/walk.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import acorn from 'acorn';

declare module "acorn-walk" {
type NodeType = acorn.Node["type"];
type DiscriminateUnion<T, K extends keyof T, V extends T[K] = T[K]> = T extends Record<K, V> ? T : never;
type NarrowNode<K extends NodeType> = DiscriminateUnion<acorn.Node, "type", K>;
type NodeType = acorn.Node["type"];

type FullWalkerCallback<TState> = (
node: acorn.Node,
Expand All @@ -20,18 +18,18 @@ declare module "acorn-walk" {
type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void;

type SimpleWalkerFn<K extends NodeType, TState> = (
node: NarrowNode<K>,
node: acorn.Node,
state: TState
) => void;

type AncestorWalkerFn<K extends NodeType, TState> = (
node: NarrowNode<K>,
node: acorn.Node,
state: TState| acorn.Node[],
ancestors: acorn.Node[]
) => void;

type RecursiveWalkerFn<K extends NodeType, TState> = (
node: NarrowNode<K>,
node: acorn.Node,
state: TState,
callback: WalkerCallback<TState>
) => void;
Expand All @@ -51,7 +49,7 @@ declare module "acorn-walk" {
type FindPredicate = (type: NodeType, node: acorn.Node) => boolean;

interface Found<Type extends NodeType, TState> {
node: NarrowNode<Type>,
node: acorn.Node,
state: TState
}

Expand Down

0 comments on commit de6edeb

Please sign in to comment.