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