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