Commit 6fcdc22 1 parent 884460b commit 6fcdc22 Copy full SHA for 6fcdc22
File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,18 @@ export interface H3Event {
12
12
13
13
export type CompatibilityEvent = H3Event | IncomingMessage
14
14
15
- export type _JSONValue < T = string | number | boolean > = T | T [ ] | Record < string , T >
15
+ type _JSONValue < T = string | number | boolean > = T | T [ ] | Record < string , T >
16
16
export type JSONValue = _JSONValue < _JSONValue >
17
- export type H3Response = void | JSONValue | Buffer
18
17
19
- export interface EventHandler {
18
+ type _H3Response = void | JSONValue | Buffer
19
+ export type H3Response = _H3Response | Promise < _H3Response >
20
+
21
+ export interface EventHandler < T extends H3Response = H3Response > {
20
22
'__is_handler__' ?: true
21
- ( event : CompatibilityEvent ) : H3Response | Promise < H3Response >
23
+ ( event : CompatibilityEvent ) : T
22
24
}
23
25
24
- export function defineEventHandler ( handler : EventHandler ) {
26
+ export function defineEventHandler < T extends H3Response = H3Response > ( handler : EventHandler < T > ) : EventHandler < T > {
25
27
handler . __is_handler__ = true
26
28
return handler
27
29
}
You can’t perform that action at this time.
0 commit comments