]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(types): fix extension for TS 4.3
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 3 Jun 2021 09:20:23 +0000 (11:20 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 3 Jun 2021 09:20:23 +0000 (11:20 +0200)
src/mapHelpers.ts
src/store.ts

index 00b8c9004d098cd7e75a1f5407fcf4e4ead4139d..0a6f1ff7d83bb8c85d9bd82b098d48fc711c1295 100644 (file)
@@ -30,10 +30,13 @@ export type _StoreObject<S> = 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 {
index 63b91f9d85d28e1a9db53b6b5ab788d477829062..0ff26be7f3129a754f6f4836f1f607f0968d52dc 100644 (file)
@@ -333,10 +333,7 @@ function buildStoreToUse<
       let ret: ReturnType<A[typeof actionName]>
       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