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