Currently, I am attempting to combine namespaces from d.ts files.
For example, when I attempt to merge namespaces in a single file, everything works as expected.
declare namespace tst {
export interface info {
info1: number;
}
var a: info;
}
declare namespace tst {
export interface info {
info2: number;
}
}
tst.a.info1 = 1;
tst.a.info2 = 1;
However, when I move the first namespace to a test.d.ts file - things start breaking.
test.d.ts
declare namespace tst {
export interface info {
info1: number;
}
var a: info;
}
index.ts
/// <reference path="test.d.ts" />
declare namespace tst {
export interface info {
info2: number;
}
}
// Module to control application life.
tst.a.info1 = 1;
tst.a.info2 = 1; // Error:(31, 7) TS2339: Property 'info2' does not exist on type 'info'.
I encountered this issue when I added a new method to types like Electron and Angular2.
For instance, in electron/index.d.ts
declare namespace Electron {
interface App extends NodeJS.EventEmitter {
...
}
}
In my file test.ts
declare namespace Electron {
interface App extends NodeJS.EventEmitter {
isQuiting?: boolean;
}
}
This caused an error: TS2339: Property 'isQuiting' does not exist on type 'App'.
Is it possible to merge custom namespaces with d.ts files?