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

refactor: support for extractOptionalPropertyTypes #3638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maroKanatani
Copy link

I always use shadcn/ui. Thanks.
I was getting a type error in my project when using some components with extractOptionalPropertyTypes set to true.
I would be happy to merge them if you would like.

https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes

Copy link

vercel bot commented May 1, 2024

@maroKanatani is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

@maroKanatani
Copy link
Author

Error is as follows.

❯ npm run build

> [email protected] build
> next build

  ▲ Next.js 14.2.3

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  ...Failed to compile.

./src/lib/shadcn/ui/dropdown-menu.tsx:99:4
Type error: Type '{ children: (Element | ReactNode)[]; style?: CSSProperties | undefined; id?: string | undefined; nonce?: string | undefined; key?: Key | null | undefined; ... 272 more ...; checked: CheckedState | undefined; }' is not assignable to type 'DropdownMenuCheckboxItemProps' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
  Types of property 'checked' are incompatible.
    Type 'CheckedState | undefined' is not assignable to type 'CheckedState'.
      Type 'undefined' is not assignable to type 'CheckedState'.

   97 |   React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
   98 | >(({ className, children, checked, ...props }, ref) => (
>  99 |   <DropdownMenuPrimitive.CheckboxItem
      |    ^
  100 |     ref={ref}
  101 |     className={cn(
  102 |       "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant