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 分钟前
新手指南:快速理清独立仓库 Java 8 多模块项目依赖并运行
前端·后端
蓝银草同学9 分钟前
前端转 Java,第一篇看懂 pom.xml:Maven 依赖管理从入门到不懵
前端·后端
彦为君11 分钟前
JavaSE-11-网络编程(详细版)
java·前端·网络·ai·ai编程
HjhIron13 分钟前
从三件套到模块化:前端开发的底层思维
前端·后端
yingyima16 分钟前
Kubernetes CronJob 速查手册:核心语法与实战示例
前端
麻雀飞吧19 分钟前
TqWebHelper 本地监控:图表不刷新与端口冲突排查
前端·python
用户524388559288720 分钟前
拆解Vue2源码-01 reactive
前端
ZC跨境爬虫28 分钟前
跟着 MDN 学CSS day_10:(博客页面样式修复实战挑战)
前端·css
宋浮檀s32 分钟前
DVWA通关教程2
运维·服务器·前端·javascript
前端爆冲1 小时前
基于SSE实现AI聊天场景的流式输出
前端·ai编程