packages/babel-types/src/validators/isLet.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 `let` variable declaration. |
| 7 | */ |
| 8 | export default function isLet(node: t.Node): boolean { |
| 9 | return ( |
| 10 | isVariableDeclaration(node) && |
| 11 | (node.kind !== "var" || |
| 12 | // @ts-expect-error Fixme: document private properties |
| 13 | node[BLOCK_SCOPED_SYMBOL]) |
| 14 | ); |
| 15 | } |