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"
    }
  ]
}
相关推荐
hoLzwEge6 小时前
node-linker VS shamefully-hoist
前端·前端框架
袋鱼不重6 小时前
解决 Web 端图片预览与下载颜色不一致的一种工程方案
前端·后端
风止何安啊6 小时前
教你用 JS + AI 实现简单的爬虫,零门槛爬取网页信息
前端
cidy_986 小时前
codebase-memory-mcp 新手完全教程:让 AI 真正「理解」你的代码库
前端
牛奶6 小时前
HTTPS你不知道的事
前端·https·浏览器
小小小小宇6 小时前
前端 Vue 如何避免不必要的子组件渲染全解析
前端
cidy_987 小时前
codebase-memory-mcp 安装教程
前端
mt_z7 小时前
Webpack 与 Vite 完全指南
前端
灏仟亿前端技术团队7 小时前
B 端多弹窗越来越难维护?试试把弹窗交互 Promise 化
前端
奇奇怪怪的7 小时前
向量数据库选型与生产级实战
前端