Reactjs Next.js、TypeScript和tsconfig.json';jsx&x27;正在覆盖的属性
在运行开发服务器时,如何阻止NextJS将Reactjs Next.js、TypeScript和tsconfig.json';jsx&x27;正在覆盖的属性,reactjs,typescript,next.js,tsconfig,Reactjs,Typescript,Next.js,Tsconfig,在运行开发服务器时,如何阻止NextJS将jsx属性从“react”覆盖为“preserve” 我的tsconfig.json文件: "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "strict": false,
jsx
属性从“react”覆盖为“preserve”
我的tsconfig.json
文件:
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}
AFAIK jsx选项必须是react
,才能将我的tsx
文件编译为jsx
回答如下:
基本上,您可以使用一个专门用于jest的扩展来扩展当前的
tsconfig.json
,然后从jest.config.js
中引用该tsconfig.json
,tsconfig.test.json{“扩展”:“/tsconfig.json”,“编译器选项”:{“jsx”:“react”}