This project is read-only.


Type error with generics not detected


The problem is explained inline.
interface IPromise<T> {
    next<R>(success: (value: T) => R): IPromise<R>

class Promise<T> implements IPromise<T> {
    value: T;
    constructor(value: T) {
        this.value = value;
    next<R>(success: (value: T) => R): IPromise<R> {
        return new Promise(success(this.value));

var promise = new Promise(42);
function success(value: number): number {
    // The line below should have a type error. `notexisting` is not defined
    // on a number. Line 21 is just below:
    return value.notexiting();

// Comment out this line and the compiler will complain about the type error
// on line 21.
var next =;
This code in the playground
Closed Jul 12, 2013 at 1:10 AM by danquirk
This appears to be fixed in the latest bits in the develop branch. I always see an error on line 21.