Skip to content

Commit 9732a7b

Browse files
NamesMTnakasyou
andauthored
feat(types): improve ToSchema & WebSocket Helper types (#2588)
* feat: add `outputFormat` types to Input Co-authored-by: Shotaro Nakamura <syoutarou1103@outlook.jp> * feat: `ToSchema` ability to use whole `Input` Co-authored-by: Shotaro Nakamura <syoutarou1103@outlook.jp> * feat: improve `UpgradeWebSocket` types flow Co-authored-by: Shotaro Nakamura <syoutarou1103@outlook.jp> --------- Co-authored-by: Shotaro Nakamura <syoutarou1103@outlook.jp>
1 parent 2b2dacc commit 9732a7b

File tree

8 files changed

+141
-165
lines changed

8 files changed

+141
-165
lines changed

deno_dist/client/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { UpgradedWebSocketResponseInputJSONType } from '../helper/websocket/index.ts'
21
import type { Hono } from '../hono.ts'
32
import type { Endpoint, ResponseFormat, Schema } from '../types.ts'
43
import type { StatusCode, SuccessStatusCode } from '../utils/http-status.ts'
@@ -34,10 +33,10 @@ export type ClientRequest<S extends Schema> = {
3433
: {}
3534
: {}
3635
) => URL
37-
} & (S['$get'] extends { input: { json: UpgradedWebSocketResponseInputJSONType } }
36+
} & (S['$get'] extends { outputFormat: 'ws' }
3837
? S['$get'] extends { input: infer I }
3938
? {
40-
$ws: (args?: Omit<I, 'json'>) => WebSocket
39+
$ws: (args?: I) => WebSocket
4140
}
4241
: {}
4342
: {})

deno_dist/helper/websocket/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export interface WSEvents {
1212
onError?: (evt: Event, ws: WSContext) => void
1313
}
1414

15-
export type UpgradedWebSocketResponseInputJSONType = '__websocket'
16-
1715
/**
1816
* Upgrade WebSocket Type
1917
*/
@@ -23,9 +21,7 @@ export type UpgradeWebSocket = (
2321
any,
2422
string,
2523
{
26-
in: {
27-
json: UpgradedWebSocketResponseInputJSONType
28-
}
24+
outputFormat: 'ws'
2925
}
3026
>
3127

0 commit comments

Comments
 (0)