Closed merisbahti closed 3 years ago
I care that this key exists, but the value of that key is Json too
Would you be willing to provide an example?
I have a few examples, so for example we're able to get the "A"-type using typeof JsonFromString._A
which is great and all, but if we're asserting for example:
const myApiReturnsThis = JsonFromString.pipe(type({
myKey: evenMoreJson
}))
All I wanna verify is that the server returns an object with the type {myKey: typeof JsonFromString._A}
. Since we're only able to get the type
and not codec, we can't do this. making the JsonFromString
-codec a bit less useful IMO.
(More examples coming later if you're not convinced)
@merisbahti thanks (I'm convinced)
we're able to get the "A"-type using typeof JsonFromString._A
Btw there's an official util for this (TypeOf
), see TypeScript integration
you are the best 🚀
🚀 Feature request
Current Behavior
The
Json
codec is used in the definition ofJsonFromString
, but it's not exported, and it makes it hard to depend onJSONFromString
because it's useful to assert for example that "I care that this key exists, but the value of that key is Json too` https://github.com/gcanti/io-ts-types/blob/master/src/JsonFromString.ts#L27Desired Behavior
export that line.