ssalbdivad
ssalbdivad
Aarktype
Created by Josh on 4/22/2025 in #questions
Generic minimum and maximum
Good question. It is theoretically possible to allow aliases to specify range constraints then check if they refer to a literal numeric value, but it does add a fair amount of parsing overhead. Is it possible at all in this situation to just use an external generic wrapper? https://arktype.io/docs/generics#external
3 replies
Aarktype
Created by nickmazuk on 4/19/2025 in #questions
`.configure` not being applied
@nickmazuk @Flosi21 .configure basically iterates over each node and adds metadata so that when that specific node creates an error, it will use the associated error config. What's unique about .narrow is that the errors being created aren't attached to the node itself, but created dynamically by the user in the narrow logic. It is impossible to transform them directly since they're not introspectable at runtime.
8 replies
Aarktype
Created by nickmazuk on 4/19/2025 in #questions
`.configure` not being applied
The error config docs do actually describe how these parts work together: https://arktype.io/docs/configuration#errors The goal of making the more granular config options like expected for must be ____ the defaults is that they can be composed if you e.g. use your type in a union.
8 replies
Aarktype
Created by nickmazuk on 4/19/2025 in #questions
`.configure` not being applied
.configure changes the errors that get created by your types, but if you create custom errors with narrow, it wouldn't affect those. You can see if you shorten the password to be less than 12 characters, which is enforced by the base type, your custom message applies. You want to write your own error message in narrow and then override it again?
8 replies
Aarktype
Created by albertcito on 4/19/2025 in #questions
It is compatible with Nuxt UI?
It mentions it accepts any Standard Schema so yes, it should be!
3 replies
Aarktype
Created by Stuart B on 4/10/2025 in #questions
Set object property alias for errors?
3 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
Then you should just pipe from unknown instead and return undefined in that case
20 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
Oh I see you're saying that shouldn't fail
20 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
No description
20 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
If you read about morphs and look at the way that is written, it would have to be a string otherwise it would be an error
20 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
That should be true of the current implementation
20 replies
Aarktype
Created by Paul on 4/17/2025 in #questions
Hint for discriminators in union for better error messages?
It will be awesome if @Flosi21 is able to make some of those improvements, but unfortunately something like what you're describing isn't possible because the problem isn't identifying the discriminator, it's splitting up all the case logic. In the meantime, you can just use a .pipe to discriminate yourself or map the type so that each discriminator is on its own branch
2 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
Only meaningful difference is string.integer.parse if you need them to be integers
20 replies
Aarktype
Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
Yeah this is almost exactly what I wrote:
import { type } from "arktype"

const parseToIntegers = type("string.integer.parse[]")

const T = type({
param1: "string",
param2: type.string.pipe(s => {
const substrings = s.split(",")
const parsed = parseToIntegers(substrings)
if (parsed instanceof type.errors) return undefined
return parsed
})
})
import { type } from "arktype"

const parseToIntegers = type("string.integer.parse[]")

const T = type({
param1: "string",
param2: type.string.pipe(s => {
const substrings = s.split(",")
const parsed = parseToIntegers(substrings)
if (parsed instanceof type.errors) return undefined
return parsed
})
})
20 replies
Aarktype
Created by Zicklag on 4/18/2025 in #questions
Fix Slow Types Warning When Publishing to JSR?
Ehh it has more to do with the actual logic of how they're generating the .d.ts than whats actually slow
11 replies
Aarktype
Created by Zicklag on 4/18/2025 in #questions
Fix Slow Types Warning When Publishing to JSR?
That is kind of what it is but there are a lot of cases where you'd want more control over your .d.ts output and it just blocks useful features of TS like I mentioned so it really needs to be reconsidered
11 replies
Aarktype
Created by Zicklag on 4/18/2025 in #questions
Fix Slow Types Warning When Publishing to JSR?
And there's nothing I can do to work around so people consuming arktype through JSR would just get a worse experience than people consuming it through npm (or generally .d.ts)
11 replies
Aarktype
Created by Zicklag on 4/18/2025 in #questions
Fix Slow Types Warning When Publishing to JSR?
Even within ArkType, it disallows really useful constructs like this for allowing global configuration: https://arktype.io/docs/configuration#prototypes
11 replies
Aarktype
Created by Zicklag on 4/18/2025 in #questions
Fix Slow Types Warning When Publishing to JSR?
I really dislike slow types as a concept and am fairly convinced just publishing js + .d.ts is better
11 replies