我按照介绍中的"experimentalDecorators": true
说明做了,我在 tsconfig.json 中添加了“compilerOptions”。但是,错误仍然存在。
这是为什么?我该如何解决?
这是我的 package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.23",
"@types/node": "^15.6.0",
"@types/react": "^17.0.6",
"@types/react-dom": "^17.0.5",
"axios": "^0.21.1",
"framer-motion": "^4.1.17",
"history": "^5.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-loader-spinner": "^4.0.0",
"react-promise-tracker": "^2.1.0",
"react-redux": "^7.2.4",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"redux": "^4.1.0",
"typescript": "^4.2.4",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"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/core": "^7.14.0",
"@babel/preset-env": "^7.14.1",
"@babel/preset-react": "^7.13.13",
"autoprefixer": "^9.8.6",
"babel-loader": "^8.1.0",
"file-loader": "^6.1.1",
"url-loader": "^4.1.1"
}
}
这是我的 tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"strict": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules"
]
}
这就是我所有的配置文件。我并没有真正手动触及任何一个配置文件中的任何内容,它们都是预先生成的——"experimentalDecorators": true
当然新添加的行除外。