1
私はインターフェイスを実装しますが、私は次のエラーを取得していたクラスのコンストラクタをオーバーロードしようとした:TypeScriptで実装されたインターフェイスでコンストラクタオーバーロードを実行するにはどうすればよいですか?
[0] app/foo.ts(12,5): error TS2394: Overload signature is not compatible with function implementation.
クラス
export interface Item {
time: number;
}
export class Foo implements Item {
public time: number;
public name: string;
constructor();
constructor(
time: number,
name: string
) {
this.time = id || -1
this.name = name || ""
};
}
を私は他の同様の質問を見つけました(Constructor overload in TypeScript )しかし、それは動作しないので、私は何かが不足しています。 typscriptのバージョンは1.8.9です。