TypeScript の同じモジュールに追加された 2 つ以上のファイルに 2 つ以上のクラスを何らかの方法で追加できるかどうか疑問に思っています。このようなもの:
//src/gui/uielement.ts
module mylib {
module gui {
export interface UIElement {
public draw() : void;
}
}
}
//src/gui/button.ts
///<reference path='uielement.ts'/>
module mylib {
module gui {
export class Button implements UIElement {
constructor(public str : string) { }
draw() : void { }
}
}
}
おそらく数十の GUI クラスが存在するため、それらすべてを同じファイルに含めることはできません。そして、私のクラスはすべて「mylib」モジュールになります。しかし、どうすればいいですか?
module mylib {...}
が関数に変換される場合、mylib
すべてのファイル内のすべてのブロックのすべてのコンテンツが同じ関数内に含まれている必要があります。
これはまったく可能ですか?
コンパイルすると、次のようになります。
$ tsc src/gui/button.ts
src/gui/button.ts(4,39): The name 'UIElement' does not exist in the current scope