Update get and identify APIs to return the item/id in one item case. #61
Conversation
@@ -83,12 +86,16 @@ function isPatch(patchObj: any): patchObj is {id: string; patch: Patch<any, any> | |||
} | |||
|
|||
const createStore: StoreFactory = compose<Store<{}, {}, any>, StoreOptions<{}, {}>>({ | |||
get(this: Store<{}, {}, any>, ids: string[] | string): Promise<{}[]> { | |||
get(this: Store<{}, {}, any>, ids: string[] | string): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we type the return here to Promise<{} | {}[]>
? That way it provides at least some guarantee about the return type in the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I have made the change.
@@ -222,8 +229,14 @@ const createStore: StoreFactory = compose<Store<{}, {}, any>, StoreOptions<{}, { | |||
}); | |||
}, | |||
|
|||
identify(this: Store<{}, {}, any>, items: {}[] | {}) { | |||
return instanceStateMap.get(this).storage.identify(Array.isArray(items) ? items : [ items ]); | |||
identify(this: Store<{}, {}, any>, items: {}[] | {}): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here really, could this return string | string[]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although get
can be done this way, identify
can't as I tried. Please let me know if you have ways to get around this and I am happy to make it type safer.
Just a note, the CI has been hanging on
I've seem this happen before. It seems it only fails occasionally. |
Type: feature
Description:
Update get and identify APIs to return the item/id instead of the one item.id array in one item case.
Related Issue: #60