Skip to content

[Bug Report] Vant Uploader 在库模式 dts 生成场景下触发 TS2742 #13818

@hezhengxu2018

Description

@hezhengxu2018

Reproduction Link

Vant Version

4.9.24

Describe the Bug

我在消费 Vant Uploader 做二次封装时,遇到了一个只发生在声明生成阶段的问题。

希望:公开 d.ts 不再依赖 csstype 的外部命名

Reproduce Steps

Vant 源码里的 ImageFit用的是 ImageFit

这个类型在最终声明里会变成 csstype.Property.ObjectFit
当我自己封装的组件做了 v-bind 和 slot 转发,dts 生成时 Volar 会产出 __VLS_template、__VLS_component 这种匿名推导类型这些匿名类型里混入了 Uploader 的完整公开类型图,TypeScript 发现这里需要引用 .pnpm/csstype... 这样的内部路径,于是认为这个类型“不可移植”,就报错。

目前暂时通过

import { Uploader as RawUploader } from 'vant'
const VanUploader = RawUploader as unknown as DefineComponent<Record<string, unknown>>

隐藏了对外部的声明暴露,但也只是一个临时的解决方案

Device / Browser

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions