Javascript 是否可以将多个内部模块组合到一个外部模块?

Javascript 是否可以将多个内部模块组合到一个外部模块?,javascript,node.js,typescript,Javascript,Node.js,Typescript,我想要实现的是这样的布局: // 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) {}

我想要实现的是这样的布局:

// 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;
//Shape.ts
模块形状{
导出接口形状{
面积():数字;
}
}
//矩形
模块形状{
导出类矩形实现形状{
构造函数(私有x:number,私有y:number){}
区域():编号{
返回这个.x*this.y;
}
}
}
//Square.ts
模块形状{
导出类Square实现形状{
构造函数(私有x:number){}
区域():编号{
返回Math.pow(this.x,2);
}
}
}
//几何
/// 
/// 
/// 
导出=形状。矩形;
导出=形状.Square;
我在常规内部模块中拥有最多的代码。另外,为了构建Node.js模块,我有一个外部模块,用于导出所有内容,供Node模块用户使用

但目前,当我调用
tsc-m commonjs--outFile geometrylib.js geometry.ts
时,我得到了一个
geometrylib.js
,没有任何
module.exports
语句,就像它在commonjs构建中应该得到的那样

使用当前版本的TypeScript是否可能

ps
tsc--version
给我
消息TS6029:version 1.6.0-beta

是否可以将多个内部模块组合到一个外部模块

而不是

export = Shape.Rectangle;
export = Shape.Square;
你可以做:

export = Shape;
但是,我建议您不要混合使用内部和外部模块。。。正如您的消费者尊重
npm
并接受
commonjs

@)--