現在我真的試圖合併來自d.ts 實例命名空間:打字稿megring命名空間
當我試圖在一個文件中megre命名空間,一切都很好。
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;
但是當我提出第一個命名空間來test.d.ts - 一切都是brokes
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'.
我遇到了這個問題,當我添加新的我Thom to Electron,Angular2等類型。 例子:
在電子/ index.d.ts
declare namespace Electron {
interface App extends NodeJS.EventEmitter {
...
}
}
在我的文件test.ts
declare namespace Electron {
interface App extends NodeJS.EventEmitter {
isQuiting?: boolean;
}
}
我得到這個錯誤:TS2339:房產 'isQuiting'在'App'類型上不存在。
我可以合併自定義名稱空間與d.ts?
你能告訴一個示例實現? – MixerOID
例如文件** test.ts ** 'import {importClass} from「。/someFile.ts」 申報命名空間電子{ 接口應用擴展NodeJS.EventEmitter { isQuiting?:布爾; }} 出口類SomeClass的{ }' 不得包含出口\ import指令 – Vlad
但我不能導入/導出!我導入電子和其他庫文件,並與他一起工作。這種變種爲「沒有文件 - 沒有問題」 – MixerOID