I'm running yarn test on a project and I get the following error:
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export { default as a11yDark } from './a11y-dark';
^^^^^^
SyntaxError: Unexpected token 'export'
1 | import React, { PureComponent } from "react";
2 | import SyntaxHighlighter from "react-syntax-highlighter";
> 3 | import { idea } from "react-syntax-highlighter/dist/esm/styles/hljs";
my tsconfig.json is as follows:
"compilerOptions": {
"target": "es6",
"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-jsx",
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
}
I'm using ts-jest and my jest.config.js is set as:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
and my package.json:
{
"name": "client",
"version": "0.1.0",
"private": true,
"engines": {
"node": "14.15.0"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.32",
"#fortawesome/free-brands-svg-icons": "^5.8.1",
"#fortawesome/free-solid-svg-icons": "^5.15.1",
"#fortawesome/react-fontawesome": "^0.1.4",
"#types/jest": "26.0.15",
"#types/node": "14.14.7",
"#types/node-fetch": "^2.5.7",
"#types/react": "17.0.0",
"#types/react-dom": "17.0.0",
"#types/react-router-dom": "5.1.6",
"#types/react-syntax-highlighter": "13.5.0",
"bootstrap": "^4.5.3",
"hydrogen": "0.2.0",
"node-fetch": "^2.6.1",
"react": "17.0.1",
"react-app-polyfill": "2.0.0",
"react-dom": "17.0.1",
"react-ga": "3.3.0",
"react-markdown": "5.0.3",
"react-router-dom": "5.2.0",
"react-scripts": "4.0.1",
"react-syntax-highlighter": "15.3.1",
"tslint": "^6.1.3",
"typescript": "4.1.2",
"url-search-params-polyfill": "8.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "tsc --noEmit -p . && react-scripts test --all",
"eject": "react-scripts eject",
"lint": "tslint --project ."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"#types/enzyme": "^3.10.8",
"#types/enzyme-adapter-react-16": "^1.0.6",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "^1.15.5"
}
}
not really sure on what am I doing wrong here, I've tried configuring jest and typescript but I got nowhere.
The answer was importing the module as commonjs instead of esm, as:
import idea from "react-syntax-highlighter/dist/cjs/styles/hljs/idea";
Related
I'm getting this error message:
./src/Home/home.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/Home/home.scss)
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (108)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v6.0.1
Here is my is my package.json:
{
"resolutions": { "react-error-overlay": "6.0.9" },
"dependencies": {
"#reduxjs/toolkit": "^1.6.1",
"#types/node": "^12.0.0",
"#types/react": "^17.0.0",
"#types/react-dom": "^17.0.0",
"#types/react-router-dom": "^5.1.8",
"node-sass": "^6.0.1",
"react": "^17.0.2",
"react-content-loader": "^6.0.3",
"react-dom": "^17.0.2",
"react-loading-skeleton": "^2.2.0",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-toastify": "^7.0.4",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"devDependencies": {
"#nomiclabs/hardhat-ethers": "^2.0.2",
"#nomiclabs/hardhat-etherscan": "^2.1.5",
"#nomiclabs/hardhat-waffle": "^2.0.1",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"#types/jest": "^26.0.15",
"chai": "^4.3.4",
"colors": "^1.4.0",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.5",
"hardhat": "^2.6.2",
"hardhat-deploy": "^0.9.3",
"react-scripts": "5.0.1"
},
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "./build.sh",
"build1": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build",
"testui": "react-scripts test",
"eject": "react-scripts eject",
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"clean": "rm -rf build/static/js/*.map",
"clean-win": "del build/static/js/*.map",
"local": "npx hardhat run --network localhost scripts/deploy-eth.js",
"ftm": "npx hardhat run --network ftm scripts/deploy-ftm.js",
"tftm": "npx hardhat run --network tftm scripts/deploy-ftm.js",
"btc": "npx hardhat run --network btc scripts/deploy.js",
"tbtc": "npx hardhat run --network localhost scripts/deploy.js"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"`your text`
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}`
}
This is my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "es6", "es2017", "es2020", "dom"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noEmit": true,
"jsx": "react-jsx",
"isolatedModules": true,
"noImplicitAny": false
},
"include": [
"src"
],
"typeRoots": [
"./node_modules/#types",
"./src/#types"
]
}
If you know about it, please send me answer.
Thank you.
I nearly searched every topic in google but it looks like it changes with the config and version.
I am having trouble with ES6 imports. I did everything I can, I checked ts-jest and jest github issues and whole stackoverflow but couldn't get it done. Maybe I am forgetting something? I am still getting this error:
SyntaxError: Cannot use import statement outside a module
I really don't know what else to do...
my babel.config.js
module.exports = api => {
const isTest = api.env('test');
// You can use isTest to determine what presets and plugins to use.
return {
presets: [
[
'#babel/preset-env',
'#babel/preset-typescript',
{
targets: {
node: 'current',
},
},
],
],
env: {
test: {
plugins: [
"transform-es2015-modules-commonjs"
]
}
}
};
};
jest.config.js
module.exports = {
preset: 'ts-jest',
rootDir: "./",
testEnvironment: "node",
globals: {
'ts-jest': {
tsconfig: {
jsx: 'react',
isolatedModules: true
},
},
},
testPathIgnorePatterns: ['/dist', '<rootDir>/src/assets'],
transform: {
'^.+\\.ts?$': 'ts-jest',
},
moduleNameMapper: {
"\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/src/__mocks__/fileMock.js",
"^#common(.*)$": "<rootDir>/src/common$1",
},
collectCoverage: true,
verbose: true,
};
my package.json
{
"name": "project",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"#types/jest": "^26.0.15",
"#types/node": "^12.0.0",
"#types/react": "^17.0.0",
"#types/react-dom": "^17.0.0",
"dayjs": "^1.10.7",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.13.0",
"react-scripts": "4.0.3",
"react-select": "^5.1.0",
"react-spinners": "^0.11.0",
"sp-rest-proxy": "^3.1.1",
"typescript": "^3.6.4",
"web-vitals": "^1.0.1"
},
"scripts": {
"serve": "node server.js",
"start": "webpack-dev-server --mode development --open --hot",
"build": "webpack --mode production",
"test": "npx jest",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/preset-env": "^7.16.0",
"#babel/preset-react": "^7.16.0",
"#babel/preset-typescript": "^7.16.0",
"awesome-typescript-loader": "^5.2.1",
"babel-core": "7.0.0-beta.3",
"babel-jest": "^27.3.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"css-loader": "^3.2.0",
"file-loader": "^6.2.0",
"jest": "26.4.2",
"react-test-renderer": "^17.0.2",
"style-loader": "^1.0.0",
"ts-jest": "26.3.0",
"ts-loader": "^9.2.6",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.4.0"
}
}
and lastly tsconfig
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es5",
"lib": [
"es2015",
"es2017",
"ES6",
"dom"
],
"types": [
"jest"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"baseUrl": "./",
"paths": {
"#common/*": [
"src/common/*"
],
"#components/*": [
"src/components/*"
],
"#webparts/*": [
"src/WebParts/*"
],
}
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}```
I updated react-scripts#^4.0.3 as well as typescript#~3.7.2 to the latest however when I run npm run start I get the following error :
ReferenceError: Cannot access {variable name} before initialization
I'm aware of "Temporal Deadzones" however this app has had no problem with declaring exports for arrow functions like this, in fact, we declare most/all of our functions in this syntax:
export const someFunc = () => {}
Now it's only allowing me to export after declaration like this:
function someFunction(){} -or- const someFunction = () => {}
export { someFunction }
Question: How can I allow for the export shorthand function expression syntax, with these new package updates?
Filename: tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"es2015",
"dom",
"dom.iterable",
"esnext"
],
"jsx": "react",
"baseUrl": "src",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"allowJs": true,
"noEmit": true,
"skipLibCheck": true,
"isolatedModules": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": [
"src"
],
"exclude": [
"./node_modules"
],
"extends": "./tsconfig.paths.json"
}
Filename: tsconfig.paths.json
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"#src": ["*"],
"#pages": ["pages"],
"#pages/*": ["pages/*"],
"#hooks": ["core/hooks"],
"#hooks/*": ["core/hooks/*"],
"#components": ["core/components"],
"#components/*": ["core/components/*"],
"#containers": ["containers"],
"#containers/*": ["containers/*"],
"#services": ["core/services"],
"#services/*": ["core/services/*"],
"#configs": ["core/configs"],
"#configs/*": ["core/configs/*"],
"#assets": ["core/assets"],
"#assets/*": ["core/assets/*"],
"#models": ["core/models"],
"#models/*": ["core/models/*"],
"#store": ["core/store"],
"#store/*": ["core/store/*"],
"#utils": ["core/utils"],
"#utils/*": ["core/utils/*"],
"#styles": ["core/styles"],
"#styles/*": ["core/styles/*"]
}
}
}
Filename: craco.config.js
const CracoAlias = require("craco-alias")
module.exports = {
plugins: [
{
plugin: CracoAlias,
options: {
source: "tsconfig",
baseUrl: "./src",
tsConfigPath: "./tsconfig.paths.json"
}
}
]
}
Filename: package.json
{
"name": "ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"#craco/craco": "^6.1.2",
"#prettier/plugin-xml": "^0.12.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.1.2",
"#types/bootstrap": "^4.5.1",
"#types/classnames": "^2.2.11",
"#types/debug": "^4.1.5",
"#types/jest": "^24.9.1",
"#types/jquery": "^3.5.5",
"#types/lodash": "^4.14.168",
"#types/node": "^12.19.15",
"#types/react": "^16.14.2",
"#types/react-dom": "^16.9.10",
"#types/react-helmet": "^5.0.16",
"#types/react-redux": "^7.1.15",
"#types/react-router-dom": "^5.1.7",
"#types/react-select": "^3.1.2",
"#types/react-table": "^7.0.27",
"bootstrap": "^4.6.0",
"classnames": "^2.2.6",
"core-js": "^3.12.1",
"debug": "^4.3.1",
"file-selector": "^0.1.19",
"husky": "^4.3.8",
"i18next": "^19.8.4",
"immer": "^6.0.9",
"jquery": "^3.5.1",
"lint-staged": "^10.5.3",
"node-sass": "^4.14.0",
"prettier": "^2.2.1",
"react": "^17.0.2",
"react-bootstrap": "^1.4.3",
"react-dom": "^16.14.0",
"react-dropzone": "^10.2.2",
"react-helmet": "^6.1.0",
"react-i18next": "^11.8.5",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-select": "^3.1.1",
"react-table": "^7.6.3",
"redux-thunk": "^2.3.0",
"typescript": "~3.7.2"
},
"scripts": {
"start": "BROWSER=none craco start",
"build": "npm run check && craco build",
"test": "craco test",
"coverage": "CI=true npm test -- --colors --coverage",
"check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md,xml,svg}\"",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md,xml,svg}\"",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"coverageReporters": [
"text",
"html"
],
"moduleNameMapper": {
"react-i18next": "<rootDir>/__mocks__/react-i18next.js",
"^file-loader": "<rootDir>/__mocks__/file-loader.js"
},
"resetMocks": false
},
"prettier": {
"singleQuote": true,
"jsxSingleQuote": true
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md,xml,svg}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"#babel/core": "^7.14.3",
"craco-alias": "^3.0.0"
}
}
I'm writing my first application using React+TypeScript.
I'm very confused about why my Visual Studio Code show completly different Type Checking than the same code in CodeSandbox.
Here is what my VSC shows: [props.direction as any]
And here is corect way in CodeSandbox: [props.direcion as FlexProps].
Link to Codesanbox from where I got this example:
https://codesandbox.io/s/funny-frost-1bxwk?file=/src/Heading.tsx
When I rewrite the code in this way, everything is ok:
export const Flex = styled.div`
display: flex;
flex-direction: ${(props : FlexProps) => props.direction}
`
However if interface FlexProps has more types, I will have to repeat them on each line separately. So is not good way for me.
my package.json:
{
"name": "interactive-visited-countries-map-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.11.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/jest": "^24.0.0",
"#types/node": "^12.0.0",
"#types/react": "^16.9.0",
"#types/react-dom": "^16.9.0",
"#types/styled-components": "^5.1.2",
"#typescript-eslint/eslint-plugin": "^4.1.1",
"#typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"eslint-plugin-react-hooks": "^4.0.8",
"lodash.sortby": "^4.7.0",
"node-sass": "^4.14.1",
"normalize.css": "^8.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"react-tooltip": "^4.2.7",
"styled-components": "^5.1.1",
"styled-icons": "^10.19.0",
"svg-url-loader": "^6.0.0",
"typescript": "^4.0.2",
"typescript-styled-plugin": "^0.15.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/lodash.sortby": "^4.7.6",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.1.1"
}
}
and tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "es2015", "es2017", "dom.iterable"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": false,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"downlevelIteration": true,
"declaration": true,
"noImplicitAny": false,
"plugins": [
{
"name": "typescript-styled-plugin"
}
]
},
"include": ["src", "**/*.ts"]
}
Solution:
I've solved a problem.
In react-app-env.d I have
<reference types="react-scripts" />
declare module "styled-components";
I deleted
declare module "styled-components"
and It seems to work fine
Is it possible to use export * from './X' with absolute import paths and eslint in react/typescript? I wanted to have single index.ts file in components folder that would export everything else but eslint gives me weird error when i'm trying to do this.
My current structure looks like this:
src/components/Example1/Example1.tsx
import React from 'react';
export type Props = {};
export const Example1 = (props: Props) => <div></div>
src/components/Example1/index.ts
export * from './Example1';
src/components/index.ts
export * from './Example1';
Both index files gives me error:
0:0 error Parsing error: Cannot read property 'name' of undefined
Also when i try to import anything from the components/index file using an absolute path import { Example1 } from 'components'; i have an error:
1:43 error Parse errors in imported module 'components': Cannot read property 'name' of undefined (undefined:undefined) import/namespace
1:43 error Parse errors in imported module 'components': Cannot read property 'name' of undefined (undefined:undefined) import/named
This is my .eslintrc.json file
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"root": true,
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:#typescript-eslint/eslint-recommended",
"plugin:import/warnings",
"plugin:import/errors",
"plugin:import/typescript",
"prettier/#typescript-eslint",
"prettier",
"prettier/react"
],
"plugins": [
"react",
"react-hooks",
"jsx-a11y",
"#typescript-eslint",
"prettier"
],
"parser": "#typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"moduleDirectory": ["node_modules", "src/"]
}
}
},
"rules": {
"prettier/prettier": "error",
"import/newline-after-import": "error",
"no-unused-vars": "off",
"#typescript-eslint/no-unused-vars": [
"warn",
{ "args": "after-used", "argsIgnorePattern": "^_" }
]
}
}
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",
"baseUrl": "./src"
},
"include": ["src"]
}
My current package.json:
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"private": true,
"dependencies": {
"#apollo/react-hooks": "^3.1.3",
"#material-ui/core": "^4.9.5",
"#material-ui/icons": "^4.9.1",
"#material-ui/styles": "^4.9.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/jest": "^24.0.0",
"#types/material-ui": "^0.21.7",
"#types/node": "^12.0.0",
"#types/react": "^16.9.0",
"#types/react-dom": "^16.9.0",
"#types/react-router-dom": "^5.1.3",
"#types/styled-components": "^5.0.1",
"#types/yup": "^0.26.32",
"apollo-boost": "^0.4.7",
"env-cmd": "^10.1.0",
"formik": "^2.1.4",
"graphql": "^14.6.0",
"i18next": "^19.3.3",
"i18next-browser-languagedetector": "^4.0.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-i18next": "^11.3.3",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"styled-components": "^5.0.1",
"typescript": "~3.7.2",
"yup": "^0.28.3"
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^2.23.0",
"#typescript-eslint/parser": "^2.23.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build:staging": "env-cmd -f .env.staging yarn build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "tsc --noEmit && eslint . --ext .js,.tsx,.ts --max-warnings=0",
"lint:fix": "eslint . --ext .js,.tsx,.ts --fix",
"watch": "react-scripts start",
"deploy": "yarn build && firebase deploy",
"deploy:staging": "yarn build:staging && firebase use staging && firebase deploy"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I'm also using lerna with yarn workspaces to easily handle MERN app.
Deleting eslint package / configs, node_modules did not help me, i still have Cannot read property 'name' of undefined error. It is super weird because in clean CRA everything works. I spent last 4 hours trying to solve this problem and finally used a workaround with importing types to root index file and reexporing them as new type but it's definately a painful solution. I need to keep isolatedModules. Maybe someone had similar problem?
The problem was #typescript-eslint package, check out the issue for more info:
https://github.com/typescript-eslint/typescript-eslint/issues/1746
Fast fix for this is to downgrade packages to version 2.22.0:
#typescript-eslint/eslint-plugin
#typescript-eslint/parser
#Edit This helped with lint error but my CRA build is still crashing, I guess i will have to wait for package fix