apiComputed.ts 554 B

1234567891011121314151617
  1. import { type ComputedRefImpl, computed as _computed } from '@vue/reactivity'
  2. import { getCurrentInstance, isInSSRComponentSetup } from './component'
  3. export const computed: typeof _computed = (
  4. getterOrOptions: any,
  5. debugOptions?: any,
  6. ) => {
  7. // @ts-expect-error
  8. const c = _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
  9. if (__DEV__) {
  10. const i = getCurrentInstance()
  11. if (i && i.appContext.config.warnRecursiveComputed) {
  12. ;(c as unknown as ComputedRefImpl<any>)._warnRecursive = true
  13. }
  14. }
  15. return c as any
  16. }