Trying to execute a function expression in this format:
export default interface IUserManager {
deleteUser: ((userId: string) => Promise<void>) | ((userName: string, userSurname: string, city: string) => Promise<void>)
}
from within a class containing the interface instance:
import MyUserManager from "path/to/IUserManager.ts"
class CompanyProcessor {
private myUserManager: IUserManager;
public constructor() {
this.myUserManager = new MyUserManager(); // MyUserManager implements IUserManager
}
public async deleteUser(userId: string): Promise<void> {
await this.myUserManager.deleteUser(userid); // Error: Expected 3 arguments, but only provided 1. ts(2554)
}
}
In VSCode, when hovering over the function expression in IUserManager, it displays a tuple of functions. However, hovering over the function call in CompanyProcessor only shows the largest function in the tuple. Making "userSurname" and "city" optional seems to work in CompanyProcessor, but it breaks the requirement for 3 properties, allowing only the first 2 to be provided. Additionally, it does not utilize the other functions in the tuple in this manner.
Example hover pop-up in original scenario:
(property) IUserManager.deleteUser: (userName: string, userSurname: string, city: string) => Promise<void>
Example hover pop-up with "userSurname" and "city" as optional:
(property) IUserManager.deleteUser: (userName: string, userSurname?: string, city?: string) => Promise<void> (+1 overload)
Running TypeScript version 4.7.4