2013-06-20 61 views
1

我有一個打字稿外部定義文件(foo.d.ts):爲什麼導入TypeScript模塊不允許使用現有的模塊擴展?

declare module foo { 
    export class bar { 
    } 
} 

然後我用它像這樣(在baz.ts):

/// <reference path="foo.d.ts" /> 
module foo { 
    class baz extends bar { 
    } 
} 

到目前爲止好。但是,當我輸入編譯爲AMD的模塊編譯減免一些其他的打字稿文件:

module foo { 
    class baz extends bar { // Error: could not find symbol "bar" 
    } 
} 

import T1 = module("test1"); // Removing this line resolves the compilation error 

被導入的AMD文件是一個簡單的:

export var NAME = "NAME"; 

有誰知道這是故意的嗎?爲什麼import以這種方式破壞我的代碼?

回答

3

我認爲打字稿編譯器存在一個錯誤。

請嘗試以下, 刪除了參考 「參考路徑=」 foo.d.ts」 並添加

import f = module("foo.d"); 
module foo { 
    class baz extends f.foo.bar { 
    } 
} 

我不知道怎麼會輸出.js文件。但是這樣做這在視覺工作室中沒有給出錯誤。

相關問題