Repository: vuejs/composition-api (ts)

Issue:
Ref not unwrapping other refs set with `set` on Node
- Clone https://github.com/posva/bug-report-vca
- `yarn`
- `node index.js`

It should log an object `{ old: false, new: true }` but it logs `{ old: false, new: { value: true }}`

There is also an index.html file to show the (expected) behavior on a browser

Pull request description:
feat(reactivity): unwrap value when using `set`
fix #721


When using `set` if the object is not `reactive` it won't execute the unwrapping as per expected on a reactive object, in vue 2 every object used is expected to be `reactive` by default so I believe is safe to assume that if you calling `set` we will want to unwrap the value if is a `ref`

Patch:
diff --git a/src/reactivity/set.ts b/src/reactivity/set.ts
index f2a733c..f33032d 100644
--- a/src/reactivity/set.ts
+++ b/src/reactivity/set.ts
@@ -34,7 +34,8 @@ export function set<T>(target: any, key: any, val: T): T {
     return val
   }
   if (!ob) {
-    target[key] = val
+    // If we are using `set` we can assume that the unwrapping is intended
+    defineAccessControl(target, key, val)
     return val
   }
   defineReactive(ob.value, key, val)


Test patch:
diff --git a/test/ssr/ssrReactive.spec.ts b/test/ssr/ssrReactive.spec.ts
index 5c8510c..b4325fa 100644
--- a/test/ssr/ssrReactive.spec.ts
+++ b/test/ssr/ssrReactive.spec.ts
@@ -90,4 +90,16 @@ describe('SSR Reactive', () => {
 
     done()
   })
+
+  // #721
+  it('should behave correctly', () => {
+    const state = ref({ old: ref(false) })
+    set(state.value, 'new', ref(true))
+    // console.log(process.server, 'state.value', JSON.stringify(state.value))
+
+    expect(state.value).toMatchObject({
+      old: false,
+      new: true,
+    })
+  })
 })