nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
21.32k stars 1.37k forks source link

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

Closed conduongtong closed 1 week ago

conduongtong commented 1 month ago

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

linear[bot] commented 1 month ago

ENG-1186 [BUG] - Typescript, extendVariants not allowed variant array