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"
    }
  ]
}
相关推荐
kyriewen1 小时前
我装了30多个Skill,给AI安排了8个岗位
前端·javascript·ai编程
风骏时光牛马1 小时前
大模型落地实践中的技术选型思路与方案对比
前端
IT_陈寒2 小时前
Vite打包时的静态资源坑,我帮你踩过了
前端·人工智能·后端
默_笙3 小时前
🔥 让 AI 帮我写完整个 Next.js 博客:框架就是 AI 的"上下文 buff"
前端·javascript
牧艺3 小时前
登录页还在用渐变?我一口气做了 5 个能摸的背景动效:吹蒲公英、滴墨染水、点熔岩闷裂
前端·canvas·交互设计
陆枫Larry3 小时前
状态机简介
前端
陆枫Larry4 小时前
一次登录问题排查:接口没错,错的是旧业务逻辑
前端
小小小小宇4 小时前
大模型打分与采样原理,以及 Pi Agent 核心原理
前端
一位正在转型AI全栈的前端工程师4 小时前
AI 全栈学习之旅 -Week 5:RAG 知识库问答系统:从零到生产级部署的全栈实践总结
前端·python
光影少年5 小时前
react navite 安卓iOS 打包、签名、环境区分
前端·react native·react.js