假设我有一个这样的命名空间:
export namespace Foo1 {
export namespace Foo2 {
export namespace Foo3 {
export interface Foo4 {}
export interface Foo5 {}
}
}
}
在 .ts 文件中,我有这样的内容:
import {Foo1} from './foo';
const bar1 = function(){
type t = Foo1.Foo2.Foo3.Foo4;
}
const bar2 = function(){
type t = Foo1.Foo2.Foo3.Foo5;
}
这可能会有点冗长,我希望做这样的事情:
import {Foo1} from './foo';
type Foo3 = Foo1.Foo2.Foo3; // <<< this don't work, I get an error explained below
const bar1 = function(){
type t = Foo3.Foo4;
}
const bar2 = function(){
type t = Foo3.Foo5;
}
但我似乎无法存储对命名空间的引用,我只能存储对类型的引用?(我得到的错误是命名空间 Foo2 没有导出的成员 Foo3)。