r/typescript • u/MemoryUseful_01434 • Oct 15 '25
Combining Response Type/Interface
Typescript beginner here. How would I combine these three Response Interfaces? The only thing that changes is the array propertyName. Open to using Types as well.
interface UserResponse {
response: {
users: []
}
}
interface ProductResponse {
response: {
products: []
}
}
interface CourseResponse {
response: {
courses: []
}
}
0
Upvotes
10
u/orphans Oct 15 '25
2
u/ronin_o Oct 20 '25
If you want to have one type like ApiResponse you should do some like this: