Now can be enabled with app.config.warnRecursiveComputed option.
close #10341
public _cacheable: boolean
+ /**
+ * Dev only
+ */
+ _warnRecursive?: boolean
+
constructor(
private getter: ComputedGetter<T>,
private readonly _setter: ComputedSetter<T>,
}
trackRefValue(self)
if (self.effect._dirtyLevel >= DirtyLevels.MaybeDirty_ComputedSideEffect) {
- __DEV__ && warn(COMPUTED_SIDE_EFFECT_WARN, `\n\ngetter: `, this.getter)
+ if (__DEV__ && (__TEST__ || this._warnRecursive)) {
+ warn(COMPUTED_SIDE_EFFECT_WARN, `\n\ngetter: `, this.getter)
+ }
triggerRefValue(self, DirtyLevels.MaybeDirty_ComputedSideEffect)
}
return self._value
type WritableComputedOptions,
type ComputedGetter,
type ComputedSetter,
+ type ComputedRefImpl,
} from './computed'
export { deferredComputed } from './deferredComputed'
export {
-import { computed as _computed } from '@vue/reactivity'
-import { isInSSRComponentSetup } from './component'
+import { type ComputedRefImpl, computed as _computed } from '@vue/reactivity'
+import { getCurrentInstance, isInSSRComponentSetup } from './component'
export const computed: typeof _computed = (
getterOrOptions: any,
debugOptions?: any,
) => {
// @ts-expect-error
- return _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
+ const c = _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
+ if (__DEV__) {
+ const i = getCurrentInstance()
+ if (i && i.appContext.config.warnRecursiveComputed) {
+ ;(c as unknown as ComputedRefImpl<any>)._warnRecursive = true
+ }
+ }
+ return c
}
* @deprecated use config.compilerOptions.isCustomElement
*/
isCustomElement?: (tag: string) => boolean
+
+ /**
+ * TODO document for 3.5
+ * Enable warnings for computed getters that recursively trigger itself.
+ */
+ warnRecursiveComputed?: boolean
}
export interface AppContext {