問題:
解決方案:
在每個ts文件的開頭添加:
export {};
就解決了 ^^
官方的解釋:
Typescript is moduler and each module has it’s own block. So, basically if you could somehow enclose the variable which is declared as let within it’s own module, the error will be resolved because now your let variable is in it’s separate block.
To achieve this, simply type export on the top of your script or additionally you can type export {}. Now you will see that the error is resolved.
蹩腳翻譯:
Typescript是模塊化的凄敢,同時每個模塊都有自己的代碼塊皮璧。所以,基本上在一定程度上let可以讓所有的變量都
在一個模塊中。如果你把變量放到單獨的代碼塊中捐晶,那么問題將很快被解決。
要實現(xiàn)這個恨憎,只要在你的腳本頂部寫下export{}〕В現(xiàn)在你將看到問題已經被解決了。