Skip to content

Commit

Permalink
Fix #699: Use TS 4.7 Instantiation Expressions for filterObject retur…
Browse files Browse the repository at this point in the history
…n type (#806)
  • Loading branch information
nelsonni authored Jun 7, 2022
1 parent 362f1db commit cffc229
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/containers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const asyncFilter = async <T>(arr: T[], predicate: (e: T) => Promise<bool
* @param filter An array of key strings that indicate which key-value pairs should be included or excluded.
* @return The resulting object devoid of key-value fields that did not match the key filter, or an empty object.
*/
export const filterObject = <V, T extends Record<string, V>>(obj: T, filter: string[]): T | Record<string, never> => {
export const filterObject = <V, T extends Record<string, V>>(obj: T, filter: string[]): ReturnType<typeof flattenObject<T>> => {
return Object.entries(flattenObject(obj))
.filter(([key]) => filter.includes(key))
.reduce((accumulator, [k, v]) => ({ ...accumulator, [k]: v }), {});
Expand Down

0 comments on commit cffc229

Please sign in to comment.