From aff5c1e6fb5c559d3cae103a3049046ee97ce3c0 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 3 Jun 2021 11:20:23 +0200 Subject: [PATCH] fix(types): fix extension for TS 4.3 --- src/mapHelpers.ts | 9 ++++++--- src/store.ts | 5 +---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mapHelpers.ts b/src/mapHelpers.ts index 00b8c900..0a6f1ff7 100644 --- a/src/mapHelpers.ts +++ b/src/mapHelpers.ts @@ -30,10 +30,13 @@ export type _StoreObject = S extends StoreDefinition< infer Actions > ? { - [Id in `${Ids}${'suffix' extends keyof MapStoresCustomization + [Id in `${Ids}${MapStoresCustomization extends Record<'suffix', string> ? MapStoresCustomization['suffix'] : 'Store'}`]: () => Store< - Id extends `${infer RealId}${'suffix' extends keyof MapStoresCustomization + Id extends `${infer RealId}${MapStoresCustomization extends Record< + 'suffix', + string + > ? MapStoresCustomization['suffix'] : 'Store'}` ? RealId @@ -82,7 +85,7 @@ export let mapStoreSuffix = 'Store' * @param suffix - new suffix */ export function setMapStoreSuffix( - suffix: 'suffix' extends keyof MapStoresCustomization + suffix: MapStoresCustomization extends Record<'suffix', string> ? MapStoresCustomization['suffix'] : string // could be 'Store' but that would be annoying for JS ): void { diff --git a/src/store.ts b/src/store.ts index 63b91f9d..0ff26be7 100644 --- a/src/store.ts +++ b/src/store.ts @@ -333,10 +333,7 @@ function buildStoreToUse< let ret: ReturnType try { ret = actions[actionName].apply(localStore, args as unknown as any[]) - Promise.resolve(ret) - // @ts-expect-error: can't work this out - .then(afterCallback) - .catch(onErrorCallback) + Promise.resolve(ret).then(afterCallback).catch(onErrorCallback) } catch (error) { onErrorCallback(error) throw error -- 2.47.2