A
arktype•5mo ago
SynthLuvr

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"));
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
ParseError: Root of kind union should be one of alias,intersection,unit,domain,proto
4 Replies
TizzySaurus
TizzySaurus•5mo ago
Make sure you're on the latest version (iirc dev.26 dev.29) There was a similar issue that I had on a prior version that's since been fixed
ssalbdivad
ssalbdivad•5mo ago
You might remember that being the latest version but that doesn't mean there haven't been new versions since then 😛
TizzySaurus
TizzySaurus•5mo ago
Damn, you've been busy 😅
ssalbdivad
ssalbdivad•5mo ago
I will look into this once I finish up generics. I can confirm this is on the latest version. Looking into it @SynthLuvr This will be fixed once I release in the next hour or so
Want results from more Discord servers?
Add your server