Simplify AST validators - #18103
Simplify AST validators#18103
Conversation
db0da4a to
1b5c198
Compare
| return opts == null || shallowEqual(node, opts); | ||
| return ( | ||
| node?.type === "ArrayExpression" && | ||
| (opts == null || shallowEqual(node, opts)) |
There was a problem hiding this comment.
Maybe we could have a shallowEqualN function that returns true is opts is null, to avoid repeating the check every time.
There was a problem hiding this comment.
If so, should we move the node.type compare to it too? 馃槃
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61960 |
|
commit: |
|
@fisker It seems to me that this PR is ready for review. Are there any pending action items? |
I mean, do we want change export function isBlockStatement<Opts extends Options<t.BlockStatement>>(
node: t.Node | null | undefined,
opts?: Opts | null,
): boolean {
- return node?.type === "BlockStatement" && shallowEqualN(node, opts);
+ return shallowEqualN(node, "BlockStatement", opts);
} |
This change looks good to me, in this case we can also consider rename |
liuxingbaoyu
left a comment
There was a problem hiding this comment.
This doesn't seem to affect performance. Thank you!
Fixes #1, Fixes #2