youzan / vant

A lightweight, customizable Vue UI library for mobile web apps.

Home Page:https://vant-ui.github.io/vant/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug Report] vant-cli TS 打包报错:type of '__vue_sfc__' cannot be named without a reference

LomyCool opened this issue · comments

commented

重现链接

https://codesandbox.io/p/github/LomyCool/test-css-bind/main?file=%2Fpackage.json&workspaceId=b692d5d9-9349-485b-b45a-aff272de85c1

Vant 版本

"@vant/cli": "^7.0.1",

描述一下你遇到的问题。

当定义了props变量,打包时会报错:
error TS2742: The inferred type of 'vue_sfc' cannot be named without a reference to '.pnpm/@VUE+shared@3.4.21/node_modules/@vue/shared'. This is likely not portable. A type annotation is necessary.
`<script setup lang="ts">
import { computed } from 'vue';
defineOptions({ name: 'DemoButton' })

//当定义了props变量,打包时会报错,
const props = defineProps({
width: {
type: String,
default: '100px'
},
})
// const width = 100px
const height = 100px
const calcWidth = computed(() => {
return props.width
})
</script>`
图片

重现步骤

1.封装组件,使用TS+setup ;定义一个props
const props = defineProps({
width: {
type: String,
default: '100px'
},
})
2.打包

设备/浏览器

No response