Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Next.js、TypeScript和tsconfig.json';jsx&x27;正在覆盖的属性_Reactjs_Typescript_Next.js_Tsconfig - Fatal编程技术网

Reactjs Next.js、TypeScript和tsconfig.json';jsx&x27;正在覆盖的属性

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,

在运行开发服务器时,如何阻止NextJS将
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”}