Skip to content

Commit 4e5c07f

Browse files
committed
Fix JsonRpcRequest to be valid json
fix/types: JsonRpcParams should be valid JSON values `undefined` is not valid JSON. https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf (Section 5): A JSON value can be an object, array, number, string, true, false, or null.
1 parent 20bb059 commit 4e5c07f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/json.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ export type JsonRpcError = OptionalField<
177177
'data'
178178
>;
179179

180-
export const JsonRpcParamsStruct = optional(
181-
union([record(string(), JsonStruct), array(JsonStruct)]),
182-
);
183-
export type JsonRpcParams = Infer<typeof JsonRpcParamsStruct>;
180+
export const JsonRpcParamsStruct: Struct<Json[] | Record<string, Json>, null> =
181+
optional(union([record(string(), JsonStruct), array(JsonStruct)])) as any;
182+
183+
export type JsonRpcParams = Json[] | Record<string, Json>;
184184

185185
export const JsonRpcRequestStruct = object({
186186
id: JsonRpcIdStruct,

0 commit comments

Comments
 (0)