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