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"
    }
  ]
}
相关推荐
水煮白菜王4 分钟前
从零搭建 React 工程化项目
前端·javascript·react.js
会飞的鱼先生9 分钟前
react的基本使用
前端·react.js·前端框架
chenglin01618 分钟前
C#_接口设计:角色与契约的分离
java·前端·c#
chenglin01627 分钟前
ES_多表关联
java·前端·elasticsearch
明月与玄武3 小时前
Vue 3 高性能实践 全面提速剖析!
前端·javascript·vue.js
童先生7 小时前
Nginx + Vue/React 前端 + API:防止路径混淆漏洞与跨域问题实战分享
前端·vue.js·nginx
Stringzhua9 小时前
Vue数据的变更操作与表单数据的收集【6】
前端·javascript·vue.js
万少10 小时前
可可图片编辑 HarmonyOS 上架应用分享
前端·harmonyos
你的人类朋友10 小时前
git常见操作整理(持续更新)
前端·git·后端
无羡仙10 小时前
Webpack 核心实战:从零搭建支持热更新与 Babel 转译的现代前端环境
前端·webpack·前端框架