Generic interface declaration not working as-is on typescript 0.9.5

I have an interface that defines a generic method, that returns a generic instance. For type safety I put some retractions to the type of the returned instances.

Here is some sample code:

class Animal {
}

class Dog extends Animal {
    name: string;
}

interface IGreeter {
    greet<T extends Animal>(): T;
}

class Greeter implements IGreeter {
    greet<T extends Animal>(): T {
        return new Dog();
    }
}

var dog = new Greeter().greet<Dog>();
dog.name = "Poochie";

The code above does not compile because of the error stated below. But I don't find the root cause of the error from the message, I suspect is something related to the spec, but the error message is not helpful and I can't find the response in the spec documents.

Here is the error that I get for the Greeter class:

Class Greeter declares interface IGreeter but does not implement it:
Types of property 'greet' of types 'Greeter' and 'IGreeter' are incompatible:
Call signatures of types '<T extends Animal>() => T' and
                         '<T extends Animal>() => T' are incompatible.

Finally, this code is a simplified version of a complex structure I have on a larger solution, the code worked on TypeScript 0.9.1.1 but broke after upgrading to 0.9.5.

Here is the live version with the error on the TypeScript playground

Here is the 0.9.5 spec

Finally I found a way to make it somehow-work, replacing T by Animal in the interface declaration, but I can't find why this implementation is wrong.


ANSWERS:


Your implementation is correct. Seems like a bug in TS 0.9.5. You can report it here :



 MORE:


 ? Compiled JavaScript Files Not Appearing In Visual Studio Project
 ? Is there any difference in using overloads or optional parameters in TypeScript?
 ? The property 'jqGrid' does not exist on value of type 'JQuery'
 ? Trying to convert JQuery plugin to TypeScript
 ? Cannot extend angularjs controller in typescript
 ? Angular2 routing : redirectTo a relative url
 ? Angular 2 - Check current active route "name"
 ? Manually changing the route parameters leads to inconsistent user interface
 ? knockout - trying to use data from 2 data sets in my view
 ? PostgreSQL: Converting data file string to epoch time