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