Add type annotations to common

This commit is contained in:
Danila Fedorin 2021-09-29 18:13:49 -07:00
parent e53f3d23d5
commit bf53449f66

View File

@ -14,9 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {BaseObservableList} from "./BaseObservableList";
/* inline update of item in collection backed by array, without replacing the preexising item */
export function findAndUpdateInArray(predicate, array, observable, updater) {
export function findAndUpdateInArray<T>(predicate: (value: T) => boolean, array: T[], observable: BaseObservableList<T>, updater: (value: T) => any | false) {
const index = array.findIndex(predicate);
if (index !== -1) {
const value = array[index];
@ -29,4 +30,4 @@ export function findAndUpdateInArray(predicate, array, observable, updater) {
return true;
}
return false;
}
}