[3.2.0-rc] .bind with overloads causes compile error in strict mode (strictBindCallApply) · Issue #28582 · microsoft/TypeScript (original) (raw)
class Logger { static debug(message: string, ...params: any[]): void; static debug(context: object | undefined, message: string, ...params: any[]): void; static debug(contextOrMessage: object | string | undefined, ...params: any[]): void { // ... }
static log(message: string, ...params: any[]): void; static log(context: object | undefined, message: string, ...params: any[]): void; static log(contextOrMessage: object | string | undefined, ...params: any[]): void { // ... } }
// @log decorator function log(debug: boolean) { // ... const logFn = debug ? Logger.debug.bind(Logger) : Logger.log.bind(Logger);
// ...
// Errors with Argument of type 'string' is not assignable to parameter of type 'object | undefined' // NOTE: This doesn't error without the .bind() call above logFn("message", 1, 2, 3); }