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"
    }
  ]
}
相关推荐
zhanlang021717 分钟前
1.2 CSS 盒模型深度剖析:标准与怪异模式的博弈
前端·css
徐同保23 分钟前
模板里的图标组件找不到定义?聊聊 @tabler/icons-vue 与自动导入
前端·javascript·vue.js
喵本喵叁肆30 分钟前
ReAct、Plan-Execute、Reflection:三种 Agent 模式实测对比
前端·react.js·前端框架
qetfw1 小时前
EVE-NG 导入 Debian 虚拟机:VMDK 转 QCOW2 与启动验证
linux·前端·debian·github
这里是北京2 小时前
HLS 播放地址有效期只有5分钟,直播到一半会断吗?
运维·前端·网络
ZHOUPUYU2 小时前
PHP 实战:从零构建一个高可用的小型 Web 应用
android·前端·php
JudithHuang2 小时前
Vue3 WebSocket 实时协作
前端·网络·websocket·网络协议·vue
云南新人和数采集团3 小时前
Chrome 扩展安全攻防实录:从权限滥用、消息劫持到供应链投毒
前端·chrome·安全
SEO_juper3 小时前
PHP 站内搜索词分析器:从买家搜的词里,挖出内容缺口
前端·javascript·node.js·json·1024程序员节
代码小学生&3 小时前
Ajax · 通用接口测试工具
前端·ajax·okhttp