@@ -47,7 +47,10 @@ export type HookDescriptor<T extends (...args: any[]) => any> = {
47
47
order : HookOrder ;
48
48
} ;
49
49
50
- export type EnvironmentAsyncHook < Callback extends ( ...args : any [ ] ) => any > = {
50
+ export type EnvironmentAsyncHook <
51
+ Callback extends ( ...args : any [ ] ) => T ,
52
+ T = any ,
53
+ > = {
51
54
/**
52
55
* Registers a callback function to be executed when the hook is triggered.
53
56
* The callback can be a plain function or a HookDescriptor that includes execution order.
@@ -90,7 +93,7 @@ export type EnvironmentAsyncHook<Callback extends (...args: any[]) => any> = {
90
93
* Each callback receives the original parameters, and their results don't affect subsequent callbacks.
91
94
* @returns A promise that resolves with an array containing the results of all callbacks
92
95
*/
93
- callBatch : < T = unknown > ( params : {
96
+ callBatch : ( params : {
94
97
/**
95
98
* Specify the environment for filtering callbacks.
96
99
*/
@@ -99,10 +102,10 @@ export type EnvironmentAsyncHook<Callback extends (...args: any[]) => any> = {
99
102
* The parameters to pass to each callback
100
103
*/
101
104
args : Parameters < Callback > ;
102
- } ) => Promise < T [ ] > ;
105
+ } ) => Promise < Awaited < ReturnType < Callback > > [ ] > ;
103
106
} ;
104
107
105
- export type AsyncHook < Callback extends ( ...args : any [ ] ) => any > = {
108
+ export type AsyncHook < Callback extends ( ...args : any [ ] ) => T , T = any > = {
106
109
/**
107
110
* Registers a callback function to be executed when the hook is triggered.
108
111
* The callback can be a plain function or a HookDescriptor that includes execution order.
@@ -123,7 +126,9 @@ export type AsyncHook<Callback extends (...args: any[]) => any> = {
123
126
* @param params The parameters to pass to each callback
124
127
* @returns A promise that resolves with an array containing the results of all callbacks
125
128
*/
126
- callBatch : < T = unknown > ( ...args : Parameters < Callback > ) => Promise < T [ ] > ;
129
+ callBatch : (
130
+ ...args : Parameters < Callback >
131
+ ) => Promise < Awaited < ReturnType < Callback > > [ ] > ;
127
132
} ;
128
133
129
134
export type ModifyRspackConfigFn = (
0 commit comments