Skip to content

Commit b63300a

Browse files
committed
refactor: narrow JSON-RPC message ID type from number | string to string.
1 parent 94d58eb commit b63300a

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

genkit-tools/common/src/manager/manager-v2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface JsonRpcRequest {
5252
jsonrpc: '2.0';
5353
method: string;
5454
params?: any;
55-
id?: number | string;
55+
id?: string;
5656
}
5757

5858
interface JsonRpcResponse {
@@ -63,7 +63,7 @@ interface JsonRpcResponse {
6363
message: string;
6464
data?: any;
6565
};
66-
id: number | string;
66+
id: string;
6767
}
6868

6969
type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse;

js/core/src/reflection-v2.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface JsonRpcRequest {
4040
jsonrpc: '2.0';
4141
method: string;
4242
params?: any;
43-
id?: number | string;
43+
id?: string;
4444
}
4545

4646
interface JsonRpcResponse {
@@ -51,7 +51,7 @@ interface JsonRpcResponse {
5151
message: string;
5252
data?: any;
5353
};
54-
id: number | string;
54+
id: string;
5555
}
5656

5757
type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse;
@@ -128,20 +128,15 @@ export class ReflectionServerV2 {
128128
}
129129
}
130130

131-
private sendResponse(id: number | string, result: any) {
131+
private sendResponse(id: string, result: any) {
132132
this.send({
133133
jsonrpc: '2.0',
134134
result,
135135
id,
136136
});
137137
}
138138

139-
private sendError(
140-
id: number | string,
141-
code: number,
142-
message: string,
143-
data?: any
144-
) {
139+
private sendError(id: string, code: number, message: string, data?: any) {
145140
this.send({
146141
jsonrpc: '2.0',
147142
error: { code, message, data },

0 commit comments

Comments
 (0)