Repository: vuejs/composition-api
Pull request #688 (2021-04-25 19:26:52)

types: expose ComponentPropsOptions types to align with vue-next
https://gist.github.com/TakNePoidet/39de3d40ce492f515b5e8846f0a2d1fe

antfu: Can you omit the changes to package.json and yarn.lock, then follow the same code format as other code in this repo? Thanks

Patch:
diff --git a/src/component/componentOptions.ts b/src/component/componentOptions.ts
index 9a17738..eb8f7ed 100644
--- a/src/component/componentOptions.ts
+++ b/src/component/componentOptions.ts
@@ -2,7 +2,7 @@ import Vue, { VNode, ComponentOptions as Vue2ComponentOptions } from 'vue'
 import { Data } from './common'
 import { ComponentPropsOptions, ExtractPropTypes } from './componentProps'
 import { ComponentInstance, ComponentRenderProxy } from './componentProxy'
-
+export { ComponentPropsOptions } from './componentProps'
 export interface SetupContext {
   readonly attrs: Data
   readonly slots: Readonly<{ [key in string]?: (...args: any[]) => VNode[] }>
diff --git a/src/component/index.ts b/src/component/index.ts
index 86a79ee..8648456 100644
--- a/src/component/index.ts
+++ b/src/component/index.ts
@@ -1,6 +1,12 @@
 export { defineComponent } from './defineComponent'
 export { defineAsyncComponent } from './defineAsyncComponent'
-export { SetupFunction, SetupContext } from './componentOptions'
+export {
+  SetupFunction,
+  SetupContext,
+  ComputedOptions,
+  MethodOptions,
+  ComponentPropsOptions,
+} from './componentOptions'
 export { ComponentInstance, ComponentRenderProxy } from './componentProxy'
 export { Data } from './common'
 export {
diff --git a/src/reactivity/reactive.ts b/src/reactivity/reactive.ts
index 6cdaa82..fec1cea 100644
--- a/src/reactivity/reactive.ts
+++ b/src/reactivity/reactive.ts
@@ -1,6 +1,14 @@
 import { AnyObject } from '../types/basic'
 import { getRegisteredVueOrDefault } from '../runtimeContext'
-import { isPlainObject, def, warn, isArray, hasOwn, noopFn } from '../utils'
+import {
+  isPlainObject,
+  def,
+  warn,
+  isArray,
+  hasOwn,
+  noopFn,
+  isObject,
+} from '../utils'
 import { isComponentInstance, defineComponentInstance } from '../utils/helper'
 import { RefKey } from '../utils/symbols'
 import { isRef, UnwrapRef } from './ref'
@@ -190,10 +198,11 @@ export function shallowReactive(obj: any): any {
  * Make obj reactivity
  */
 export function reactive<T extends object>(obj: T): UnwrapRef<T> {
-  if (__DEV__ && !obj) {
-    warn('"reactive()" is called without provide an "object".')
-    // @ts-ignore
-    return
+  if (!isObject(obj)) {
+    if (__DEV__) {
+      warn('"reactive()" is called without provide an "object".')
+    }
+    return obj as any
   }
 
   if (
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index 32d0961..dff6823 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -14,21 +14,17 @@ export const hasSymbol =
 
 export const noopFn: any = (_: any) => _
 
-const sharedPropertyDefinition = {
-  enumerable: true,
-  configurable: true,
-  get: noopFn,
-  set: noopFn,
-}
-
 export function proxy(
   target: any,
   key: string,
   { get, set }: { get?: Function; set?: Function }
 ) {
-  sharedPropertyDefinition.get = get || noopFn
-  sharedPropertyDefinition.set = set || noopFn
-  Object.defineProperty(target, key, sharedPropertyDefinition)
+  Object.defineProperty(target, key, {
+    enumerable: true,
+    configurable: true,
+    get: get || noopFn,
+    set: set || noopFn,
+  })
 }
 
 export function def(obj: Object, key: string, val: any, enumerable?: boolean) {


Test patch:
diff --git a/test/v3/reactivity/reactive.spec.ts b/test/v3/reactivity/reactive.spec.ts
index 04034ba..5576836 100644
--- a/test/v3/reactivity/reactive.spec.ts
+++ b/test/v3/reactivity/reactive.spec.ts
@@ -142,6 +142,7 @@ describe('reactivity/reactive', () => {
   test('non-observable values', () => {
     const assertValue = (value: any) => {
       expect(isReactive(reactive(value))).toBe(false)
+      expect(reactive(value)).toBe(value)
       // expect(warnSpy).toHaveBeenLastCalledWith(`value cannot be made reactive: ${String(value)}`);
     }
 
@@ -167,7 +168,7 @@ describe('reactivity/reactive', () => {
     const d = new Date()
     expect(reactive(d)).toBe(d)
 
-    expect(warn).toBeCalledTimes(3)
+    expect(warn).toBeCalledTimes(12)
     expect(
       warn.mock.calls.map((call) => {
         expect(call[0]).toBe(