You cannot do this in classes, but you can do it with a regular function:
interface I {
(name: string): void;
}
var C: I = function(name: string) {
};
C("test");
C(1);
Then, if you change your interface, you will be notified of a compilation error to change the function C.
source
share