Refine DataSource id to use actual key type instead of a wide string type
Summary: Current implementation uses type `string` as a key for indexing items stored in datasource. However, users can provide any key as an index which means that the type of index item can be anything, not only string. This diff introduces a more refined types for the key. It adds another requirement to provide a key property to a generic which is used to infer the index type. Reviewed By: mweststrate, aigoncharov Differential Revision: D31895751 fbshipit-source-id: 19ba907bd6f35df87e3fa442db5fc5cec6af174d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
64e791e253
commit
4a4cc21d89
@@ -32,7 +32,7 @@ function generateTodos(amount: number): Todo[] {
|
||||
|
||||
const defaultFilter = (t: Todo) => !t.done;
|
||||
|
||||
type DataSourceish = DataSource<Todo> | FakeDataSource<Todo>;
|
||||
type DataSourceish = DataSource<Todo, Todo[keyof Todo]> | FakeDataSource<Todo>;
|
||||
|
||||
// NOTE: this run in jest, which is not optimal for perf, but should give some idea
|
||||
// make sure to use the `yarn watch` script in desktop root, so that the garbage collector is exposed
|
||||
|
||||
Reference in New Issue
Block a user