【发布时间】:2015-09-10 11:05:20
【问题描述】:
我想要实现的是有这样的布局:
// Shape.ts
module Shape {
export interface Shape {
area(): number;
}
}
// Rectangle.ts
module Shape {
export class Rectangle implements Shape {
constructor(private x:number, private y: number) {}
area(): number {
return this.x * this.y;
}
}
}
// Square.ts
module Shape {
export class Square implements Shape {
constructor(private x:number) {}
area(): number {
return Math.pow(this.x, 2);
}
}
}
// geometry.ts
/// <reference path="Shape.ts" />
/// <reference path="Rectangle.ts" />
/// <reference path="Square.ts" />
export = Shape.Rectangle;
export = Shape.Square;
我在常规内部模块中的代码最多。而且,为了构建一个 Node.js 模块,我有一个外部模块,它导出所有的东西,旨在供 Node 模块用户使用。
但目前,当我调用 tsc -m commonjs --outFile geometrylib.js geometry.ts 时,我得到一个 geometrylib.js 没有任何 module.exports 语句,因为它应该在 CommonJS 构建中。
当前版本的 TypeScript 是否有可能?
pstsc --version 给我message TS6029: Version 1.6.0-beta。
【问题讨论】:
标签: javascript node.js typescript