TS2322 Type Element is not assignable to type ReactNode-出现在preact

出现TS2322 Type Element is not assignable to type ReactNode

  • 大部分都是ts的问题,没有识别到,目前在preact出现过这种

解决

  • tsconfig.json添加下面内容
    "paths": {
      "react": ["./node_modules/preact/compat"],
      "react-dom": ["./node_modules/preact/compat"]
    }
  • tsconfig.json完整内容
{
  "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"
    }
  ]
}

相关推荐

  1. visual studio 2022 使用open3d出现的问题及解决方式

    2024-04-03 09:52:02       11 阅读
  2. ts中const和readonly区别?

    2024-04-03 09:52:02       23 阅读
  3. vue项目中使用TS

    2024-04-03 09:52:02       15 阅读
  4. Linux中tomcat出现乱码

    2024-04-03 09:52:02       40 阅读
  5. 创建vue3 ts项目 tsc.configvscode下标红

    2024-04-03 09:52:02       28 阅读
  6. React和Preact 这样处理className更优雅

    2024-04-03 09:52:02       48 阅读
  7. Ubuntu开机出现Welcome to emergency mode解决办法

    2024-04-03 09:52:02       62 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-03 09:52:02       5 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-03 09:52:02       5 阅读
  3. 在Django里面运行非项目文件

    2024-04-03 09:52:02       4 阅读
  4. Python语言-面向对象

    2024-04-03 09:52:02       7 阅读

热门阅读

  1. 平台介绍-大屏组件

    2024-04-03 09:52:02       21 阅读
  2. Facebook推广常见问题解惑答疑

    2024-04-03 09:52:02       22 阅读
  3. SegmentAnything导出Onnx模型分割图片

    2024-04-03 09:52:02       23 阅读
  4. 120.单例模式(C++设计模式)

    2024-04-03 09:52:02       20 阅读
  5. 【Node】使用Node.js构建简单的静态页面生成器

    2024-04-03 09:52:02       22 阅读
  6. 工厂方法模式:灵活的创建对象实例

    2024-04-03 09:52:02       25 阅读
  7. WPF —— 关键帧动画

    2024-04-03 09:52:02       25 阅读
  8. Yolov5封装detect.py面向对象

    2024-04-03 09:52:02       19 阅读
  9. Rancher(v2.6.3)——Rancher部署Minio(单机版)

    2024-04-03 09:52:02       17 阅读
  10. STM32为什么不能跑Linux?

    2024-04-03 09:52:02       20 阅读
  11. 菜鸟笔记-Python函数-ones

    2024-04-03 09:52:02       25 阅读