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