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