I
I
Ivan Simonov2021-09-22 12:43:35
typescript
Ivan Simonov, 2021-09-22 12:43:35

How to pass any type using generics?

Good afternoon
I'm trying to deal with generics
There are 2 types
1.TUserInfo

type TUserInfo = {
   id: num,
   readonly fname: string,
   readonly lname: string
}

2.TBody
type TBody = {
   success: boolean,
   user?: any
}


Tell me how to TBodypass any type (for example, TUserInfo). And the same type should be y userinsteadany

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2021-09-22
@ivan00007

type TBody<T> = {
   success: boolean;
   user?: T;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question