1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-15 07:25:54 +00:00

Improve type safety: Replace 'any[]' with generic type parameter in a… (#27334)

Improve type safety: Replace 'any[]' with generic type parameter in arrayFilter function

- Convert arrayFilter from using 'any[]' to generic type <T>
- Improves TypeScript type safety and inference
- Follows strict TypeScript guidelines in codebase
- No behavioral changes, purely type improvement
This commit is contained in:
Leslie Fernando
2025-10-05 17:14:34 +05:30
committed by GitHub
parent 733be8e5a3
commit c09e97a561

View File

@@ -2,16 +2,16 @@ import type { HassEntity } from "home-assistant-js-websocket";
import { computeDomain } from "../../../common/entity/compute_domain";
import type { HomeAssistant } from "../../../types";
const arrayFilter = (
array: any[],
conditions: ((value: any) => boolean)[],
const arrayFilter = <T>(
array: T[],
conditions: ((value: T) => boolean)[],
maxSize: number
) => {
): T[] => {
if (!maxSize || maxSize > array.length) {
maxSize = array.length;
}
const filteredArray: any[] = [];
const filteredArray: T[] = [];
for (let i = 0; i < array.length && filteredArray.length < maxSize; i++) {
let meetsConditions = true;