Skip to content

Commit

Permalink
add find last method, this is a bug with typescript version 4.8 and i…
Browse files Browse the repository at this point in the history
…s will be fixed in typescript version 5, short term fix is to add to globals microsoft/TypeScript#48829
  • Loading branch information
G-bot987 committed Dec 26, 2022
1 parent 5bdc990 commit c641155
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {};

declare global {
interface Array<T> {
findLast(
predicate: (value: T, index: number, obj: T[]) => unknown,
thisArg?: any
): number;

This comment has been minimized.

Copy link
@Beraliv

Beraliv Jan 9, 2023

Could you please fix it to be T | undefined instead?

Or add both methods to be correct:

declare global {
  interface Array<T> {
    findLast(
      predicate: (value: T, index: number, obj: T[]) => unknown,
      thisArg?: any
    ): T | undefined;
    findLastIndex(
      predicate: (value: T, index: number, obj: T[]) => unknown,
      thisArg?: any
    ): number;
  }
}
}
}

0 comments on commit c641155

Please sign in to comment.