打字稿投:
除非'-- JSX‘标志是provided.ts(17004),否则不能使用jsx。
在将tsconfig.json jsx更改为react-jsx之后,jsx工作。yarn start再次将tsconfig.json更改为react-jsx。
react-scripts更新为4.0.1。
package.json
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"semantic-ui-css": "^2.4.1",
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^14.14.9",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint-config-react": "^1.1.7",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"typescript": "^4.1.2"
},tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}怎么解决这个问题?
发布于 2020-11-30 10:45:06
您可以修复这个跟随方式
"Ctrl + Shift + P“或单击窗口右下角的打字本版本。TypeScript:选择TypeScript版本使用工作区版本.4.1.2“
发布于 2020-12-10 08:10:11
这是因为一个新的错误,这是vscode和类型记录之间的不匹配。如果其他解决方案不起作用,我将tsconfig.json中的tsconfig.json更改为
"include": [
"./src/**/*.ts"
]https://stackoverflow.com/questions/64965203
复制相似问题