TizzySaurus
TizzySaurus
Aarktype
Created by anispwyn on 4/26/2025 in #questions
customize errors
Per your example it's a function, so you can just return different things based on what the user entered
7 replies
Aarktype
Created by anispwyn on 4/26/2025 in #questions
customize errors
Just use an if statement :Shrug:
7 replies
Aarktype
Created by anispwyn on 4/26/2025 in #questions
customize errors
And then just provide a better error message yourself
7 replies
Aarktype
Created by anispwyn on 4/26/2025 in #questions
customize errors
You can set the message instead of the problem
7 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
I.e. type.instanceOf(CalendarDate).or(type.instanceOf(CalendarDateTime).or(type.instanceOf(ZonedDateTime).as<DateValue>() (and I'd make DateValue a type import again for clarity)
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
So you'll need to recreate from the actual classes
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Oh, right, DateValue is a type not a class
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Using a different name should work though (make sure to update the other references)
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Right yeah, the import isn't type-only anymore so you can't name the ArkType type the same
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
@Frieder
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Yeah, there is, so something like
import { DateValue } from "..."; // NB: NOT a type import
import { type } from "arktype";

const DateValue = type.instanceOf(DateValue);

export const arcEditObject = type({
...
start: [DateValue, "|", "undefined"]
});
import { DateValue } from "..."; // NB: NOT a type import
import { type } from "arktype";

const DateValue = type.instanceOf(DateValue);

export const arcEditObject = type({
...
start: [DateValue, "|", "undefined"]
});
should work
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Well, actually, I think there's a type.instanceOf or something
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Right... I guess you'd need an equivalent ArkType type for each of those classes then
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
I.e.
import type { DateValue } from "...";
import { type } from "arktype";

const DateValue = type(...).as<DateValue>();

export const arcEditObject = type({
...
start: [DateValue, "|", "undefined"]
});
import type { DateValue } from "...";
import { type } from "arktype";

const DateValue = type(...).as<DateValue>();

export const arcEditObject = type({
...
start: [DateValue, "|", "undefined"]
});
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
You probably need to create an arktype type equivalent and use that
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
What actually is DateValue?
18 replies
Aarktype
Created by Frieder on 4/24/2025 in #questions
Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
You're importing DateValue as a TS type, so it doesn't even exist at runtime [when arktype runs]
18 replies
Aarktype
Created by Simon on 4/23/2025 in #questions
Can the JSON Schema be typed automatically?
As I said originally, just do "type" in jsonSchema && jsonSchema.type === "object" (in theory, anyway)
53 replies
Aarktype
Created by Simon on 4/23/2025 in #questions
Can the JSON Schema be typed automatically?
Although it's not really clear what those if statements actually add
53 replies
Aarktype
Created by Simon on 4/23/2025 in #questions
Can the JSON Schema be typed automatically?
And since it's repeated, maybe it's worth moving it to a util function
53 replies