【问题标题】:Next.js, TypeScript and tsconfig.json 'jsx' property being overwrittenNext.js、TypeScript 和 tsconfig.json 'jsx' 属性被覆盖
【发布时间】:2020-09-10 09:51:42
【问题描述】:

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

【问题讨论】:

    标签: reactjs typescript next.js tsconfig


    【解决方案1】:

    在这里回答:

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

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

    【讨论】:

    • 对于任何想知道如何扩展其当前 tsconfig.json 的人:tsconfig.test.json { "extends": "./tsconfig.json", "compilerOptions": { "jsx": "react" } }
    猜你喜欢
    • 1970-01-01
    • 2020-02-22
    • 2020-01-14
    • 2013-01-19
    • 2020-05-13
    • 2020-11-01
    • 2015-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多