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"
    }
  ]
}
相关推荐
深蓝AI1 天前
Meta 开源用了八年的设计系统 astryx:连坐两天 GitHub 总榜第一,组件库开始写给 agent 的说明书
前端·人工智能
IT_陈寒1 天前
Vue的watch把我坑惨了,原来要这样用才靠谱
前端·人工智能·后端
1-1=01 天前
Vue 3 模板语
前端·javascript·vue.js
用户7610304473711 天前
【转战智能眼镜开发】ROKID AIUI 小游戏 亚马逊标枪项目实战讲解
前端
风卿1 天前
看着AI写代码太孤独了,来欣赏星云吧:一个DSH 装饰插件
前端·javascript
牧艺1 天前
弹层不用再手算坐标了:CSS Anchor Positioning 从原理到可上线
前端·javascript·css
用户老李1 天前
YOLO 目标检测自学教程 07:YOLOv3——多尺度预测
前端
moshuying1 天前
ESP32 墨水屏金价牌(上):从点亮到把图片推过去
前端
李剑一1 天前
别再抬杠,前端岗已经没了!无论前后端,我们最终都要成“全干”工程师
前端·面试
Highcharts.js1 天前
Highcharts 仪表盘与速度仪图表库介绍
前端·信息可视化·仪表板·highcharts·图表开发·图表库·仪表可视化