Difference Of Typescript Function Declaration In Interfaces
What is the difference between these two declarations of functions in TypeScript Interfaces? interface IExample { myFunction(str: string): void; } and interface IExample { myF
Solution 1:
These declarations are completely equivalent.
The only relevant difference here is that the second form can't be used for function overloads:
// OKinterfaceExample {
myFunction(s: string): void;
myFunction(s: number): void;
}
// Not OKinterfaceExample {
myFunction: (s: string) =>void;
myFunction: (s: number) =>void;
}
Post a Comment for "Difference Of Typescript Function Declaration In Interfaces"