报错信息如下:
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/[email protected]/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/[email protected][email protected][email protected]_/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/[email protected]/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
}
}