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"
    }
  ]
}
相关推荐
C_心欲无痕1 小时前
前端实现水印的两种方式:SVG 与 Canvas
前端·安全·水印
尾善爱看海4 小时前
不常用的浏览器 API —— Web Speech
前端
美酒没故事°5 小时前
vue3拖拽+粘贴的综合上传器
前端·javascript·typescript
jingling5556 小时前
css进阶 | 实现罐子中的水流搅拌效果
前端·css
悟能不能悟7 小时前
前端上载文件时,上载多个文件,但是一个一个调用接口,怎么实现
前端
可问春风_ren8 小时前
前端文件上传详细解析
前端·ecmascript·reactjs·js
羊小猪~~9 小时前
【QT】--文件操作
前端·数据库·c++·后端·qt·qt6.3
晚风资源组10 小时前
CSS文字和图片在容器内垂直居中的简单方法
前端·css·css3
Miketutu10 小时前
Flutter学习 - 组件通信与网络请求Dio
开发语言·前端·javascript
光影少年12 小时前
前端如何调用gpu渲染,提升gpu渲染
前端·aigc·web·ai编程