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"
    }
  ]
}
相关推荐
唐叔在学习3 分钟前
e.preventDefault()到底怎么用?
前端·javascript
北寻北爱10 分钟前
面试题-vue篇
前端·vue.js
XPoet12 分钟前
AI 编程工程化:Skill——给你的 AI 员工装上技能包
前端·后端·ai编程
JEECG低代码平台12 分钟前
JeecgBoot低代码平台 Qiankun 微前端集成指南:主应用配置全流程
前端·低代码
木斯佳1 小时前
鸿蒙开发入门指南:前端开发者快速掌握常用布局
前端·css
咕噜咪1 小时前
OpenLayers 入门教程:从零开始学习Web地图开发
前端·学习
炽烈小老头1 小时前
前端最最最基础的基础HTML基础
前端·html
小霖家的混江龙1 小时前
仿淘宝 AI 推荐:用 Next.js 构建入门智能水果推荐 Demo
前端·人工智能·next.js
诚诚程程成1 小时前
URL Query Editor 前端开发工具:方便调试页面URL参数 URL参数可视化
前端
CHU7290351 小时前
直播逛购新体验——直播商城APP前端功能详解
前端·小程序