Skip to content

Commit 9cc7190

Browse files
authored
improv(commons): add number key type to JSONObject type
The change introduced in this PR allows to narrow the type of JSON objects using numbers as key. JSON allows only string types as keys, however JavaScript coerces the value to a string even when a number is passed.
1 parent 58120e3 commit 9cc7190

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: packages/commons/src/types/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export { isRecord, isString, isTruthy, isNullOrUndefined };
5353

5454
type JSONPrimitive = string | number | boolean | null | undefined;
5555
type JSONValue = JSONPrimitive | JSONObject | JSONArray;
56-
type JSONObject = { [key: string]: JSONValue };
56+
type JSONObject = { [key: number | string]: JSONValue };
5757
type JSONArray = Array<JSONValue>;
5858

5959
export type { JSONPrimitive, JSONValue, JSONObject, JSONArray };

0 commit comments

Comments
 (0)