I want to merge two types and also keep the generics valid. for example
Type 1
interface Request<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.Request<P, ResBody, ReqBody, ReqQuery> { }
Type 2
type Auth = {
user: User
}
I want my new type to be a merge of these two, where the type can receive all those generics.
Right now I am just merging them, but then I am not able to use generics of the Request type.
Currently I am just merging these two.
export type Merge<FirstType, SecondType> = Omit<FirstType, keyof SecondType> & SecondType;
Of course I can do all this manually, but this case is repeating in my project, I want a utility method which can do this for me. For example
MergeWithGenerics<Request, Body>
Where the new type keeps all generics of the first arg.
I don't know if its possible or not, but it would be really great if someone can help me with this.
