acorn-walk
Advanced tools
Comparing version 7.1.0 to 7.1.1
@@ -0,1 +1,7 @@ | ||
## 7.1.1 (2020-02-13) | ||
### Bug fixes | ||
Clean up the type definitions to actually work well with the main parser. | ||
## 7.1.0 (2020-02-11) | ||
@@ -2,0 +8,0 @@ |
@@ -0,113 +1,111 @@ | ||
import {Node} from 'acorn'; | ||
declare module "acorn-walk" { | ||
type NodeType = import("estree").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<import("estree").Node, "type", K>; | ||
type FullWalkerCallback<TState> = ( | ||
node: import("estree").Node, | ||
state: TState, | ||
type: NodeType | ||
node: Node, | ||
state: TState, | ||
type: string | ||
) => void; | ||
type FullAncestorWalkerCallback<TState> = ( | ||
node: import("estree").Node, | ||
state: TState | import("estree").Node[], | ||
ancestors: import("estree").Node[], | ||
type: NodeType | ||
node: Node, | ||
state: TState | Node[], | ||
ancestors: Node[], | ||
type: string | ||
) => void; | ||
type WalkerCallback<TState> = (node: import("estree").Node, state: TState) => void; | ||
type WalkerCallback<TState> = (node: Node, state: TState) => void; | ||
type SimpleWalkerFn<K extends NodeType, TState> = ( | ||
node: NarrowNode<K>, | ||
state: TState | ||
type SimpleWalkerFn<TState> = ( | ||
node: Node, | ||
state: TState | ||
) => void; | ||
type AncestorWalkerFn<K extends NodeType, TState> = ( | ||
node: NarrowNode<K>, | ||
state: TState| import("estree").Node[], | ||
ancestors: import("estree").Node[] | ||
type AncestorWalkerFn<TState> = ( | ||
node: Node, | ||
state: TState| Node[], | ||
ancestors: Node[] | ||
) => void; | ||
type RecursiveWalkerFn<K extends NodeType, TState> = ( | ||
node: NarrowNode<K>, | ||
state: TState, | ||
callback: WalkerCallback<TState> | ||
type RecursiveWalkerFn<TState> = ( | ||
node: Node, | ||
state: TState, | ||
callback: WalkerCallback<TState> | ||
) => void; | ||
type SimpleVisitors<Types extends NodeType, TState> = { | ||
[Type in Types]: SimpleWalkerFn<Type, TState> | ||
type SimpleVisitors<TState> = { | ||
[type: string]: SimpleWalkerFn<TState> | ||
}; | ||
type AncestorVisitors<Types extends NodeType, TState> = { | ||
[Type in Types]: AncestorWalkerFn<Type, TState> | ||
type AncestorVisitors<TState> = { | ||
[type: string]: AncestorWalkerFn<TState> | ||
}; | ||
type RecursiveVisitors<Types extends NodeType, TState> = { | ||
[Type in Types]: RecursiveWalkerFn<Type, TState> | ||
type RecursiveVisitors<TState> = { | ||
[type: string]: RecursiveWalkerFn<TState> | ||
}; | ||
type FindPredicate = (type: NodeType, node: import("estree").Node) => boolean; | ||
type FindPredicate = (type: string, node: Node) => boolean; | ||
interface Found<Type extends NodeType, TState> { | ||
node: NarrowNode<Type>, | ||
state: TState | ||
interface Found<TState> { | ||
node: Node, | ||
state: TState | ||
} | ||
export function simple<TState, K extends NodeType>( | ||
node: import("estree").Node, | ||
visitors: SimpleVisitors<K, TState>, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
export function simple<TState>( | ||
node: Node, | ||
visitors: SimpleVisitors<TState>, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): void; | ||
export function ancestor<TState, K extends NodeType>( | ||
node: import("estree").Node, | ||
visitors: AncestorVisitors<K, TState>, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
export function ancestor<TState>( | ||
node: Node, | ||
visitors: AncestorVisitors<TState>, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): void; | ||
export function recursive<TState, K extends NodeType>( | ||
node: import("estree").Node, | ||
state: TState, | ||
functions: RecursiveVisitors<K, TState>, | ||
base?: RecursiveVisitors<NodeType, TState> | ||
export function recursive<TState>( | ||
node: Node, | ||
state: TState, | ||
functions: RecursiveVisitors<TState>, | ||
base?: RecursiveVisitors<TState> | ||
): void; | ||
export function full<TState>( | ||
node: import("estree").Node, | ||
callback: FullWalkerCallback<TState>, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
node: Node, | ||
callback: FullWalkerCallback<TState>, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): void; | ||
export function fullAncestor<TState>( | ||
node: import("estree").Node, | ||
callback: FullAncestorWalkerCallback<TState>, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
node: Node, | ||
callback: FullAncestorWalkerCallback<TState>, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): void; | ||
export function make<TState, K extends NodeType>( | ||
functions: RecursiveVisitors<K, TState>, | ||
base?: RecursiveVisitors<NodeType, TState> | ||
): RecursiveVisitors<NodeType, TState>; | ||
export function make<TState>( | ||
functions: RecursiveVisitors<TState>, | ||
base?: RecursiveVisitors<TState> | ||
): RecursiveVisitors<TState>; | ||
export function findNodeAt<TState, K extends NodeType>( | ||
node: import("estree").Node, | ||
start: number | undefined, | ||
end: number | undefined, | ||
type: K, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
): Found<K, TState> | undefined; | ||
export function findNodeAt<TState>( | ||
node: Node, | ||
start: number | undefined, | ||
end: number | undefined, | ||
type: string, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): Found<TState> | undefined; | ||
export function findNodeAt<TState>( | ||
node: import("estree").Node, | ||
start: number | undefined, | ||
end: number | undefined, | ||
type?: FindPredicate, | ||
base?: RecursiveVisitors<NodeType, TState>, | ||
state?: TState | ||
): Found<NodeType, TState> | undefined; | ||
node: Node, | ||
start: number | undefined, | ||
end: number | undefined, | ||
type?: FindPredicate, | ||
base?: RecursiveVisitors<TState>, | ||
state?: TState | ||
): Found<TState> | undefined; | ||
@@ -114,0 +112,0 @@ export const findNodeAround: typeof findNodeAt; |
@@ -8,3 +8,3 @@ { | ||
"module": "dist/walk.mjs", | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"engines": {"node": ">=0.4.0"}, | ||
@@ -11,0 +11,0 @@ "maintainers": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99762
912