When handling a login operation, I receive an HTTP response like this:
interface ILoginResponse { // ok
message: string
token: string;
}
This response structure is part of a generic response format that I intend to use for all my HTTP responses:
interface IResponse<TResponseData> { // ok
Data: TResponseData;
Errors: string[];
Status: number;
}
My plan was to incorporate this generic response format into an abstract service like so:
abstract class HttpService<TRequest, IResponse<TResponseData>> { // ERROR
protected onSuccess(responseData: TResponseData); // I want to do this (hide the wrapper from the subclass)
}
I had hoped to extend this abstract service for different HTTP operations, such as a login operation:
class LoginService extends HttpService<ILoginRequest, ILoginResponse> { } // ok
However, I encountered an issue in the HttpService
class:
"Cannot find name 'TResponseData'"
.
How can I resolve this?