From e9372c151f63fe254c7f5e7ffd7a820e34422208 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 13 Feb 2020 17:50:46 +0100 Subject: [PATCH] Further clean up walker types --- acorn-walk/dist/walk.d.ts | 146 +++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 74 deletions(-) diff --git a/acorn-walk/dist/walk.d.ts b/acorn-walk/dist/walk.d.ts index f452bf75b..f2e68483c 100644 --- a/acorn-walk/dist/walk.d.ts +++ b/acorn-walk/dist/walk.d.ts @@ -1,115 +1,113 @@ -import acorn from 'acorn'; +import {Node} from 'acorn'; declare module "acorn-walk" { - type NodeType = acorn.Node["type"]; - type FullWalkerCallback = ( - node: acorn.Node, - state: TState, - type: NodeType + node: Node, + state: TState, + type: string ) => void; type FullAncestorWalkerCallback = ( - node: acorn.Node, - state: TState | acorn.Node[], - ancestors: acorn.Node[], - type: NodeType + node: Node, + state: TState | Node[], + ancestors: Node[], + type: string ) => void; - type WalkerCallback = (node: acorn.Node, state: TState) => void; + type WalkerCallback = (node: Node, state: TState) => void; - type SimpleWalkerFn = ( - node: acorn.Node, - state: TState + type SimpleWalkerFn = ( + node: Node, + state: TState ) => void; - type AncestorWalkerFn = ( - node: acorn.Node, - state: TState| acorn.Node[], - ancestors: acorn.Node[] + type AncestorWalkerFn = ( + node: Node, + state: TState| Node[], + ancestors: Node[] ) => void; - type RecursiveWalkerFn = ( - node: acorn.Node, - state: TState, - callback: WalkerCallback + type RecursiveWalkerFn = ( + node: Node, + state: TState, + callback: WalkerCallback ) => void; - type SimpleVisitors = { - [Type in Types]: SimpleWalkerFn + type SimpleVisitors = { + [type: string]: SimpleWalkerFn }; - type AncestorVisitors = { - [Type in Types]: AncestorWalkerFn + type AncestorVisitors = { + [type: string]: AncestorWalkerFn }; - type RecursiveVisitors = { - [Type in Types]: RecursiveWalkerFn + type RecursiveVisitors = { + [type: string]: RecursiveWalkerFn }; - type FindPredicate = (type: NodeType, node: acorn.Node) => boolean; + type FindPredicate = (type: string, node: Node) => boolean; - interface Found { - node: acorn.Node, - state: TState + interface Found { + node: Node, + state: TState } - export function simple( - node: acorn.Node, - visitors: SimpleVisitors, - base?: RecursiveVisitors, - state?: TState + export function simple( + node: Node, + visitors: SimpleVisitors, + base?: RecursiveVisitors, + state?: TState ): void; - export function ancestor( - node: acorn.Node, - visitors: AncestorVisitors, - base?: RecursiveVisitors, - state?: TState + export function ancestor( + node: Node, + visitors: AncestorVisitors, + base?: RecursiveVisitors, + state?: TState ): void; - export function recursive( - node: acorn.Node, - state: TState, - functions: RecursiveVisitors, - base?: RecursiveVisitors + export function recursive( + node: Node, + state: TState, + functions: RecursiveVisitors, + base?: RecursiveVisitors ): void; export function full( - node: acorn.Node, - callback: FullWalkerCallback, - base?: RecursiveVisitors, - state?: TState + node: Node, + callback: FullWalkerCallback, + base?: RecursiveVisitors, + state?: TState ): void; export function fullAncestor( - node: acorn.Node, - callback: FullAncestorWalkerCallback, - base?: RecursiveVisitors, - state?: TState + node: Node, + callback: FullAncestorWalkerCallback, + base?: RecursiveVisitors, + state?: TState ): void; - export function make( - functions: RecursiveVisitors, - base?: RecursiveVisitors - ): RecursiveVisitors; + export function make( + functions: RecursiveVisitors, + base?: RecursiveVisitors + ): RecursiveVisitors; - export function findNodeAt( - node: acorn.Node, - start: number | undefined, - end: number | undefined, - type: K, - base?: RecursiveVisitors, - state?: TState - ): Found | undefined; + export function findNodeAt( + node: Node, + start: number | undefined, + end: number | undefined, + type: string, + base?: RecursiveVisitors, + state?: TState + ): Found | undefined; export function findNodeAt( - node: acorn.Node, - start: number | undefined, - end: number | undefined, - type?: FindPredicate, - base?: RecursiveVisitors, - state?: TState - ): Found | undefined; + node: Node, + start: number | undefined, + end: number | undefined, + type?: FindPredicate, + base?: RecursiveVisitors, + state?: TState + ): Found | undefined; export const findNodeAround: typeof findNodeAt;