From ce48ec46e0d7626eeefa0ee9c4e8c6b65fce31e1 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 1 Feb 2025 23:30:04 +0100 Subject: [PATCH] refactor: remove internal type `_Awaited` BREAKING CHANGE: We now use the native `Awaited` introduced in TS 4.5. This shouldn't affect you. --- packages/pinia/src/index.ts | 1 - packages/pinia/src/types.ts | 12 +----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/pinia/src/index.ts b/packages/pinia/src/index.ts index 7db2b4fd..87f845cf 100644 --- a/packages/pinia/src/index.ts +++ b/packages/pinia/src/index.ts @@ -48,7 +48,6 @@ export type { _ExtractGettersFromSetupStore_Keys, _ExtractStateFromSetupStore_Keys, _UnwrapAll, - _Awaited, } from './types' export { MutationType } from './types' diff --git a/packages/pinia/src/types.ts b/packages/pinia/src/types.ts index 79a188df..37054ac6 100644 --- a/packages/pinia/src/types.ts +++ b/packages/pinia/src/types.ts @@ -158,16 +158,6 @@ export type SubscriptionCallback = ( state: UnwrapRef ) => 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 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 // 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 - ? (resolvedReturn: _Awaited>) => void + ? (resolvedReturn: Awaited>) => void : () => void ) => void -- 2.47.3