Skip to content

Commit 24196ec

Browse files
committed
Arrays are not records
1 parent 5e5a941 commit 24196ec

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ParseJson/ParseJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export function parseJsonInto<T>(
2121
}
2222

2323
export function isRecord(value: unknown): value is Record<string, unknown> {
24-
return typeof value === "object" && value !== null;
24+
return typeof value === "object" && value !== null && !Array.isArray(value);
2525
}

tests/parseJson_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Deno.test("isRecord - null", () => {
7070
});
7171

7272
Deno.test("isRecord - array", () => {
73-
expect(isRecord([])).toBe(true); // Arrays are typeof 'object', not null
73+
expect(isRecord([])).toBe(false); // Arrays are typeof 'object', not null
7474
});
7575

7676
Deno.test("isRecord - string", () => {

0 commit comments

Comments
 (0)