]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
chore: note
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 6 Oct 2024 14:50:12 +0000 (16:50 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 6 Oct 2024 14:50:12 +0000 (16:50 +0200)
[skip ci]

packages/pinia/src/storeToRefs.ts

index 5b268fc991c2e2d03c5c203736388e77514cdb99..9e5dab0e4b30179fe2ecda9b7d3cdaadbfdf450e 100644 (file)
@@ -68,11 +68,14 @@ type _ToStateRefs<SS> =
  * Extracts the return type for `storeToRefs`.
  * Will convert any `getters` into `ComputedRef`.
  */
-export type StoreToRefs<SS extends StoreGeneric> = SS extends unknown
-  ? _ToStateRefs<SS> &
-      ToRefs<PiniaCustomStateProperties<StoreState<SS>>> &
-      _ToComputedRefs<StoreGetters<SS>>
-  : never
+export type StoreToRefs<SS extends StoreGeneric> =
+  // NOTE: always trues but the conditional makes the type distributive
+  // https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
+  SS extends unknown
+    ? _ToStateRefs<SS> &
+        ToRefs<PiniaCustomStateProperties<StoreState<SS>>> &
+        _ToComputedRefs<StoreGetters<SS>>
+    : never
 
 /**
  * Creates an object of references with all the state, getters, and plugin-added