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