Closed
Description
TypeScript Version: 3.2.0-rc
Search Terms:
strictBindCallApply, bind, overload
Code
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);
}
Expected behavior:
Not exactly sure, but not an error
Actual behavior:
Error -- see playground link
Playground Link:
Related Issues:
#28567