File tree Expand file tree Collapse file tree 3 files changed +5
-92
lines changed Expand file tree Collapse file tree 3 files changed +5
-92
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import {
2- type ComputedGetter ,
3- type WritableComputedOptions ,
4- computed as _computed ,
5- } from '@vue/reactivity'
1+ import { computed as _computed } from '@vue/reactivity'
62import { isInSSRComponentSetup } from './component'
7- import { isFunction } from '@vue/shared'
8-
9- /**
10- * For dev warning only.
11- * Context: https://github.com/vuejs/core/discussions/9974
12- */
13- export let isInComputedGetter = false
14-
15- function wrapComputedGetter (
16- getter : ComputedGetter < unknown > ,
17- ) : ComputedGetter < unknown > {
18- return ( ) => {
19- isInComputedGetter = true
20- try {
21- return getter ( )
22- } finally {
23- isInComputedGetter = false
24- }
25- }
26- }
273
284export const computed : typeof _computed = (
29- getterOrOptions : ComputedGetter < unknown > | WritableComputedOptions < unknown > ,
5+ getterOrOptions : any ,
306 debugOptions ?: any ,
317) => {
32- if ( __DEV__ ) {
33- if ( isFunction ( getterOrOptions ) ) {
34- getterOrOptions = wrapComputedGetter ( getterOrOptions )
35- } else {
36- getterOrOptions . get = wrapComputedGetter ( getterOrOptions . get )
37- }
38- }
39-
40- // @ts -expect-error the 3rd argument is hidden from public types
8+ // @ts -expect-error
419 return _computed ( getterOrOptions , debugOptions , isInSSRComponentSetup )
4210}
Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ import {
8585} from './compat/compatConfig'
8686import type { SchedulerJob } from './scheduler'
8787import type { LifecycleHooks } from './enums'
88- import { isInComputedGetter } from './apiComputed'
8988
9089export type Data = Record < string , unknown >
9190
@@ -632,18 +631,8 @@ export function createComponentInstance(
632631
633632export let currentInstance : ComponentInternalInstance | null = null
634633
635- export const getCurrentInstance : ( ) => ComponentInternalInstance | null =
636- ( ) => {
637- if ( __DEV__ && isInComputedGetter ) {
638- warn (
639- `getCurrentInstance() called inside a computed getter. ` +
640- `This is incorrect usage as computed getters are not guaranteed ` +
641- `to be executed with an active component instance. If you are using ` +
642- `a composable inside a computed getter, move it ouside to the setup scope.` ,
643- )
644- }
645- return currentInstance || currentRenderingInstance
646- }
634+ export const getCurrentInstance : ( ) => ComponentInternalInstance | null = ( ) =>
635+ currentInstance || currentRenderingInstance
647636
648637let internalSetCurrentInstance : (
649638 instance : ComponentInternalInstance | null ,
You can’t perform that action at this time.
0 commit comments