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"
    }
  ]
}
相关推荐
林恒smileZAZ2 小时前
Vue<前端页面版本检测>
前端·javascript·vue.js
码事漫谈5 小时前
当AI开始“思考”:我们是否真的准备好了?
前端·后端
许杰小刀5 小时前
ctfshow-web文件包含(web78-web86)
android·前端·android studio
我是Superman丶6 小时前
Element UI 表格某行突出悬浮效果
前端·javascript·vue.js
恋猫de小郭6 小时前
你的代理归我了:AI 大模型恶意中间人攻击,钱包都被转走了
前端·人工智能·ai编程
xiaokuangren_6 小时前
前端css颜色
前端·css
hoiii1877 小时前
C# 基于 LumiSoft 实现 SIP 客户端方案
前端·c#
anOnion7 小时前
构建无障碍组件之Meter Pattern
前端·html·交互设计
小码哥_常7 小时前
Spring Boot配置diff:解锁配置管理新姿势
前端
小码哥_常7 小时前
告别onActivityResult!Android数据回传的3大痛点与终极解决方案
前端