Skip to content

Commit

Permalink
re-add helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Oct 25, 2023
1 parent 835f78d commit 24b0460
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions centrifuge-app/src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Array.find gives a Typescript error when used on a union of different array types
* This is a workaround to still have it be typed
* @see https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgGLAF4eQbwLABQyxywAJgFzIgCuAtgEbQDchJyMmGVAzmFKADmrAgF9ChUJFiIUAIRpZcbEuSq1GLFcQaLuyPgJDDC4goQAUAbQC6yODzRdbyAD7IFWWwEoAdJxAyC2BIOmQAXgA+UlDfcm9mZCA
* @see https://github.com/microsoft/TypeScript/issues/44373
*/
export function find<T extends Array<any>>(
arr: T,
predicate: (value: T[0], index: number, obj: T) => unknown
): T[0] | undefined {
return arr.find(predicate as any)
}

0 comments on commit 24b0460

Please sign in to comment.