Yes
CRA ^2.0.6-next.c662dfb0 with TypeScript support
npx create-react-app --scripts-version @next myappcd myappyarn add typescript @types/react @types/react-dom @types/jestmv src/index.{js,tsx}src/setupProxy.js with following content:const proxy = require('http-proxy-middleware')
module.exports = function(app) {
app.use(proxy('/api', { target: 'http://localhost:5000/' }))
}
yarn run buildsetupProxy.js should be compiled without any problems.
Behold the "Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. TS1208" error message.
Additionally: if one were to rewrite the setupProxy.js script with proper ES6 exports like this:
const proxy = require('http-proxy-middleware')
export const setupProxy = (app) => {
app.use(proxy('/api', { target: 'http://localhost:5000/' }))
}
yarn run build compiles successfully, while yarn run start claims "unexpected token export".
Thanks for the report!
You are right. For now, please add this line to your tsconfig.json:
"exclude": ["src/setupProxy.js"]
Let me know if that fixes the issue for you.
Yes, that works for me.
JSON imports are also broken, exclude is not helping.
Should be fixed in 2.1, out now: https://github.com/facebook/create-react-app/releases/tag/v2.1.0
@Timer it does not work in 2.1.1 for us. Workaround is working fine.
Most helpful comment
Thanks for the report!
You are right. For now, please add this line to your
tsconfig.json:"exclude": ["src/setupProxy.js"]Let me know if that fixes the issue for you.