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"
    }
  ]
}
相关推荐
reasonsummer6 分钟前
【办公类-120-01】20260812闵行区幼儿园概况表的数据统计(户籍、五类性质、优抚子女)
前端·python
宿6749 分钟前
vue3-指令和事件处理
开发语言·前端·javascript
风骏时光牛马19 分钟前
AI助手异常问题Debug排查
前端
梦想的旅途225 分钟前
企业微信API实战:Python自动化消息推送
java·前端·python·自动化·企业微信
恋猫de小郭25 分钟前
Flutter 3.47 发布,快来看看有什么更新吧
android·前端·flutter
程序员黑豆25 分钟前
Java 内存存储机制:基本数据类型 vs 引用数据类型
前端·ai编程·全栈
90后的晨仔36 分钟前
uni-app 三方库与插件管理体系全解析:从原生开发者视角彻底讲透
前端
程序员爱钓鱼40 分钟前
Rust 生命周期案例详解:从编译错误到真实业务场景
前端·后端·rust
90后的晨仔1 小时前
uni-app 跨端布局与适配技术指南
前端
紫禁玄科10 小时前
Shai-Hulud:npm生态的自我复制蠕虫风暴
前端·npm·node.js