So, I just added TypeScript to an existing React Native project (first commit dates from Feb 2016), and I'm getting the follwing errors when running unit tests (using Jest):
This only happens when adding ts, I've only modified three files from the project to use it as I have to go slowly because it's a huge project.
I've tried out with different setups for jest.config.js but nothing changes:
jest.config.js
const { defaults: tsjPreset } = require('ts-jest/presets');module.exports = { ...tsjPreset, globals: {'ts-jest': { babelConfig: true, } }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], modulePaths: ['<rootDir>'], preset: 'react-native', transform: { ...tsjPreset.transform,'^.+\\.(js)$': '<rootDir>/node_modules/babel-jest','^.+\\.(ts|tsx)?$': '<rootDir>/node_modules/ts-jest/preprocessor.js', }, transformIgnorePatterns: ['node_modules/(?!(texts/@debitoor/react-native-sunstone/))/'],};
tsconfig.json
{"compilerOptions": {"allowJs": true,"allowSyntheticDefaultImports": true,"baseUrl": "./app","esModuleInterop": true,"isolatedModules": true,"jsx": "react","lib": ["es2017"],"moduleResolution": "node","noEmit": true,"paths": {"common": ["./common"] },"skipLibCheck": true,"strict": false,"target": "esnext" },"exclude": ["node_modules","babel.config.js","metro.config.js","jest.config.js" ]}
I tried removing the exclude elements at same thing happens. Not sure what else I'm missing.
I also tried using ts-jest but nothing changed either.
This is the tsconfig.jest.json file:
{"extends": "./tsconfig","compilerOptions": {"jsx": "react","module": "commonjs" }}
I've searched around and in most articles/sites they always talk about starting fresh, but I've already got everything else setup and can't really change much without taking too much time.
Any ideas would be great!