Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided.


在使用create-react 構件的TS項目時如果我們想導入一個普通的 .js文件會有以下報錯

Failed to compile
C:/Users/JH55692/rendition_ui/public/readership/adobe/AppMeasurement.js
Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. TS1208


網上都說可以通過 修改 tsconfig.json 中的 "isolatedModules": false 來解決
但是我試了發現沒用,還是要用一個空的導出在普通的 .js文件最后來解決,如下:
export {
    // Use an empty export to please Babel's single file emit.
}

 

其實好像還有別的方法.詳見:https://github.com/Microsoft/TypeScript/issues/15230


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM