-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 3.7.x-dev.201xxxxx ("nightly" on http://www.typescriptlang.org/play/)
Search Terms:
typescript parameters of overloading function interface
Code
interface LogFn {
// move lines oreder to see different behavior
(msg: string, ...args: any[]): void;
(obj: object, msg?: string, ...args: any[]): void;
}
class Logger {
private readonly logger!: LogFn;
log(...args: Parameters<LogFn>) {
this.logger(...args);
}
}
const loggerInstance = new Logger();
loggerInstance.log('test');
^^^^^^ Argument of type '"test"' is not assignable to parameter of type 'object'.(2345)
loggerInstance.log({});
Expected behavior:
Parameters<FnInterface>
should return all types of arguments
Actual behavior:
Parameters<FnInterface>
return only last overload arguments type
Related Issues:
ikokostya
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created