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