Microsoft/TypeScript
Auf GitHub ansehenInterface Overload Generic Member - Compiler error when removing overload
Open
#51.370 geöffnet am 1. Nov. 2022
BugDomain: check: Type InferenceHelp Wanted
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
Bug Report
Removing an overload member Controller.handle from Controller causes a compilation error.
🔎 Search Terms
- Interface overload
- Member Type Parameter
- Works When Removing overload
⏯ Playground Link
💻 Code
Code below compiles
export interface Controller {
handle<T>(httpRequest: HttpRequest<T>): HttpResponse<T>;
handle<TRequest, TResponse>(httpRequest: HttpRequest<TRequest>): HttpResponse<TResponse>;
}
Code below does not compile
export interface Controller {
// handle<T>(httpRequest: HttpRequest<T>): HttpResponse<T>;
handle<TRequest, TResponse>(httpRequest: HttpRequest<TRequest>): HttpResponse<TResponse>;
}
Code below does not compile
export interface Controller {
handle<T>(httpRequest: HttpRequest<T>): HttpResponse<T>;
// handle<TRequest, TResponse>(httpRequest: HttpRequest<TRequest>): HttpResponse<TResponse>;
}
🙁 Actual behavior
Code does not compile when removing any of the overloads.
🙂 Expected behavior
Since having an overload in Controller.handle works, having just one member with the correct signature should also work.