@@ -32,12 +32,11 @@ export const KEYS = Evk.unionWith({
32
32
33
33
/**
34
34
* Check that the given key should be traversed or not.
35
- * @this {Traversable}
36
35
* @param key The key to check.
36
+ * @param value The value of the key in the node.
37
37
* @returns `true` if the key should be traversed.
38
38
*/
39
- function fallbackKeysFilter ( this : any , key : string ) : boolean {
40
- let value = null
39
+ function fallbackKeysFilter ( key : string , value : any = null ) : boolean {
41
40
return (
42
41
key !== "comments" &&
43
42
key !== "leadingComments" &&
@@ -46,7 +45,7 @@ function fallbackKeysFilter(this: any, key: string): boolean {
46
45
key !== "range" &&
47
46
key !== "tokens" &&
48
47
key !== "trailingComments" &&
49
- ( value = this [ key ] ) !== null &&
48
+ value !== null &&
50
49
typeof value === "object" &&
51
50
( typeof value . type === "string" || Array . isArray ( value ) )
52
51
)
@@ -57,8 +56,10 @@ function fallbackKeysFilter(this: any, key: string): boolean {
57
56
* @param node The node to get.
58
57
* @returns The keys to traverse.
59
58
*/
60
- function getFallbackKeys ( node : Node ) : string [ ] {
61
- return Object . keys ( node ) . filter ( fallbackKeysFilter , node )
59
+ export function getFallbackKeys ( node : Node ) : string [ ] {
60
+ return Object . keys ( node ) . filter ( ( key ) =>
61
+ fallbackKeysFilter ( key , node [ key as keyof Node ] ) ,
62
+ )
62
63
}
63
64
64
65
/**
@@ -119,5 +120,3 @@ export interface Visitor {
119
120
export function traverseNodes ( node : Node , visitor : Visitor ) : void {
120
121
traverse ( node , null , visitor )
121
122
}
122
-
123
- export { getFallbackKeys }
0 commit comments