Skip to content
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

[BUG] - Typescript, extendVariants not allowed variant array #3530

Closed
conduongtong opened this issue Jul 22, 2024 · 1 comment · Fixed by #3559
Closed

[BUG] - Typescript, extendVariants not allowed variant array #3530

conduongtong opened this issue Jul 22, 2024 · 1 comment · Fixed by #3559
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@conduongtong
Copy link

conduongtong commented Jul 22, 2024

NextUI Version

2.4.6

Describe the bug

I cannot use variant type string[] with extendVariants like code below:

'use client';

import { Button as BaseButton, extendVariants } from '@nextui-org/react';

const Button = extendVariants(BaseButton, {
  // Must define default variants before extending them
  defaultVariants: { size: 'md', variant: 'solid', color: 'default' },
  compoundVariants: [
    {
      variant: ['solid'], // <-- ERROR: Type 'string[]' is not assignable to type '"solid" | "bordered" | "light" | "flat" | "faded" | "shadow" | "ghost" | undefined'.
      color: 'default',
      class: 'text-white'
    }
  ],
  variants: {
    size: {
      sm: 'text-button-sm leading-button-sm h-fit rounded-sm px-14 py-6',
      md: 'text-button-md leading-button-md h-fit rounded-md px-20 py-8',
      lg: 'text-button-lg leading-button-lg h-fit rounded-lg px-26 py-11'
    }
  }
});

export default Button;

But if I as any, it still works. Is this expected behavior?

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Just put the code and see typescript error

Expected behavior

No typerscript error

Screenshots or Videos

No response

Operating System Version

Windows

Browser

Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants