]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: remove internal type `_Awaited`
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 1 Feb 2025 22:30:04 +0000 (23:30 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 1 Feb 2025 22:30:04 +0000 (23:30 +0100)
BREAKING CHANGE: We now use the native `Awaited` introduced in TS 4.5.
This shouldn't affect you.

packages/pinia/src/index.ts
packages/pinia/src/types.ts

index 7db2b4fd39ce46044897f904f76553f7c9cee8d3..87f845cf70ea811372a53d7e6dfc00899a432216 100644 (file)
@@ -48,7 +48,6 @@ export type {
   _ExtractGettersFromSetupStore_Keys,
   _ExtractStateFromSetupStore_Keys,
   _UnwrapAll,
-  _Awaited,
 } from './types'
 export { MutationType } from './types'
 
index 79a188df71f13d9f381b7b3354d1f4ff6a78dba8..37054ac656c4dfaa66094ba1fd17e4e1c8bd90cb 100644 (file)
@@ -158,16 +158,6 @@ export type SubscriptionCallback<S> = (
   state: UnwrapRef<S>
 ) => void
 
-// to support TS 4.4
-// TODO: remove in 2.1.0, use Awaited, and up the peer dep to TS 4.5
-export type _Awaited<T> = T extends null | undefined
-  ? T // special case for `null | undefined` when not in `--strictNullChecks` mode
-  : T extends object & { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
-    ? F extends (value: infer V, ...args: any) => any // if the argument to `then` is callable, extracts the first argument
-      ? _Awaited<V> // recursively unwrap the value
-      : never // the argument to `then` was not callable
-    : T // non-object or non-thenable
-
 /**
  * Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
  * purposes. For internal use only.
@@ -201,7 +191,7 @@ export interface _StoreOnActionListenerContext<
    */
   after: (
     callback: A extends Record<ActionName, _Method>
-      ? (resolvedReturn: _Awaited<ReturnType<A[ActionName]>>) => void
+      ? (resolvedReturn: Awaited<ReturnType<A[ActionName]>>) => void
       : () => void
   ) => void