ParseError: Root of kind union should be one of alias,intersection,unit,domain,proto

import { type } from "arktype";

const Amount = type("string|number")
  .pipe((s, ctx) => {
    try {
      return BigInt(s);
    } catch {
      return ctx.error("a non-decimal number");
    }
  })
  .narrow((amount, ctx) => amount > 0n || ctx.mustBe("greater than zero"));

console.log(Amount.assert("1000"));

Produces error:
ParseError: Root of kind union should be one of alias,intersection,unit,domain,proto
Was this page helpful?