From: skirtle <65301168+skirtles-code@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:40:36 +0000 (+0000) Subject: refactor(reactivity): add `__NO_SIDE_EFFECTS__` comments (#14308) X-Git-Tag: v3.5.27~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cde5d8f0efb1644d2f3cc1bfa7489c244f17f5df;p=thirdparty%2Fvuejs%2Fcore.git refactor(reactivity): add `__NO_SIDE_EFFECTS__` comments (#14308) --- diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index ea798e201d..1e2623cecf 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -194,6 +194,7 @@ export function computed( options: WritableComputedOptions, debugOptions?: DebuggerOptions, ): WritableComputedRef +/*@__NO_SIDE_EFFECTS__*/ export function computed( getterOrOptions: ComputedGetter | WritableComputedOptions, debugOptions?: DebuggerOptions, diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 802f7fc68e..e383581785 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -89,6 +89,7 @@ export type Reactive = UnwrapNestedRefs & * @see {@link https://vuejs.org/api/reactivity-core.html#reactive} */ export function reactive(target: T): Reactive +/*@__NO_SIDE_EFFECTS__*/ export function reactive(target: object) { // if trying to observe a readonly proxy, return the readonly version. if (isReadonly(target)) { @@ -137,6 +138,7 @@ export type ShallowReactive = T & { [ShallowReactiveMarker]?: true } * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive} */ +/*@__NO_SIDE_EFFECTS__*/ export function shallowReactive( target: T, ): ShallowReactive { @@ -202,6 +204,7 @@ export type DeepReadonly = T extends Builtin * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-core.html#readonly} */ +/*@__NO_SIDE_EFFECTS__*/ export function readonly( target: T, ): DeepReadonly> { @@ -244,6 +247,7 @@ export function readonly( * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly} */ +/*@__NO_SIDE_EFFECTS__*/ export function shallowReadonly(target: T): Readonly { return createReactiveObject( target, @@ -315,6 +319,7 @@ function createReactiveObject( * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive} */ +/*@__NO_SIDE_EFFECTS__*/ export function isReactive(value: unknown): boolean { if (isReadonly(value)) { return isReactive((value as Target)[ReactiveFlags.RAW]) @@ -333,10 +338,12 @@ export function isReactive(value: unknown): boolean { * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly} */ +/*@__NO_SIDE_EFFECTS__*/ export function isReadonly(value: unknown): boolean { return !!(value && (value as Target)[ReactiveFlags.IS_READONLY]) } +/*@__NO_SIDE_EFFECTS__*/ export function isShallow(value: unknown): boolean { return !!(value && (value as Target)[ReactiveFlags.IS_SHALLOW]) } @@ -348,6 +355,7 @@ export function isShallow(value: unknown): boolean { * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy} */ +/*@__NO_SIDE_EFFECTS__*/ export function isProxy(value: any): boolean { return value ? !!value[ReactiveFlags.RAW] : false } @@ -375,6 +383,7 @@ export function isProxy(value: any): boolean { * @param observed - The object for which the "raw" value is requested. * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw} */ +/*@__NO_SIDE_EFFECTS__*/ export function toRaw(observed: T): T { const raw = observed && (observed as Target)[ReactiveFlags.RAW] return raw ? toRaw(raw) : observed diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 1b8eaaf88d..598b319f30 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -43,6 +43,7 @@ export interface Ref { * @see {@link https://vuejs.org/api/reactivity-utilities.html#isref} */ export function isRef(r: Ref | unknown): r is Ref +/*@__NO_SIDE_EFFECTS__*/ export function isRef(r: any): r is Ref { return r ? r[ReactiveFlags.IS_REF] === true : false } @@ -58,6 +59,7 @@ export function ref( value: T, ): [T] extends [Ref] ? IfAny, T> : Ref, UnwrapRef | T> export function ref(): Ref +/*@__NO_SIDE_EFFECTS__*/ export function ref(value?: unknown) { return createRef(value, false) } @@ -93,6 +95,7 @@ export function shallowRef( : ShallowRef : ShallowRef export function shallowRef(): ShallowRef +/*@__NO_SIDE_EFFECTS__*/ export function shallowRef(value?: unknown) { return createRef(value, true) } @@ -338,6 +341,7 @@ export type ToRefs = { * @param object - Reactive object to be made into an object of linked refs. * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs} */ +/*@__NO_SIDE_EFFECTS__*/ export function toRefs(object: T): ToRefs { if (__DEV__ && !isProxy(object)) { warn(`toRefs() expects a reactive object but received a plain one.`) @@ -474,6 +478,7 @@ export function toRef( key: K, defaultValue: T[K], ): ToRef> +/*@__NO_SIDE_EFFECTS__*/ export function toRef( source: Record | MaybeRef, key?: string,