Sometimes, we want to fix the Typescript ‘Duplicate function implementation’ error.
In this article, we’ll look at how to fix the Typescript ‘Duplicate function implementation’ error.
How to fix the Typescript ‘Duplicate function implementation’ error?
To fix the Typescript ‘Duplicate function implementation’ error, we should make sure we didn’t define the same function multiple times.
For instance, we write
class C {
public emit<T1>(event: string, arg1: T1): void;
public emit<T1, T2>(event: string, arg1: T1, arg2: T2): void;
public emit(event: string, ...args: any[]): void {
// ...
}
}
to add the emit
method to class C
with different signatures and return types to overload the method.
We only have the curly braces in the last line and we put our function implementation code in there.
Conclusion
To fix the Typescript ‘Duplicate function implementation’ error, we should make sure we didn’t define the same function multiple times.