import type { Node } from 'web-tree-sitter'; import type { ValueNode } from './value.js'; const TYPE = 'list_value' as const; // ================================================================ // ================================================================ // // ListValueNode // // GraphQL list value node // // ================================================================ // ================================================================ /** * Represents a list value in the GraphQL AST. * * Children: * {@link ValueNode} * */ export interface ListValueNode extends Node { type: typeof TYPE; } // ================================================================ // ================================================================ // // Type Guard // // ================================================================ // ================================================================ /** * Type guard to check if a node is a {@link ListValueNode}. * * @param node - The node to check * @returns True if the node is a {@link ListValueNode} * * @example * ```typescript * if (isListValueNode(node)) { * // TypeScript now knows node is ListValueNode * console.log(node.type); // 'list_value' * } * ``` */ export function isListValueNode(node: unknown): node is ListValueNode { return (node as any)?.type === TYPE; } // ================================================================ // ================================================================ // // Constructor // // ================================================================ // ================================================================ /** * Creates a new {@link ListValueNode} with the specified properties. * * @param props - The node properties * @param props.value - {@link ValueNode} * @returns A new {@link ListValueNode} * * @example * ```typescript * const node = ListValueNode({ * // properties... * }); * ``` */ export function ListValueNode(props: Omit): ListValueNode { return { type: TYPE, ...props }; }