在使用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