I basically want to implement left | right join of two objects looking at their types. For example, object config of default type RequestInit.
config = {
headers: {
'Content-Type': 'application/json',
},
}
And I have a customized customConfig of type, for example, CustomRequestInit that contains additional query params, which I later will join with url.
customConfig = {
mode: 'cors',
headers: {
'Content-Type': 'application/json',
},
params: {
'tk': '2edr3q2afa3',
}
}
This object has properties from RequestInit class, they should overwrite same properties in config object. Other properties from customConfig mustn't be in the final config object. How do I left join this two objects by their types, ommitting additional keys that CustomRequestInit brings in?
It is a bit unclear what you are trying to achieve.
This type adds properties from B which are missing in A (only adds new properties).
type AddMissing<A, B> = A & Omit<B, keyof A>;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.