Skip to content

Commit ce48ec4

Browse files
committed
refactor: remove internal type _Awaited
BREAKING CHANGE: We now use the native `Awaited` introduced in TS 4.5. This shouldn't affect you.
1 parent 87c6182 commit ce48ec4

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

packages/pinia/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export type {
4848
_ExtractGettersFromSetupStore_Keys,
4949
_ExtractStateFromSetupStore_Keys,
5050
_UnwrapAll,
51-
_Awaited,
5251
} from './types'
5352
export { MutationType } from './types'
5453

packages/pinia/src/types.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,6 @@ export type SubscriptionCallback<S> = (
158158
state: UnwrapRef<S>
159159
) => void
160160

161-
// to support TS 4.4
162-
// TODO: remove in 2.1.0, use Awaited, and up the peer dep to TS 4.5
163-
export type _Awaited<T> = T extends null | undefined
164-
? T // special case for `null | undefined` when not in `--strictNullChecks` mode
165-
: T extends object & { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
166-
? F extends (value: infer V, ...args: any) => any // if the argument to `then` is callable, extracts the first argument
167-
? _Awaited<V> // recursively unwrap the value
168-
: never // the argument to `then` was not callable
169-
: T // non-object or non-thenable
170-
171161
/**
172162
* Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
173163
* purposes. For internal use only.
@@ -201,7 +191,7 @@ export interface _StoreOnActionListenerContext<
201191
*/
202192
after: (
203193
callback: A extends Record<ActionName, _Method>
204-
? (resolvedReturn: _Awaited<ReturnType<A[ActionName]>>) => void
194+
? (resolvedReturn: Awaited<ReturnType<A[ActionName]>>) => void
205195
: () => void
206196
) => void
207197

0 commit comments

Comments
 (0)