File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,16 @@ export type SubscriptionCallback<S> = (
159
159
state : UnwrapRef < S >
160
160
) => void
161
161
162
+ // to support TS 4.4
163
+ // TODO: remove in 2.1.0, use Awaited, and up the peer dep to TS 4.5
164
+ type _Awaited < T > = T extends null | undefined
165
+ ? T // special case for `null | undefined` when not in `--strictNullChecks` mode
166
+ : T extends object & { then ( onfulfilled : infer F ) : any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
167
+ ? F extends ( value : infer V , ...args : any ) => any // if the argument to `then` is callable, extracts the first argument
168
+ ? Awaited < V > // recursively unwrap the value
169
+ : never // the argument to `then` was not callable
170
+ : T // non-object or non-thenable
171
+
162
172
/**
163
173
* Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
164
174
* purposes. For internal use only.
@@ -194,12 +204,12 @@ export interface _StoreOnActionListenerContext<
194
204
after : (
195
205
callback : A extends Record < ActionName , _Method >
196
206
? (
197
- resolvedReturn : Awaited < ReturnType < A [ ActionName ] > >
207
+ resolvedReturn : _Awaited < ReturnType < A [ ActionName ] > >
198
208
// allow the after callback to override the return value
199
209
) =>
200
210
| void
201
211
| ReturnType < A [ ActionName ] >
202
- | Awaited < ReturnType < A [ ActionName ] > >
212
+ | _Awaited < ReturnType < A [ ActionName ] > >
203
213
: ( ) => void
204
214
) => void
205
215
You can’t perform that action at this time.
0 commit comments