Skip to content

Reduce type duplication by excluding undefined - #135

Closed
Mrtenz wants to merge 4 commits into
mainfrom
mrtenz/reduce-type-duplication
Closed

Reduce type duplication by excluding undefined#135
Mrtenz wants to merge 4 commits into
mainfrom
mrtenz/reduce-type-duplication

Conversation

@Mrtenz

Copy link
Copy Markdown
Member

This is intended to be merged into @legobeat's branch (#134).

@legobeat

Copy link
Copy Markdown
Contributor

Result from dist/types/json.d.ts after yarn build:

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 InferWithParams<Type extends Struct<any>, Params extends JsonRpcParams> = Omit<Infer<Type>, 'params'> & {
params?: Exclude<Params, undefined>;
};
/**
* A JSON-RPC request object.
*/
export declare type JsonRpcRequest<Params extends JsonRpcParams = JsonRpcParams> = InferWithParams<typeof JsonRpcRequestStruct, Params>;
export declare const JsonRpcNotificationStruct: Struct<{
method: string;
jsonrpc: "2.0";
params?: Json[] | Record<string, Json> | undefined;
}, {
jsonrpc: Struct<"2.0", "2.0">;
method: Struct<string, null>;
params: Struct<Json[] | Record<string, Json> | undefined, null>;
}>;

@MrtenzMrtenz closed this Aug 30, 2023
@Mrtenz
Mrtenz deleted the mrtenz/reduce-type-duplication branch August 30, 2023 10:24
@legobeat

Copy link
Copy Markdown
Contributor

This is now part of #134

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Mrtenz@legobeat