Skip to content

fix(PinInput): remove default generic type #4346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playground/app/pages/components/pin-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import theme from '#build/ui/pin-input'
const sizes = Object.keys(theme.variants.size) as Array<keyof typeof theme.variants.size>
const variants = Object.keys(theme.variants.variant) as Array<keyof typeof theme.variants.variant>

const onComplete = (e: string[]) => {
const onComplete = (e: string[] | number[]) => {
console.log(e)
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/components/PinInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type PinInputEmits<T extends PinInputType = 'text'> = PinInputRootEmits<T

</script>

<script setup lang="ts" generic="T extends PinInputType = 'text'">
<script setup lang="ts" generic="T extends PinInputType">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this change is necessary there should be no default here. However, the playground should work with just string[] since the default type is text ๐Ÿค”

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was looking into but not there are no string[] | number[] definition. The Reka UI component defines it like this: type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]. This should work, I'm confused ๐Ÿ˜…

Copy link
Author

@KIM-DONGJU KIM-DONGJU Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked into this as well, and it does correctly infer the type of the complete event when type="text" is explicitly specified, like in <UPinInput type="text" @ complete="onComplete" />.
However, I'm also unsure why TypeScript fails to infer the correct type when relying on the default type value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamincanac
Additionally, could you let me know the estimated release schedule for the version that includes reka-ui 2.3.1 (e.g., 3.1.4)?
Currently, it seems there's an issue where, in the current version, when the PinInput type is set to number, trying to clear the value results in it changing to 0 instead of being cleared.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KIM-DONGJU I'll make a release this week for sure!

Did you find a way to make this work? Not sure if we can merge this as is ๐Ÿ˜ฌ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iโ€™ve been juggling a few things on my end, so I havenโ€™t been able to give this the attention it deserves. Iโ€™ll look into it more thoroughly soon.

import type { ComponentPublicInstance } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { PinInputInput, PinInputRoot, useForwardPropsEmits } from 'reka-ui'
Expand Down