Generic & intersection
I'm looking to have a helper
arkWithMetadata
, which basically takes a base type and add { metadata: { id: <id> }}
I wanted to write this :
But it doesn't work.
I want to retain both types doc
and id
.
Is there a way to do that ?
I also tried to write a function :
But it doesn't work either 🤷♂️
PS: I'm using v2.0.0-rc.18
12 Replies
Type deos have
withMetadata
or smth@Dimava of course not, that's just some business name
I just want a generic type that can be expressed in the form of an intersection
In my case it's a validator named
arkWithMetadata
that takes two arguments, a Type
representing some kind of record, and a Type
that extends string
.
The TypeScript equivalent is :
You are looking for .merge I guess
how does that play with a generic ?
I mean '.and' does not work as & on objects iirc
Or does it
I assumed it does too
Anyways does this work?
Btw, is there an equivalent for
merge
? Because an intersection is not the same, although it works for me here
Let me try
It works perfectly ! You are a beast 😄
do you want me to open another topic for my question about merge
vs &
?Check the docs maaaaaybe its there idk
Otherwise yes
are you the author of the lib ?
Nah I'm contributor
Has been hitting every pipe edge case bug is the last month
oh yeah, I've seen the issues on GH ^^
nope, nothing about
merge