TizzySaurus
Aarktype
•Created by papy0977 on 1/20/2025 in #questions
Hi,
And for the second, wouldn't just calling the type do that? I.e.
foo()
/foo({})
4 replies
Aarktype
•Created by papy0977 on 1/20/2025 in #questions
Hi,
You can try
foo: type("string[]").default(["bar"])
4 replies
Aarktype
•Created by Tony on 12/19/2024 in #questions
Optional required pairs?
One way would be to use
.narrow()
, which has the added benefit of being able to specify custom errors:If you just want the default error messages though do something like what @ArkDavid suggested below3 replies
Aarktype
•Created by JesusTheHun on 11/19/2024 in #questions
`narrow` vs `satisfying`
There'd need to be some form of transform, yes. Not necessarily a
.pipe()
explicitly though.11 replies
Aarktype
•Created by JesusTheHun on 11/19/2024 in #questions
`narrow` vs `satisfying`
narrow
applies the constraint to the output, whereas satisfying
applies the constraint to the input11 replies
Aarktype
•Created by JesusTheHun on 11/19/2024 in #questions
`narrow` vs `satisfying`
this is the difference in the source code
11 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
Fwiw there's alsoiirc
16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
But in theory you could do something like....
16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
Your type also seems to be wrong because
weightAliases
is Record<string, StandardWeightUnit>
, but then you do Object.keys(weightAliases) as StandardWeightUnit[]
.
But the keys are string
, not StandardWeightUnit
. It's the values that are StandardWeightUnit
16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
What is
normalizedUnitUnion
and namedUnit
?16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
There's also
type.enumerated([1, 2, 3])
iirc16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
toStringUnion
should just be type("...", aliasList)
. I wouldn't even wrap it in a function since then you loose the type inference -- just use it directly16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
It's not entirely clear to me what you're trying to achieve though
16 replies
Aarktype
•Created by jacksteamdev on 11/9/2024 in #questions
Union Fallthrough?
Are you aware of
type("...", arrOfTypes)
? That may be what you're looking for with toStringUnion
16 replies
Aarktype
•Created by terinjokes on 11/4/2024 in #questions
morphing to typescript type
Err, you can do. Might be worth waiting for David to confirm it is indeed a bug.
24 replies
Aarktype
•Created by terinjokes on 11/4/2024 in #questions
morphing to typescript type
Tl;Dr; I'm fairly certain this is a bug in ArkType (tbc by David), so thanks for reporting this 🙂
24 replies
Aarktype
•Created by terinjokes on 11/4/2024 in #questions
morphing to typescript type
@ssalbdivad Are you able to confirm that this is the case (i.e. this is unintentional)?
Context: the inferred type of a morph that returns an object with
valueOf: () => never
becomes valueOf: never
(instead of keeping valueOf
as a function, as it does for when e.g. valueOf: () => number
)24 replies
Aarktype
•Created by terinjokes on 11/4/2024 in #questions
morphing to typescript type
I assume this is because
() => never
extends InferredMorph
, which I don't think it should.24 replies