fix: ensure every variant of ClientRequest has a params field (#4512)
This ensures changes the generated TypeScript type for `ClientRequest`
so that instead of this:
```typescript
/**
* Request from the client to the server.
*/
export type ClientRequest =
| { method: "initialize"; id: RequestId; params: InitializeParams }
| { method: "newConversation"; id: RequestId; params: NewConversationParams }
// ...
| { method: "getUserAgent"; id: RequestId }
| { method: "userInfo"; id: RequestId }
// ...
```
we have this:
```typescript
/**
* Request from the client to the server.
*/
export type ClientRequest =
| { method: "initialize"; id: RequestId; params: InitializeParams }
| { method: "newConversation"; id: RequestId; params: NewConversationParams }
// ...
| { method: "getUserAgent"; id: RequestId; params: undefined }
| { method: "userInfo"; id: RequestId; params: undefined }
// ...
```
which makes TypeScript happier when it comes to destructuring instances
of `ClientRequest` because it does not complain about `params` not being
guaranteed to exist anymore.
This commit is contained in:
@@ -158,6 +158,10 @@ pub enum ClientRequest {
|
||||
LoginChatGpt {
|
||||
#[serde(rename = "id")]
|
||||
request_id: RequestId,
|
||||
|
||||
#[ts(type = "undefined")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
params: Option<()>,
|
||||
},
|
||||
CancelLoginChatGpt {
|
||||
#[serde(rename = "id")]
|
||||
@@ -167,6 +171,10 @@ pub enum ClientRequest {
|
||||
LogoutChatGpt {
|
||||
#[serde(rename = "id")]
|
||||
request_id: RequestId,
|
||||
|
||||
#[ts(type = "undefined")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
params: Option<()>,
|
||||
},
|
||||
GetAuthStatus {
|
||||
#[serde(rename = "id")]
|
||||
@@ -176,6 +184,10 @@ pub enum ClientRequest {
|
||||
GetUserSavedConfig {
|
||||
#[serde(rename = "id")]
|
||||
request_id: RequestId,
|
||||
|
||||
#[ts(type = "undefined")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
params: Option<()>,
|
||||
},
|
||||
SetDefaultModel {
|
||||
#[serde(rename = "id")]
|
||||
@@ -185,10 +197,18 @@ pub enum ClientRequest {
|
||||
GetUserAgent {
|
||||
#[serde(rename = "id")]
|
||||
request_id: RequestId,
|
||||
|
||||
#[ts(type = "undefined")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
params: Option<()>,
|
||||
},
|
||||
UserInfo {
|
||||
#[serde(rename = "id")]
|
||||
request_id: RequestId,
|
||||
|
||||
#[ts(type = "undefined")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
params: Option<()>,
|
||||
},
|
||||
FuzzyFileSearch {
|
||||
#[serde(rename = "id")]
|
||||
|
||||
Reference in New Issue
Block a user