radix-vue / radix-vue

Vue port of Radix UI Primitives. An open-source UI component library for building high-quality, accessible design systems and web apps.
https://radix-vue.com
MIT License
2.77k stars 149 forks source link

feat: export CalendarRoot props #916

Closed RayGuo-ergou closed 2 weeks ago

RayGuo-ergou commented 2 weeks ago

Description

Export typo MultipleCalendarRootProps and SingleCalendarRootProps used by CalendarRootProps.

Motivation

I was working on build an UI library based on radix-vue/shadcn-vue, this error shows up when build:

image

This seems a typescript limitation that interface of type alias should also be exposed.

I have also tried:

interface CalendarRootProps extends MultipleCalendarRootProps, SingleCalendarRootProps {
}

which will also work because it's an interface, but I think they are not functionally equivalent.

zernonia commented 2 weeks ago

Thanks for the PR @RayGuo-ergou ! Can you share more details of the error you are having? It's weird that such error being thrown, as internally the component should be able to refer those types correctly.

RayGuo-ergou commented 2 weeks ago

It's only happening when the build reference and expose this type for my library. e.g. I have the props type

// types.ts
export type MyProps = CalendarRootProps & {
  ...
}
// index.ts

export type * from './types'

or even just use in Calendar.vue, because the build will create a type declare file for each component, will also see this error.

I will create a reproduction repo later.

RayGuo-ergou commented 2 weeks ago

Hi @zernonia, here's a reproduction of this issue: https://github.com/RayGuo-ergou/radix-reproduction

It's actually caused by th vite-plugin-dts because that plugin is to generate type declare files.

RayGuo-ergou commented 2 weeks ago

image

After manually export the type: image