diff --git a/lib/api.d.ts b/lib/api.d.ts index 376a2cc..23789ed 100644 --- a/lib/api.d.ts +++ b/lib/api.d.ts @@ -144,6 +144,7 @@ declare class Collection { * order, until it finds one where `filterFunc` returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. */ + find(filterFunc: (item: Item) => item is T): T; // Type guard version to allow TypeScript to narrow the type of the result find(filterFunc: (item: Item) => boolean): Item; /** * Creates a new collection which contains only those items that meet a certain condition. @@ -154,6 +155,7 @@ declare class Collection { * * @param filterFunc A function that accepts up to three arguments. The filter method calls the `filterFunc` function one time for each element in the collection. */ + filterOnce(filterFunc: (item: Item) => item is T): Collection; // Type guard version to allow TypeScript to narrow the type of the result filterOnce(filterFunc: (item: Item) => boolean): Collection; /** * Creates a new collection which contains only those items that meet a certain condition. @@ -174,6 +176,7 @@ declare class Collection { * * @param filterFunc A function that accepts up to three arguments. The filter method calls the `filterFunc` function one time for each element in the collection. */ + filterObservable(filterFunc: (item: Item) => item is T): ObservableFilteredCollection; // Type guard version to allow TypeScript to narrow the type of the result filterObservable(filterFunc: (item: Item) => boolean): ObservableFilteredCollection; /** * Creates a new collection which contains only those items that meet a certain condition. @@ -187,6 +190,7 @@ declare class Collection { * * @param filterFunc A function that accepts up to three arguments. The filter method calls the `filterFunc` function one time for each element in the collection. */ + filter(filterFunc: (item: Item) => item is T): FilteredCollection; // Type guard version to allow TypeScript to narrow the type of the result filter(filterFunc: (item: Item) => boolean): FilteredCollection; /** * Creates a new collection which contains other objects that are derived from the items in this collection. diff --git a/lib/collection/array.d.ts b/lib/collection/array.d.ts index 50adf52..3664ddb 100644 --- a/lib/collection/array.d.ts +++ b/lib/collection/array.d.ts @@ -140,6 +140,7 @@ declare class ArrayColl extends KeyValueCollection { * order, until it finds one where `filterFunc` returns true. If such an element is found, find * immediately returns that element valuehttps://github.com/microsoft/TypeScript/blob/main/src/lib/es2016.array.include.d.tsOtherwise, find returns undefined. */ + find(filterFunc: (item: Item) => item is T): T; // Type guard version to allow TypeScript to narrow the type of the result find(filterFunc: (item: Item) => boolean): Item; /** * Returns the index of the first element in the collection where `filterFunc` is true,