I am trying to add TypeScript to a React-Native Expo project and get the following error if I rename any file abc.js to abc.tsx:
I have been following the instructions at:
- https://facebook.github.io/react-native/blog/2018/05/07/using-typescript-with-react-native
- https://medium.com/@rintoj/react-native-with-typescript-40355a90a5d7
How can I address this?
rn-cli.config.js
module.exports = {
getTransformModulePath() {
return require.resolve('react-native-typescript-transformer');
},
getSourceExts() {
return ['ts', 'tsx', 'js', 'jsx'];
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"jsx": "react",
"outDir": "./dist",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
//"strict": true,
"skipLibCheck": true,
"declaration": true,
"noUnusedLocals": true
},
"exclude": [
"node_modules"
]
}