I have the following class which have overloading fucntion in typescript
export class Person {
private get fullName() {
return this.firstName + '' + this.lastname;
}
constructor(public firstName, public lastname) {
}
sayHi(): string;
sayHi(name: string): string;
sayHi(person: Person): string;
sayHi(obj: any) {
return '';
}
const name = new Person('jim', 'jonson');
when runing my app I get the following error :
Overload signature is not compatible with function implementation.
I change this line of code : sayHi(obj: any) to this line of code: sayHi() so now I have the following code
export class Person {
private get fullName() {
return this.firstName + '' + this.lastname;
}
constructor(public firstName, public lastname) {
}
sayHi(): string;
sayHi(name: string): string;
sayHi(person: Person): string;
sayHi() {
return '';
}
const name = new Person('jim', 'jonson');
When I run the code above there is no errors.
Can some one please explain why there is no error on this code while we can see clear in the code above that there is Overload signatures that are not compatible with function implementation.? am I missing something or what? am confused