TS2322 Type Element is not assignable to type ReactNode-出现在preact

出现TS2322 Type Element is not assignable to type ReactNode

  • 大部分都是ts的问题,没有识别到,目前在preact出现过这种

解决

  • tsconfig.json添加下面内容
json 复制代码
    "paths": {
      "react": ["./node_modules/preact/compat"],
      "react-dom": ["./node_modules/preact/compat"]
    }
  • tsconfig.json完整内容
java 复制代码
{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "jsxImportSource": "preact",
    "paths": {
      "react": ["./node_modules/preact/compat"],
      "react-dom": ["./node_modules/preact/compat"]
    }
  },
  "include": ["src"],
  "references": [
    {
      "path": "./tsconfig.node.json"
    }
  ]
}
相关推荐
J***Q2922 小时前
Vue数据可视化
前端·vue.js·信息可视化
ttod_qzstudio4 小时前
深入理解 Vue 3 的 h 函数:构建动态 UI 的利器
前端·vue.js
_大龄4 小时前
前端解析excel
前端·excel
一叶茶4 小时前
移动端平板打开的三种模式。
前端·javascript
前端大卫4 小时前
一文搞懂 Webpack 分包:async、initial 与 all 的区别【附源码】
前端
Want5955 小时前
HTML音乐圣诞树
前端·html
老前端的功夫5 小时前
前端浏览器缓存深度解析:从网络请求到极致性能优化
前端·javascript·网络·缓存·性能优化
Running_slave6 小时前
你应该了解的TCP滑窗
前端·网络协议·tcp/ip
程序员小寒6 小时前
前端高频面试题之CSS篇(一)
前端·css·面试·css3
颜酱6 小时前
Monorepo 架构以及工具选型、搭建
前端·javascript·node.js