packages/babel-types/src/validators/isVar.ts
raw| 1 | import { isVariableDeclaration } from "./generated"; |
| 2 | import { BLOCK_SCOPED_SYMBOL } from "../constants"; |
| 3 | import type * as t from ".."; |
| 4 | |
| 5 | /** |
| 6 | * Check if the input `node` is a variable declaration. |
| 7 | */ |
| 8 | export default function isVar(node: t.Node): boolean { |
| 9 | return ( |
| 10 | isVariableDeclaration(node, { kind: "var" }) && |
| 11 | !( |
| 12 | // @ts-expect-error document private properties |
| 13 | node[BLOCK_SCOPED_SYMBOL] |
| 14 | ) |
| 15 | ); |
| 16 | } |