checkDistinct
No two planned definitions may claim the same path in the same space (a type and a value may share one).
import { UsageError } from "#codebase/tcmts/cli/ui"; import { sameSpace } from "#codebase/tcmts/core/types"; import type { DefRecord } from "#codebase/tcmts/core/types"; export function checkDistinct<P extends { def: DefRecord; path: string }>(planned: P[], message: (p: P) => string) { planned.forEach((p, i) => { if (planned.some((q, j) => j < i && q.path === p.path && sameSpace(q.def.kind, p.def.kind))) throw new UsageError(message(p)); }); }