-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue
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
damonmaria
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue