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"
    }
  ]
}
相关推荐
问心无愧05132 小时前
ctf show web入门160 161
前端·笔记
李小白662 小时前
第四天-WEB服务器基本原理,IIS服务
运维·服务器·前端
humcomm3 小时前
AI编程时代新前端职位
前端·ai编程
好家伙VCC3 小时前
Web Components主题热切换方案揭秘
java·前端
甲维斯4 小时前
Kimi版超级玛丽效果“惊人”,配额不足5厘米!
前端·人工智能
hboot4 小时前
AI工程师第一课 - Python
前端·后端·python
凉菜凉凉4 小时前
AI时代,被抛弃的前端
前端·ai
console.log('npc')4 小时前
AI前端工程与生成式UI学习路线
前端·人工智能·ui
梦曦i4 小时前
uni-router v1.1.1发布:守卫超时保护+路由监听
前端·uni-app
qq_2518364575 小时前
基于java Web网络订餐系统设计与实现 源码文档
java·开发语言·前端