
TypeScript Interface Methods vs Function Properties
In a TypeScript interface, save(): void declares a method signature. save: () => void declares a property whose value is callable. Both describe a contract; neither creates a function or binds this. There is also a type-checking difference: with strictFunctionTypes, function properties receive stricter parameter checking than method signatures. 1interface MethodContract { 2 save(): void; 3} 4 5interface PropertyContract { 6 save: () => void; 7} These are separate interfaces so we can compare the alternatives without declaring the same member twice. ...
