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"
    }
  ]
}
相关推荐
AI周红伟11 小时前
事件分析:FDE标准,“OpenClaw+RAG+Agent” 应用实战的标准
前端·人工智能·chrome·chatgpt·aigc
Mike_jia11 小时前
Databasus:开源数据库备份革命的里程碑,企业级数据安全的守护神
前端
恋猫de小郭11 小时前
真正的跨平台 AI 自动化框架,甚至还支持鸿蒙
android·前端·flutter
IT_陈寒11 小时前
Redis的LRU淘汰策略坑了我一天血汗
前端·人工智能·后端
晓得迷路了11 小时前
栗子前端技术周刊第 132 期 - date-fns 支持 Temporal、npm 攻击事件、VoidZero...
前端·javascript·css
雨季mo浅忆11 小时前
记录Vue3项目中的各类问题
前端·bug·vue3
亿元程序员12 小时前
Cocos游戏开发中的弯的箭头游戏效果
前端
ct97812 小时前
Promise
前端·javascript·vue.js
怕浪猫12 小时前
Electron 开发实战(十一):自动更新机制|服务架构、公私网更新、版本回滚全解
前端·javascript·electron
AI视觉网奇12 小时前
three-bvh-csg glb分割
开发语言·前端·javascript