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"
    }
  ]
}
相关推荐
QN1幻化引擎5 分钟前
Gravity-Anchored Cognitive Field Architecture: The DalinX V8/V10 Implementation
java·前端·算法
光影少年10 分钟前
react的View/Text/Image/ScrollView 常用组件注意事项
开发语言·前端·javascript·react.js·前端框架
yangmu320317 分钟前
前端性能优化实战:我是如何将首屏加载时间缩短 40% 的?
前端·性能优化
IT_陈寒24 分钟前
JavaScript的隐式类型转换又双叒坑了我一次!
前端·人工智能·后端
JarvanMo27 分钟前
HTTP的DELET方法能不能有Body?
前端
天蓝色的鱼鱼33 分钟前
扔掉 ESLint + Prettier:Biome 全家桶实战
前端
533_1 小时前
[element-plus] el-tabs和el-menu联动
前端·javascript·vue.js
小呀小叮当~1 小时前
Telegram 有哪些实用功能?一文了解
前端·人工智能·后端·其它
索西引擎1 小时前
【React】React Fiber 架构:设计动机、核心机制与调度策略分析
前端·react.js·架构
雨季mo浅忆1 小时前
上传文件夹
前端·vue3