目录

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"
    }
  ]
}
本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
华洛12 分钟前
千问7B模型完胜deepseek V3,全靠我一手微调!
前端·javascript·程序员
简 洁 冬冬24 分钟前
004 Vue Cli脚手架(vue2)
前端·vue.js
不会笑的卡哇伊25 分钟前
😋1分钟 新增i18n新语种,按完回车就下班 !!!
前端
苏卫苏卫苏卫25 分钟前
【Vue】选项卡案例——NBA新闻
开发语言·前端·javascript·css·vue.js·笔记
XH27625 分钟前
Android 使用SAX解析XML格式数据
前端·后端
程序员黄同学25 分钟前
谈谈策略模式,策略模式的适用场景是什么?
前端·javascript·策略模式
石小石Orz26 分钟前
AI 剧本生成与动画创作-基于阿里云的解决方案
前端·ai编程
姑苏洛言27 分钟前
【踩坑】Vue 2 项目使用 fabric 5.x 版本
前端
大王棒棒的27 分钟前
Vue3项目生产环境增量打包,提高构建速度
前端·javascript·vue.js
前端小趴菜0527 分钟前
UniApp Vue 3 中的网络请求封装及用法
前端·vue.js·uni-app