From 3e2c44b5975a3de150175346b9f0656d7dbf689b Mon Sep 17 00:00:00 2001 From: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com> Date: Sun, 5 May 2024 16:33:05 +0900 Subject: [PATCH 1/2] fix: update type definition to prevent primitive values as items --- .changeset/great-singers-repeat.md | 11 +++++++++++ packages/components/autocomplete/src/autocomplete.tsx | 4 ++-- packages/components/dropdown/src/dropdown-menu.tsx | 4 ++-- packages/components/listbox/src/listbox.tsx | 4 ++-- packages/components/menu/src/menu.tsx | 4 ++-- packages/components/select/src/select.tsx | 4 ++-- packages/components/tabs/src/tabs.tsx | 4 ++-- 7 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 .changeset/great-singers-repeat.md diff --git a/.changeset/great-singers-repeat.md b/.changeset/great-singers-repeat.md new file mode 100644 index 0000000000..dc38069913 --- /dev/null +++ b/.changeset/great-singers-repeat.md @@ -0,0 +1,11 @@ +--- +"@nextui-org/autocomplete": patch +"@nextui-org/dropdown": patch +"@nextui-org/listbox": patch +"@nextui-org/menu": patch +"@nextui-org/select": patch +"@nextui-org/tabs": patch +"@nextui-org/use-aria-multiselect": patch +--- + +Fix update type definition to prevent primitive values as items (#2938) diff --git a/packages/components/autocomplete/src/autocomplete.tsx b/packages/components/autocomplete/src/autocomplete.tsx index 7da035b20f..022e42e2eb 100644 --- a/packages/components/autocomplete/src/autocomplete.tsx +++ b/packages/components/autocomplete/src/autocomplete.tsx @@ -58,10 +58,10 @@ function Autocomplete(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type AutocompleteProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(Autocomplete) as ( +export default forwardRef(Autocomplete) as ( props: AutocompleteProps, ) => ReactElement; diff --git a/packages/components/dropdown/src/dropdown-menu.tsx b/packages/components/dropdown/src/dropdown-menu.tsx index db3811bd6f..9a5980eb1d 100644 --- a/packages/components/dropdown/src/dropdown-menu.tsx +++ b/packages/components/dropdown/src/dropdown-menu.tsx @@ -20,10 +20,10 @@ function DropdownMenu(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type DropdownMenuProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(DropdownMenu) as ( +export default forwardRef(DropdownMenu) as ( props: DropdownMenuProps, ) => ReactElement; diff --git a/packages/components/listbox/src/listbox.tsx b/packages/components/listbox/src/listbox.tsx index 855ef169ca..ffc0fa6f82 100644 --- a/packages/components/listbox/src/listbox.tsx +++ b/packages/components/listbox/src/listbox.tsx @@ -76,7 +76,7 @@ function Listbox(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type ListboxProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(Listbox) as (props: ListboxProps) => ReactElement; +export default forwardRef(Listbox) as (props: ListboxProps) => ReactElement; diff --git a/packages/components/menu/src/menu.tsx b/packages/components/menu/src/menu.tsx index 2e7bab14f2..318b86baa1 100644 --- a/packages/components/menu/src/menu.tsx +++ b/packages/components/menu/src/menu.tsx @@ -71,9 +71,9 @@ function Menu(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type MenuProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(Menu) as (props: MenuProps) => ReactElement; +export default forwardRef(Menu) as (props: MenuProps) => ReactElement; Menu.displayName = "NextUI.Menu"; diff --git a/packages/components/select/src/select.tsx b/packages/components/select/src/select.tsx index bda7b15277..9db6723a0e 100644 --- a/packages/components/select/src/select.tsx +++ b/packages/components/select/src/select.tsx @@ -144,9 +144,9 @@ function Select(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type SelectProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(Select) as (props: SelectProps) => ReactElement; +export default forwardRef(Select) as (props: SelectProps) => ReactElement; Select.displayName = "NextUI.Select"; diff --git a/packages/components/tabs/src/tabs.tsx b/packages/components/tabs/src/tabs.tsx index a4c618ac82..09d65113ff 100644 --- a/packages/components/tabs/src/tabs.tsx +++ b/packages/components/tabs/src/tabs.tsx @@ -57,9 +57,9 @@ function Tabs(props: Props, ref: ForwardedRef = Props & {ref?: Ref}; +export type TabsProps = Props & {ref?: Ref}; // forwardRef doesn't support generic parameters, so cast the result to the correct type -export default forwardRef(Tabs) as (props: TabsProps) => ReactElement; +export default forwardRef(Tabs) as (props: TabsProps) => ReactElement; Tabs.displayName = "NextUI.Tabs"; From 003fba070a0bce806a3567ffe3fd7a20dab245ec Mon Sep 17 00:00:00 2001 From: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com> Date: Sun, 5 May 2024 17:07:37 +0900 Subject: [PATCH 2/2] fix: typecheck --- packages/components/dropdown/src/dropdown-menu.tsx | 2 +- packages/components/dropdown/src/use-dropdown.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/dropdown/src/dropdown-menu.tsx b/packages/components/dropdown/src/dropdown-menu.tsx index 9a5980eb1d..11617934c6 100644 --- a/packages/components/dropdown/src/dropdown-menu.tsx +++ b/packages/components/dropdown/src/dropdown-menu.tsx @@ -6,7 +6,7 @@ import {ForwardedRef, ReactElement, Ref} from "react"; import {useDropdownContext} from "./dropdown-context"; -interface Props extends Omit, "menuProps"> {} +interface Props extends Omit, "menuProps"> {} function DropdownMenu(props: Props, ref: ForwardedRef) { const {getMenuProps} = useDropdownContext(); diff --git a/packages/components/dropdown/src/use-dropdown.ts b/packages/components/dropdown/src/use-dropdown.ts index 55fb9071b1..9c8240dbcb 100644 --- a/packages/components/dropdown/src/use-dropdown.ts +++ b/packages/components/dropdown/src/use-dropdown.ts @@ -132,7 +132,7 @@ export function useDropdown(props: UseDropdownProps) { }; }; - const getMenuProps = ( + const getMenuProps = ( props?: Partial>, _ref: Ref | null | undefined = null, ) => {