]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(vue2): fix isComputed check for getters
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 6 Sep 2021 15:53:34 +0000 (17:53 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 6 Sep 2021 15:53:34 +0000 (17:53 +0200)
packages/pinia/src/store.ts

index b77f1f2ff03a0be242cc7a84c34f9056373a1153..690bad224d14f10ed76e4b927a34721c05f168b5 100644 (file)
@@ -77,6 +77,13 @@ const { assign } = Object
 
 function isComputed<T>(value: ComputedRef<T> | unknown): value is ComputedRef<T>
 function isComputed(o: any): o is ComputedRef {
+  if (isVue2) {
+    const descriptor = o ? Object.getOwnPropertyDescriptor(o, 'value') : null
+    return (descriptor &&
+      descriptor.get &&
+      // TODO: make something in @vue/composition-api to be able to check this
+      descriptor.get.toString().length > 42) as boolean
+  }
   return o && o.effect
 }