I have a React project using TypeScript, and in the main tsx file, the import React from 'react' line works fine. However in my test file, it's still triggering the TS1259 error. I'm guessing there is something funky with my TS/Jest/Babel config, but can't seem to pin it down.
Anybody know what the issue is?
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"target": "ES2019",
"moduleResolution": "node",
"module": "ESNext",
"allowJs": true,
"noEmit": true,
"strict": true,
"isolatedModules": true,
"esModuleInterop": true,
"strictNullChecks": true,
"jsx": "react",
"baseUrl": "./",
"types": []
},
"include": [
"index.d.ts",
"src/*.ts",
"src/*.tsx",
"src/**/*.ts",
"src/**/*.tsx"
]
}
jest.config.js
module.exports = {
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.ts'],
moduleNameMapper: {'^.+\\.s?css$': 'identity-obj-proxy'},
transform: {'^.+\\.tsx?$': 'babel-jest'},
testRegex: '/__tests__/.*\\.test\\.tsx?$',
testURL: 'http://localhost',
setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
setupFiles: [],
testPathIgnorePatterns: [
'__snapshots__',
'__mocks__',
'<rootDir>/scripts',
],
};
Error message in Jest test file
No error in main component file

