pnpm monoreop 打包时 node_modules 内部包 typescript 不能推导出类型报错

报错信息如下:

md 复制代码
../../packages/antdv/components/pro-table/src/form-render.vue:405:1 - error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/scroll-into-view-if-needed@2.2.31/node_modules/scroll-into-view-if-needed'. This is likely not portable. A type annotation is necessary.

405 export default (await import('vue')).defineComponent({
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 setup() {
    ~~~~~~~~~
... 
412 __typeEl: {} as __VLS_TemplateResult['rootEl'],
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413 });
    ~~~
../../packages/antdv/components/pro-table/src/form-render.vue:405:1 - error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/vue-types@3.0.2_vue@3.5.13_typescript@5.8.2_/node_modules/vue-types'. This is likely not portable. A type annotation is necessary.

405 export default (await import('vue')).defineComponent({
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 setup() {
    ~~~~~~~~~
... 
412 __typeEl: {} as __VLS_TemplateResult['rootEl'],
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413 });

he inferred type of 'default' cannot be named without a reference to '.pnpm/scroll-into-view-if-needed@2.2.31/node_modules/scroll-into-view-if-needed'. This is likely not portable. A type annotation is necessary.

看了一下lock文件,scroll-into-view-if-needed,vue-types这两个依赖主要是ant-design-vue使用的,为什么会报错呢,因为之前vue的版本是3.4.x,现在整到了3.5.13,降到 3.4.x就没问题了

根据这个报错搜索了一下,看到的解决方案就是把报错的包在 tsconfig.json配置一下

json 复制代码
{
  "compilerOptions": {
    "target": "ESNext",
    "jsx": "preserve",
    "jsxImportSource": "vue",
    "lib": ["ESNext"],
    "baseUrl": ".",
    "module": "ESNext",
    "moduleResolution": "Node",
    // 在这配置一下
    "paths": {
      "scroll-into-view-if-needed": ["node_modules/scroll-into-view-if-needed"],
      "vue-types": ["node_modules/vue-types"]
    },
    "resolveJsonModule": true,
    "strict": true,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "preserveSymlinks": true,
    "skipLibCheck": true
  }
}
相关推荐
竹林8185 小时前
用ethers.js连接MetaMask实现Web3钱包登录:从踩坑到稳定运行的完整记录
前端·javascript
心连欣5 小时前
从零开始,学习所有指令!
前端·javascript·vue.js
openKaka_8 小时前
从 scheduleUpdateOnFiber 到 Root 微任务调度:React 如何把更新交给调度系统
开发语言·前端·javascript
LIO8 小时前
一文读懂 Vue 3:核心特性、组合式 API 与最佳实践
前端·vue.js
前进的李工8 小时前
智能Agent实战指南:记忆组件嵌入技巧(记忆)
开发语言·前端·javascript·python·langchain·agent
IOT.FIVE.NO.18 小时前
Codex Skill 内部结构解析:从 SKILL.md 到 scripts、references、assets
前端·javascript·人工智能·笔记·html
daols8810 小时前
vue甘特图vxe-gantt如何实现拖拽任务条时如有已关联依赖线,同时更新依赖任务的日期的方式
javascript·vue.js·甘特图
我命由我1234510 小时前
前端开发概念 - 无障碍树
javascript·css·笔记·学习·html·html5·js
ZC跨境爬虫10 小时前
跟着 MDN 学 HTML day_29:(动态构建与更新 DOM 树)
前端·javascript·ui·html·html5·媒体