Skip to content

JsonRpcRequest allows non-JSON values #129

@legobeat

Description

@legobeat

The resulting type of JsonRpcRequest:

export declare const JsonRpcRequestStruct: Struct<{
    id: string | number | null;
    method: string;
    jsonrpc: "2.0";
    params?: Json[] | Record<string, Json> | undefined;
}, {
    id: Struct<string | number | null, null>;
    jsonrpc: Struct<"2.0", "2.0">;
    method: Struct<string, null>;
    params: Struct<Json[] | Record<string, Json> | undefined, null>;
}>;


export declare type JsonRpcRequest<Params extends JsonRpcParams = JsonRpcParams> = InferWithParams<typeof JsonRpcRequestStruct, Params>;

This allows explicit undefined value for params, which is invalid JSON since undefined is not a valid JSON value. params?: Json[] | Record<string, Json> | undefined; should be params?: Json[] | Record<string, Json>;.

It seems like superstruct-derived optional always get a | undefined, which makes the resolution less obvious to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions