Is there a semantic difference in defining a method of an interface using function syntax compared to lambda syntax?

Topics: General, Language Specification
Mar 26, 2014 at 3:16 PM
Edited Mar 26, 2014 at 3:43 PM
Trying my best to pick the right terminology:
  • Is there a semantic difference in defining a method of an interface using function syntax compared to lambda syntax?
  • If so, is this by design?
Consider an external module:
// some interface with a method
export interface Foo {
    bar(): void;
}

// function at a module level with the same name as the method but different signature
export function bar(value: string): void {
}

var one: Foo = {
    bar() {
        bar('Hey!'); // doesn't work
    }
};

var another: Foo = {
    bar: () => bar('Hey!') // works
};
Developer
Mar 26, 2014 at 6:10 PM
Edited Mar 26, 2014 at 6:10 PM
Looks like a bug, they should be equivalent. This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.