Type '"DateValue | undefined"' is not assignable to type '"'DateValue' is unresolvable "'.ts(2322)
Hello, i am an absolute beginner when it comes to ArkType and i am trying adapt my project while following allowing the https://arktype.io/docs/intro/your-first-type intro. When trying to adopt the example to my real life type, i am getting the error mentioned in the title. DateValue itself is a union type of some classes. What i am doing wrong?

8 Replies
You're importing
DateValue
as a TS type
, so it doesn't even exist at runtime [when arktype runs]
What actually is DateValue
?
You probably need to create an arktype type equivalent and use that
I.e.DateValue is a union type of some classes that i am forced to use because its a dependency of the shadcn date picker.

Right... I guess you'd need an equivalent ArkType type for each of those classes then
Well, actually, I think there's a
type.instanceOf
or something
Yeah, there is, so something likeshould work
@FriederThanks! Unfortunately, in order to make it work it seems that i would have to change some tsconfig.ts settings that are at least recommended by svelte, including setting "verbatimModuleSyntax" to false and also "isolatedModules". But even if i do this, i does not work and i get an as shown in the picture. Renaming '''const DateValue = type.instanceOf(DateValue);''' to something else results in "DateValue' only refers to a type, but is being used as a value here.ts(2693)"

Right yeah, the import isn't type-only anymore so you can't name the ArkType type the same
Using a different name should work though (make sure to update the other references)
I tried it but it doesn't 😦

Oh, right,
DateValue
is a type not a class
So you'll need to recreate from the actual classes
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)Many thanks, that did the trick and i could also switch back to the recommened ts settings Many thanks!