Skip to content

Commit 26990c2

Browse files
dlechsnowystinger
andauthored
@react-types/shared/collections: fix return types of KeyboardDelegate (#3139)
As noted in the doc comments, the return values for each of the methods in KeyboardDelegate can return null. This fixes the typings by adding null to the return types. Co-authored-by: Robert Snow <[email protected]>
1 parent b1af1ed commit 26990c2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/@react-types/shared/src/collections.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,31 @@ export type SortDirection = 'ascending' | 'descending';
8989

9090
export interface KeyboardDelegate {
9191
/** Returns the key visually below the given one, or `null` for none. */
92-
getKeyBelow?(key: Key): Key,
92+
getKeyBelow?(key: Key): Key | null,
9393

9494
/** Returns the key visually above the given one, or `null` for none. */
95-
getKeyAbove?(key: Key): Key,
95+
getKeyAbove?(key: Key): Key | null,
9696

9797
/** Returns the key visually to the left of the given one, or `null` for none. */
98-
getKeyLeftOf?(key: Key): Key,
98+
getKeyLeftOf?(key: Key): Key | null,
9999

100100
/** Returns the key visually to the right of the given one, or `null` for none. */
101-
getKeyRightOf?(key: Key): Key,
101+
getKeyRightOf?(key: Key): Key | null,
102102

103103
/** Returns the key visually one page below the given one, or `null` for none. */
104-
getKeyPageBelow?(key: Key): Key,
104+
getKeyPageBelow?(key: Key): Key | null,
105105

106106
/** Returns the key visually one page above the given one, or `null` for none. */
107-
getKeyPageAbove?(key: Key): Key,
107+
getKeyPageAbove?(key: Key): Key | null,
108108

109109
/** Returns the first key, or `null` for none. */
110-
getFirstKey?(key?: Key, global?: boolean): Key,
110+
getFirstKey?(key?: Key, global?: boolean): Key | null,
111111

112112
/** Returns the last key, or `null` for none. */
113-
getLastKey?(key?: Key, global?: boolean): Key,
113+
getLastKey?(key?: Key, global?: boolean): Key | null,
114114

115115
/** Returns the next key after `fromKey` that matches the given search string, or `null` for none. */
116-
getKeyForSearch?(search: string, fromKey?: Key): Key
116+
getKeyForSearch?(search: string, fromKey?: Key): Key | null
117117
}
118118

119119
/**

0 commit comments

Comments
 (0)