I have a Typescript declaration file that looks like the following:
/// <reference types="node" />
declare namespace foo {
interface bar {
}
}
declare const foo: foo.bar;
export = foo;
This compiles just fine with TS 2.0/2.2. However, if the namespace contains any class
whatsoever - e.g. changing bar
to a class, adding another class bam
, etc. - Typescript throws an error TS2300: Duplicate identifier 'foo'.
, for the two declare lines. The goal of the code as written is to take advantage of Declaration Merging in Typescript, and when foo
contains only interface
s, the code works as expected (type
s seem fine to include in foo
, too). Why does declaration merging fail if foo
contains any class
es?