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;
}
Baca Juga
- How Can I Increase A Number By Activating A Button To Be Able To Access A Function Each Time The Button Is Increased?
- What Is Missing From This Description For Nested Functions And Closures At Mozilla Developer Network?
- In Javascript V8 Does Compilation Phase Happen To Functions Before Execution Phase Then All The Code Is Executed Or Only For Global Context
Post a Comment for "Difference Of Typescript Function Declaration In Interfaces"