Is there a recommended way to transform a type union into a discriminated union by adding a tag?
Is there a way to do a case insensitive literal match?
string.lower
to a lower-case literal but that seems complicated for this.Is there a way to perform schema parsing generically?
Use native ts type
type BlockainsName = "bitcoin" | "ethereum" | "solana" | "polygon-pos" | "binance-smart-chain" | "avalanche"
type BlockainsName = "bitcoin" | "ethereum" | "solana" | "polygon-pos" | "binance-smart-chain" | "avalanche"
ParseError: undefined must be a PropertyKey or stringifyNonKey must be passed to options
key
isn't provided in the .map
function, the above error is thrown.
Not working code:
```ts...Dynamic type based on another value
Why does an optional property add a " | undefined" instead of just being an optional property?
| undefined
? I encountered something similar with zod which had the result that my zod-type and database generated type did not match although they should.
Dummy example:
```ts
const schema = type({...Generic with Narrow/Morph
Extracting defaults at runtime
Ark attest cannot find module error
@ark/attest
installed in the workspace root and running pnpx run attest trace .
, I get the following output:
```...Is there a way to parse Dates and date iso strings without losing toJsonSchema capabilities.
`string.integer.parsed` with limits
1 < integer < 9999
Hovewer, I want to parse it from env string
so I need string.integer.parse
How do I make the limited parsed integer?...Got syntax error in some browser
ToJsonSchema fails with narrow
.in
property.
```ts...extracting redux-like actions from type.enumerated discriminated union
alternative to nesting quotes in quotes for strings?
template literal/backtick string types e.g. type T = `type-${string}`
type UserId = `user-${string}`
type UserId = `user-${string}`
Multiple versions
"arktype": "2.0.0-rc.5",
"arktype": "2.0.0-rc.5",

Compile-time typesafe merge/and for data-only "traits"
arktype/util
but this is data only; so far I've avoided the need to introduce any classes and I'm hoping to maintain this approach.
So I have a discriminated union that represents the different "traits" and the union members share a common shape (mainly references to other trait names), something along these lines:
```ts...Creating default object from type definition