Next.js、TypeScript 和 tsconfig.json 'jsx' 属性 被覆盖

Next.js, TypeScript and tsconfig.json 'jsx' property being overwritten

当运行开发服务器时,如何阻止jsx属性被NextJS从'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"
  ]
}

据我所知,jsx 选项必须是 react 才能将我的 tsx 文件编译为 jsx

在这里回答:

https://github.com/kulshekhar/ts-jest/issues/937

基本上,您将当前的 tsconfig.json 扩展为一个专门用于开玩笑的 tsconfig.json,然后从您的 jest.config.js.

中引用 tsconfig.json