PIat
Aarktype
•Created by PIat on 10/9/2024 in #questions
Type definitions must be strings or objects (was undefined)
Hello!
When importing a module that is using Arktype, I get the error
Type definitions must be strings or objects (was undefined)
. I am not sure what it means. What should I be looking for to solve it?18 replies
Aarktype
•Created by PIat on 10/8/2024 in #questions
Conform to an existing type
Hello! Is there a way to force a def to conform to an existing typescript type?
29 replies
Aarktype
•Created by PIat on 10/1/2024 in #questions
Node of kind optional is not valid as a required definition
Hello! Whenever I use a type with an optional key with a default value like this:
I get the error
Node of kind optional is not valid as a required definition
. What could it mean? Note that I'm also updating the type
via map
, but removing that mapping appeared to have no effect so far.
Removing the default value throws no error42 replies
Aarktype
•Created by PIat on 9/17/2024 in #questions
ParseError: undefined must be a PropertyKey or stringifyNonKey must be passed to options
Hello! When
key
isn't provided in the .map
function, the above error is thrown.
Not working code:
Working code (simply added key
to return object):
Is there a reason for this behavior? I would expect the key to already be present on the prop
27 replies
Aarktype
•Created by PIat on 9/17/2024 in #questions
Dynamic type based on another value
Given a theoretical example like this:
Is it possible to only have
clauses
be required if agree
is true
?24 replies
Aarktype
•Created by PIat on 9/14/2024 in #questions
Extracting defaults at runtime
Hello!
What is the canon way to extract the default values of the type on runtime? I'd like to uuse the defaults from the type as defaults in a form.
4 replies
Aarktype
•Created by PIat on 9/14/2024 in #questions
Ark attest cannot find module error
Hello!
In a pnpm monorepo, with
@ark/attest
installed in the workspace root and running pnpx run attest trace .
, I get the following output:
What should I change to run it without issues?156 replies
Aarktype
•Created by PIat on 9/6/2024 in #questions
Extracting intent into runtime
Hello!
What is the canon way to extract keys from types like these:
In a way that the resulting object is
?
Would it be achieved with
internal.distribute
?7 replies
Aarktype
•Created by PIat on 9/4/2024 in #questions
Converting Zod to Arktype
Hello!
I'm really interested in using Conform instead of React Hook Form for better DX and server-side capabilities. However, it doesn't have Ark support yet, so I'll have to create my own simple patch.
Are there by any chance some examples or comparisons between Zod and Arktype architectures to go off of when translating these files, namely to extract the name of the constraints like
Array
in runtime?
expression
might be "key"? pun intended
https://github.com/edmundhung/conform/blob/main/packages/conform-zod/constraint.ts
https://github.com/edmundhung/conform/blob/main/packages/conform-zod/parse.ts
Also, is there an way to do something like superRefine
for custom run-time conditions?
https://zod.dev/?id=superrefine174 replies
Aarktype
•Created by PIat on 8/30/2024 in #questions
Default number
Hello!
Setting this brings the expected result, when ran through
inferAmbient
:
But adding a default value returns a function signature:
How can I get the number
type in the editor when providing a default value?133 replies
Aarktype
•Created by PIat on 8/23/2024 in #questions
Accept number in string type
Hello! I'm parsing each value in a form with
JSON.parse
to convert string values like false
to actual booleans. Unfortunately, this introduces the issue, that if someone inputs 123
into a text field, it gets parsed into a number type by JSON.parse
. Then if the field is type string
. An error is thrown, since number is not assignable to string.
How should a type look like, if it should handle such a situation?187 replies
Aarktype
•Created by PIat on 8/22/2024 in #questions
Extract type from or
Hello! Is it possible, using the following schema:
to extract one of the types ("find" it by the
intent
field)? I'd like to use it for multiple forms on a page.
It's possible to split it into multiple types, but having it in one type is more readable to me25 replies
Aarktype
•Created by PIat on 8/22/2024 in #questions
Get type without constraints
Hello!
inferAmbient
retuns types with constraints like moreThanLength<0>
, which when I try to access values to, I get Type 'string' is not assignable to type 'moreThanLength<0>'
.
Is it possible to extract a more basic type?15 replies
Aarktype
•Created by PIat on 8/19/2024 in #questions
must be an instance of FormData (was object)
Hello!
This code:
Throws following error:
However,
formData
is instanceof FormData
and the log also says it's FormData
:
What am I doing wrong?38 replies
Aarktype
•Created by PIat on 8/16/2024 in #questions
Error internationalization (i18n)
Hello! Is it possible to translate the errors into other languages?
In my previous setup I was using this for such funtionality:
https://github.com/aiji42/zod-i18n
I saw this issue opened for individual fields, which would really be great:
https://github.com/arktypeio/arktype/issues/722
Is this the way for "general" errors?
https://github.com/arktypeio/arktype/issues/404
124 replies
Aarktype
•Created by PIat on 8/13/2024 in #questions
Tried to initialize an $ark registry in a monorepo
Hello! In a
pnpm
workspace, I have 2 packages depending on arktype
. This means that each package depends on arktype
separately. However, when I import them into a central vite
project, I get the error:
Both packages are compiled to ESM, and the arktype
version is identical, so the issue must be in them clashing inside of the vite
project. What would be a good way to avoid this error?203 replies
Aarktype
•Created by PIat on 8/12/2024 in #questions
Adding comment to object key
Hello! What would be the right way to add comments to an object's key, like you do with
/** */
?
I tried this, but it didn't work:
33 replies
Aarktype
•Created by PIat on 8/11/2024 in #questions
Optional key
Hello! How can I define an array, which is also not required as an optional key? Is this the easiest way? https://discord.com/channels/957797212103016458/957804102685982740/1213198676349026355
10 replies