Skip to content

Commit 79c5b12

Browse files
committed
Adds type-guarding
1 parent 62da554 commit 79c5b12

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/system/object.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function updateRecordValue<T>(
157157
* @param o - The object to check
158158
* @returns true if the object has at least one own enumerable property, false otherwise
159159
*/
160-
export function hasKeys(o: Record<string, any> | null | undefined): boolean {
160+
export function hasKeys(o: Record<string, any> | null | undefined): o is Record<string, any> {
161161
for (const k in o) {
162162
if (Object.hasOwn(o, k)) return true;
163163
}
@@ -170,7 +170,10 @@ export function hasKeys(o: Record<string, any> | null | undefined): boolean {
170170
* @param required - The minimum number of truthy values required (default: 1)
171171
* @returns true if the object has at least the required number of properties with truthy values
172172
*/
173-
export function hasTruthyKeys(o: Record<string, any> | null | undefined, required: number = 1): boolean {
173+
export function hasTruthyKeys(
174+
o: Record<string, any> | null | undefined,
175+
required: number = 1,
176+
): o is Record<string, any> {
174177
let count = 0;
175178
for (const k in o) {
176179
if (Object.hasOwn(o, k) && o[k]) {

0 commit comments

Comments
 (0)