1

Closed

function returning void implements interface function returning any

description

Description

If an interface has a function that returns any then a function on a class that returns void matches the interface and appears to invalidly fulfill the interface. This bug reproduces on the current playground and in the v0.8.3.0 build.

Repro steps

  1. Enter this code into foo.ts
interface IFoo {
  bar(): any;
}

class Foo implements IFoo {
  public bar(): void {      
  }
}
  1. > tsc foo.ts

Expected:

An error telling me that Foo does not implement the interface IFoo.

Actual

No error occurs
Closed Mar 6, 2013 at 10:38 PM by paulb
This is by design We don't enforce the return type when implementing an interface.

comments