0

我正在尝试使用 ts 编译器的最新开发版本编译以下代码,但出现以下错误:

错误 TS2137:类 test.CacheService 声明了接口 test.ICache 但没有实现它:

使用 0.9.1.1 编译器可以正常工作。有谁知道可能是什么问题?再次感谢

module test {
export interface ICache {
    //indexer: [name: string]: any;
    get<T>(key: string): T;
    set(key: string, value: any);
}

export class CacheService implements ICache {
    private _cache: any = {};

    get<T>(key: string): T {
        //if (!key) {
        //    var tmp: T;
        //    if ($.isArray(tmp))

        return <T>this._cache[key];
    }

    set(key: string, value: any) {
        this._cache[key] = value;
    }
}
}
4

1 回答 1

1

Looks like this is just a compiler bug (bisected to commit 38ffe2b730585b49e4792d20468 which went in a few weeks ago). If T is used in the parameter list, the compiler accepts the code. I've logged a bug.

于 2013-11-12T01:56:20.677 回答