Unsatisfiable type
I'm trying to do this intersection, that should definitely work with typescript types, but is not working on arktype, and returning this error:
Intersection of { client_id: string, code: string, grant_type: "authorization_code", redirect_uri: (In: string ) => Out<URL>, + (undeclared): delete } and { client_secret: string, code_verifier?: never, + (undeclared): delete } | { code_verifier: string, client_secret?: never, + (undeclared): delete } results in an unsatisfiable type
. I've tested it in the playground and it works, but not in my code and I can't figure out why.
13 Replies
Hmm, could be a caching issue potentially?
Is your code public or are you able to narrow it down and publish some repo so I can see what's happening?
I just deleted the node_modules, and pnpm-lock, but the error persists. I tried creating a new react-router project, and the error is gone. Really weird
Found the issue:
I have a file called arktype.ts, where I use
arktype/config
to delete undeclared keys with
after commenting those lines, it started workingAhh okay, that makes sense. If you want to add more properties to an object with an
undeclared
config, you should use .merge
instead of .and
(generally better for combining objects anyways)another unrelated question, but how do I create an type from object in arktype? Where I have like:
I'm asking this because I already used
type.enumerated(Object.values(options))
, that results in "('foo' | 'bar')[]"
, but for some reason, it says that the input must include all the options available, and not one ofIt should be
type.enumerated(...Object.values(options))
wouldn't it turn into just
"'foo' | 'bar'"
? Because I'm actually aiming for it to be an array with one of the optionsThen you can chain
.array()
off thatgot it, thank you
hey, I was thinking if there's a way to use
.merge
without using the fluent way, I know that type.module you can use the Merge generic
but is there a way in the same way that you can use "&" and "|"?There's not a direct equivalent to
&
or |
in this case. You can use the "..."
key version of the syntax which would allow you to create a serializable version of the definitionalso, is there a way that I can use typesafe inputs while validating?
MyType.from will check what you pass directly