Skip to content

Commit 4d411d7

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update acorn-walk to 8.3.5
PR-URL: #61928 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f53a32a commit 4d411d7

File tree

7 files changed

+115
-95
lines changed

7 files changed

+115
-95
lines changed

deps/acorn/acorn-walk/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 8.3.5 (2026-02-19)
2+
3+
### Bug fixes
4+
5+
Emit a more informative error message when trying to walk a node type that has no walker function.
6+
7+
Specify callbacks in types to receive `AnyNode` type, so that they can be narrowed more easily.
8+
9+
Support import attributes.
10+
111
## 8.3.4 (2024-09-09)
212

313
### Bug fixes

deps/acorn/acorn-walk/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ produce a meaningful state. (An example of a use of state is to track
4747
scope at each point in the tree.)
4848

4949
```js
50-
const acorn = require("acorn")
51-
const walk = require("acorn-walk")
50+
import * as acorn from "acorn"
51+
import * as walk from "acorn-walk"
5252

5353
walk.simple(acorn.parse("let x = 10"), {
5454
Literal(node) {
@@ -62,8 +62,8 @@ a tree, building up an array of ancestor nodes (including the current node)
6262
and passing the array to the callbacks as a third parameter.
6363

6464
```js
65-
const acorn = require("acorn")
66-
const walk = require("acorn-walk")
65+
import * as acorn from "acorn"
66+
import * as walk from "acorn-walk"
6767

6868
walk.ancestor(acorn.parse("foo('hi')"), {
6969
Literal(_node, _state, ancestors) {
@@ -97,8 +97,8 @@ current node) and passing the array to the callbacks as a third
9797
parameter.
9898

9999
```js
100-
const acorn = require("acorn")
101-
const walk = require("acorn-walk")
100+
import * as acorn from "acorn"
101+
import * as walk from "acorn-walk"
102102

103103
walk.full(acorn.parse("1 + 1"), node => {
104104
console.log(`There's a ${node.type} node at ${node.ch}`)

deps/acorn/acorn-walk/dist/walk.d.mts

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as acorn from "acorn"
22

33
export type FullWalkerCallback<TState> = (
4-
node: acorn.Node,
4+
node: acorn.AnyNode,
55
state: TState,
66
type: string
77
) => void
88

99
export type FullAncestorWalkerCallback<TState> = (
10-
node: acorn.Node,
10+
node: acorn.AnyNode,
1111
state: TState,
12-
ancestors: acorn.Node[],
12+
ancestors: acorn.AnyNode[],
1313
type: string
1414
) => void
1515

@@ -29,24 +29,24 @@ export type SimpleVisitors<TState> = {
2929
}
3030

3131
export type AncestorVisitors<TState> = {
32-
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
32+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.AnyNode[]
3333
) => void
3434
} & {
35-
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
35+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.AnyNode[]) => void
3636
}
3737

38-
export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
38+
export type WalkerCallback<TState> = (node: acorn.AnyNode, state: TState) => void
3939

4040
export type RecursiveVisitors<TState> = {
4141
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
4242
} & {
4343
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
4444
}
4545

46-
export type FindPredicate = (type: string, node: acorn.Node) => boolean
46+
export type FindPredicate = (type: string, node: acorn.AnyNode) => boolean
4747

4848
export interface Found<TState> {
49-
node: acorn.Node,
49+
node: acorn.AnyNode,
5050
state: TState
5151
}
5252

