@@ -82,20 +82,14 @@ export function watchEffect(
82
82
// initial value for watchers to trigger on undefined initial values
83
83
const INITIAL_WATCHER_VALUE = { }
84
84
85
- // overload #1: simple effect
86
- export function watch (
87
- effect : WatchEffect ,
88
- options ?: BaseWatchOptions
89
- ) : StopHandle
90
-
91
- // overload #2: single source + cb
85
+ // overload #1: single source + cb
92
86
export function watch < T , Immediate extends Readonly < boolean > = false > (
93
87
source : WatchSource < T > ,
94
88
cb : WatchCallback < T , Immediate extends true ? ( T | undefined ) : T > ,
95
89
options ?: WatchOptions < Immediate >
96
90
) : StopHandle
97
91
98
- // overload #3 : array of multiple sources + cb
92
+ // overload #2 : array of multiple sources + cb
99
93
// Readonly constraint helps the callback to correctly infer value types based
100
94
// on position in the source array. Otherwise the values will get a union type
101
95
// of all possible value types.
@@ -110,24 +104,18 @@ export function watch<
110
104
111
105
// implementation
112
106
export function watch < T = any > (
113
- effectOrSource : WatchSource < T > | WatchSource < T > [ ] | WatchEffect ,
114
- cbOrOptions ? : WatchCallback < T > | WatchOptions ,
107
+ source : WatchSource < T > | WatchSource < T > [ ] ,
108
+ cb : WatchCallback < T > ,
115
109
options ?: WatchOptions
116
110
) : StopHandle {
117
- if ( isFunction ( cbOrOptions ) ) {
118
- // watch(source, cb)
119
- return doWatch ( effectOrSource , cbOrOptions , options )
120
- } else {
121
- // TODO remove this in the next release
122
- __DEV__ &&
123
- warn (
124
- `\`watch(fn, options?)\` signature has been moved to a separate API. ` +
125
- `Use \`watchEffect(fn, options?)\` instead. \`watch\` will only ` +
126
- `support \`watch(source, cb, options?) signature in the next release.`
127
- )
128
- // watch(effect)
129
- return doWatch ( effectOrSource , null , cbOrOptions )
111
+ if ( __DEV__ && ! isFunction ( cb ) ) {
112
+ warn (
113
+ `\`watch(fn, options?)\` signature has been moved to a separate API. ` +
114
+ `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
115
+ `supports \`watch(source, cb, options?) signature.`
116
+ )
130
117
}
118
+ return doWatch ( source , cb , options )
131
119
}
132
120
133
121
function doWatch (
0 commit comments