考虑一个带有打字稿代码的文件(例如:uid.ts):
module uid {
var id = 1;
export class Uid {
value: number;
constructor() {
this.value = id++;
}
}
}
module uid_generator {
import Uid = uid.Uid;
function generate(): Uid {
return new Uid();
}
}
尝试编译此文件(node.js,编译器版本 0.9.0.1)时出现以下错误:
$ tsc uid.ts
${HOME}/uid.ts(14,3): error TS2072: Module cannot be aliased to a non-module type.
${HOME}/uid.ts(17,16): error TS2083: Invalid 'new' expression.
根据我通过阅读语言规范的第 10.3 节“导入声明”的理解,这应该是在模块“uid_generator”中为“uid”类创建别名的正确方法。我究竟做错了什么?