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"
    }
  ]
}
相关推荐
CoderYanger2 分钟前
Java EE 进阶:4.Spring Web MVC 入门(第一弹)
java·开发语言·前端·spring·面试·java-ee·mvc
用户2788607285673 分钟前
fallback 会盖掉平台提示词:system、空数组和 systemAppend 的差别
前端·后端
peach5 分钟前
大模型和传统编程:同为程序,差异不在硬件,在"逻辑从哪来"
前端
ALONE阿龙太原微码14 分钟前
微信小程序包体积优化:2MB 到 400KB 的实操记录
前端
掘金挖土16 分钟前
前端手摸手跑路之 AI 应用开发(十一)
前端·后端
创了么OPC18 分钟前
小程序能收款了,对公户还没开?独立开发者的交付闭环踩坑②
前端·微信小程序
IT_陈寒19 分钟前
Vue动态组件缓存的坑你踩过了吗?
前端·人工智能·后端
寂寞狼牙冷32 分钟前
封装fetch替换axios
前端
用户461169657281 小时前
网站 HTTPS 不稳定?证书排查指南
前端
n87651 小时前
Playwright Java WEB UI 自动化实现框架与逻辑
java·前端·ui