gpt4 book ai didi

reactjs - 除非在 '--jsx' 为 "jsx"时提供了 "react-jsx"标志,否则无法使用 JSX

转载 作者:行者123 更新时间:2023-12-03 13:59:03 26 4
gpt4 key购买 nike

typescript 抛出:

Cannot use JSX unless the '--jsx' flag is provided.ts(17004)


更改后 tsconfig.json jsxreact-jsx , jsx 有效。 yarn start将 tsconfig.json 更改为 react-jsx再次。 react-scripts已更新至 4.0.1。
包.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"
},
配置文件
{
"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"
]
}
如何解决这个问题?

最佳答案

您可以解决此问题 following way :

"Ctrl + Shift + P" or Click Typescript version at the bottom right ofthe window. TypeScript: Select TypeScript Version Use WorkspaceVersion... 4.1.2"

关于reactjs - 除非在 '--jsx' 为 "jsx"时提供了 "react-jsx"标志,否则无法使用 JSX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64965203/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com