我有一个打字稿声明文件看起来像以下:打字稿 - 声明合并为命名空间与类
/// <reference types="node" />
declare namespace foo {
interface bar {
}
}
declare const foo: foo.bar;
export = foo;
这将编译只是TS 2.0/2.2的罚款。但是,如果命名空间包含任何class
- 例如改变bar
一类,加入另一class bam
等 - 打字稿引发错误TS2300: Duplicate identifier 'foo'.
,对于两个DECLARE线。作为编写的代码的目的是利用宣言的打字稿合并,而当foo
只包含interface
S,代码工作正常(type
小号似乎罚款foo
包括,太)。为什么声明合并失败,如果foo
包含任何class
上课?