如何将名称空间与类型记录外部模块一起使用?我有一些密码:棒球类型export namespace Living.Things {
export class Animal {
move() { /* ... */ }
}
export class Plant {
photosynthesize() { /* ... */ }
}}狗仔import b = require('./baseTypes');export namespace Living.Things {
// Error, can't find name 'Animal', ??
export class Dog extends Animal {
woof() { }
}}树// Error, can't use the same name twice, ??import b = require('./baseTypes');import b = require('./dogs');namespace Living.Things {
// Why do I have to write b.Living.Things.Plant instead of b.Plant??
class Tree extends b.Living.Things.Plant {
}}这一切都很混乱。我想让一堆外部模块都为同一个命名空间贡献类型,Living.Things..似乎这根本行不通-我看不见Animal在……里面dogs.ts..我必须写完整的命名空间名称b.Living.Things.Plant在……里面tree.ts..跨文件将同一名称空间中的多个对象组合起来并不有效。我该怎么做?
添加回答
举报
0/150
提交
取消
