From: Eduardo San Martin Morote Date: Thu, 3 Jun 2021 09:20:23 +0000 (+0200) Subject: fix(types): fix extension for TS 4.3 X-Git-Tag: v2.0.0-beta.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff5c1e6fb5c559d3cae103a3049046ee97ce3c0;p=thirdparty%2Fvuejs%2Fpinia.git fix(types): fix extension for TS 4.3 --- 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