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