The following StackOverflow answer told me how to use react-app-rewired to import JavaScript files from outside the src
folder, without ejecting the app:
https://stackoverflow.com/a/55298684/377011
However, when using this with a Typescript file outside of the src
folder (i.e. import * from '../../myfile.ts'
), I get the following error:
Module not found: Can't resolve 'ts-loader' in '...\myapp'
So I installed ts-loader
(yarn add ts-loader
), but now I'm getting
Error: TypeScript emitted no output for ...\myapp\src\index.tsx
noEmit
is set to true
in my tsconfig.json
.
Any idea?
Edit: This is my tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}