Closed samhh closed 1 year ago
Given that is
requires knowing the key
and the value ahead of time, I'm not sure how we can use it to solve https://github.com/unsplash/sum-types-io-ts/pull/15 because sum-types
doesn't export accessors for the key and/or value.
// hypothetically
const unknownSerialize = (x: unknown): O.Option<readonly [unknown, unknown]> =>
pipe(
x,
O.fromPredicate(Sum.is()(x[Sum.tagKey])((a: any): a is never => true)),
O.map(Sum.serialize),
)
Perhaps there is value of having an exported fn called isAny
🤔
Thinking of how best to tackle https://github.com/unsplash/sum-types-io-ts/pull/15 going forwards I landed here. In that specific case this could be utilised something like: