Skip to content

Commit b2d94bd

Browse files
authored
fix: update the type of the defaultFilter (#338)
1 parent 9827edf commit b2d94bd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmdk/src/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type InputProps = Omit<React.ComponentPropsWithoutRef<typeof Primitive.input>, '
7676
*/
7777
onValueChange?: (search: string) => void
7878
}
79+
type CommandFilter = (value: string, search: string, keywords?: string[]) => number
7980
type CommandProps = Children &
8081
DivProps & {
8182
/**
@@ -92,7 +93,7 @@ type CommandProps = Children &
9293
* It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely.
9394
* By default, uses the `command-score` library.
9495
*/
95-
filter?: (value: string, search: string, keywords?: string[]) => number
96+
filter?: CommandFilter
9697
/**
9798
* Optional default item value when it is initially rendered.
9899
*/
@@ -156,7 +157,7 @@ const ITEM_SELECTOR = `[cmdk-item=""]`
156157
const VALID_ITEM_SELECTOR = `${ITEM_SELECTOR}:not([aria-disabled="true"])`
157158
const SELECT_EVENT = `cmdk-item-select`
158159
const VALUE_ATTR = `data-value`
159-
const defaultFilter: CommandProps['filter'] = (value, search, keywords) => commandScore(value, search, keywords)
160+
const defaultFilter: CommandFilter = (value, search, keywords) => commandScore(value, search, keywords)
160161

161162
// @ts-ignore
162163
const CommandContext = React.createContext<Context>(undefined)

0 commit comments

Comments
 (0)