@@ -66,10 +66,6 @@ export function simple<TState>(
6666

6767
/**
6868
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
69-
* @param node
70-
* @param visitors
71-
* @param base
72-
* @param state
7369
*/
7470
export function ancestor<TState>(
7571
node: acorn.Node,
@@ -94,10 +90,6 @@ export function recursive<TState>(
9490

9591
/**
9692
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
97-
* @param node
98-
* @param callback
99-
* @param base
100-
* @param state
10193
*/
10294
export function full<TState>(
10395
node: acorn.Node,
@@ -108,10 +100,6 @@ export function full<TState>(
108100

109101
/**
110102
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
111-
* @param node
112-
* @param callback
113-
* @param base
114-
* @param state
115103
*/
116104
export function fullAncestor<TState>(
117105
node: acorn.Node,
@@ -122,8 +110,6 @@ export function fullAncestor<TState>(
122110

123111
/**
124112
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
125-
* @param functions
126-
* @param base
127113
*/
128114
export function make<TState>(
129115
functions: RecursiveVisitors<TState>,
@@ -132,33 +118,22 @@ export function make<TState>(
132118

133119
/**
134120
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
135-
* @param node
136-
* @param start
137-
* @param end
138-
* @param type
139-
* @param base
140-
* @param state
141121
*/
142122
export function findNodeAt<TState>(
143123
node: acorn.Node,
144-
start: number | undefined,
145-
end?: number | undefined,
124+
start: number | undefined | null,
125+
end?: number | undefined | null,
146126
type?: FindPredicate | string,
147127
base?: RecursiveVisitors<TState>,
148128
state?: TState
149129
): Found<TState> | undefined
150130

151131
/**
152132
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
153-
* @param node
154-
* @param start
155-
* @param type
156-
* @param base
157-
* @param state
158133
*/
159134
export function findNodeAround<TState>(
160135
node: acorn.Node,
161-
start: number | undefined,
136+
start: number | undefined | null,
162137
type?: FindPredicate | string,
163138
base?: RecursiveVisitors<TState>,
164139
state?: TState

deps/acorn/acorn-walk/dist/walk.d.ts

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as acorn from "acorn"
22

33
export type FullWalkerCallback<TState> = (
4-
node: acorn.Node,
4+
node: acorn.AnyNode,
55
state: TState,
66
type: string
77
) => void
88

99
export type FullAncestorWalkerCallback<TState> = (
10-
node: acorn.Node,
10+
node: acorn.AnyNode,
1111
state: TState,
12-
ancestors: acorn.Node[],
12+
ancestors: acorn.AnyNode[],
1313
type: string
1414
) => void
1515

@@ -29,24 +29,24 @@ export type SimpleVisitors<TState> = {
2929
}
3030

3131
export type AncestorVisitors<TState> = {
32-
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
32+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.AnyNode[]
3333
) => void
3434
} & {
35-
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
35+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.AnyNode[]) => void
3636
}
3737

38-
export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
38+
export type WalkerCallback<TState> = (node: acorn.AnyNode, state: TState) => void
3939

4040
export type RecursiveVisitors<TState> = {
4141
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
4242
} & {
4343
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
4444
}
4545

46-
export type FindPredicate = (type: string, node: acorn.Node) => boolean
46+
export type FindPredicate = (type: string, node: acorn.AnyNode) => boolean
4747

4848
export interface Found<TState> {
49-
node: acorn.Node,
49+
node: acorn.AnyNode,
5050
state: TState
5151
}
5252

@@ -66,10 +66,6 @@ export function simple<TState>(
6666

6767
/**
6868
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
69-
* @param node
70-
* @param visitors
71-
* @param base
72-
* @param state
7369
*/
7470
export function ancestor<TState>(
7571
node: acorn.Node,
@@ -94,10 +90,6 @@ export function recursive<TState>(
9490

9591
/**
9692
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
97-
* @param node
98-
* @param callback
99-
* @param base
100-
* @param state
10193
*/
10294
export function full<TState>(
10395
node: acorn.Node,
@@ -108,10 +100,6 @@ export function full<TState>(
108100

109101
/**
110102
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
111-
* @param node
112-
* @param callback
113-
* @param base
114-
* @param state
115103
*/
116104
export function fullAncestor<TState>(
117105
node: acorn.Node,
@@ -122,8 +110,6 @@ export function fullAncestor<TState>(
122110

123111
/**
124112
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
125-
* @param functions
126-
* @param base
127113
*/
128114
export function make<TState>(
129115
functions: RecursiveVisitors<TState>,
@@ -132,33 +118,22 @@ export function make<TState>(
132118

133119
/**
134120
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
135-
* @param node
136-
* @param start
137-
* @param end
138-
* @param type
139-
* @param base
140-
* @param state
141121
*/
142122
export function findNodeAt<TState>(
143123
node: acorn.Node,
144-
start: number | undefined,
145-
end?: number | undefined,
124+
start: number | undefined | null,
125+
end?: number | undefined | null,
146126
type?: FindPredicate | string,
147127
base?: RecursiveVisitors<TState>,
148128
state?: TState
149129
): Found<TState> | undefined
150130

151131
/**
152132
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
153-
* @param node
154-
* @param start
155-
* @param type
156-
* @param base
157-
* @param state
158133
*/
159134
export function findNodeAround<TState>(
160135
node: acorn.Node,
161-
start: number | undefined,
136+
start: number | undefined | null,
162137
type?: FindPredicate | string,
163138
base?: RecursiveVisitors<TState>,
164139
state?: TState

0 commit comments

Comments
 (0)