Skip to content

Commit b8102b5

Browse files
feat(watch): update watch return typo in watchExtractedObservable, watchDebounced, watchDeep, watchImmediate, watchOnce, watchThrottled and watchWithFilter (#4896)
1 parent 89702bb commit b8102b5

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

packages/guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function watchDebounced(
9797
source: any,
9898
cb: any,
9999
options: WatchDebouncedOptions = {},
100-
): WatchStopHandle {
100+
): WatchHandle {
101101
return watch(
102102
source,
103103
() => { /* ... */ },

packages/rxjs/watchExtractedObservable/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MapOldSources, MapSources, MultiWatchSources } from '@vueuse/shared'
22
import type { Observable, Subscription } from 'rxjs'
3-
import type { WatchOptions, WatchSource, WatchStopHandle } from 'vue'
3+
import type { WatchHandle, WatchOptions, WatchSource } from 'vue'
44
import { tryOnScopeDispose } from '@vueuse/shared'
55
import { watch } from 'vue'
66

@@ -27,7 +27,7 @@ export function watchExtractedObservable<
2727
callback: (snapshot: E) => void,
2828
subscriptionOptions?: WatchExtractedObservableOptions,
2929
watchOptions?: WatchOptions<Immediate>
30-
): WatchStopHandle
30+
): WatchHandle
3131

3232
// overload: multiple sources w/ `as const`
3333
// watch([foo, bar] as const, () => {})
@@ -46,7 +46,7 @@ export function watchExtractedObservable<
4646
callback: (snapshot: E) => void,
4747
subscriptionOptions?: WatchExtractedObservableOptions,
4848
watchOptions?: WatchOptions<Immediate>
49-
): WatchStopHandle
49+
): WatchHandle
5050

5151
// overload: single source + cb
5252
export function watchExtractedObservable<
@@ -63,7 +63,7 @@ export function watchExtractedObservable<
6363
callback: (snapshot: E) => void,
6464
subscriptionOptions?: WatchExtractedObservableOptions,
6565
watchOptions?: WatchOptions<Immediate>
66-
): WatchStopHandle
66+
): WatchHandle
6767

6868
// overload: watching reactive object w/ cb
6969
export function watchExtractedObservable<
@@ -80,7 +80,7 @@ export function watchExtractedObservable<
8080
callback: (snapshot: E) => void,
8181
subscriptionOptions?: WatchExtractedObservableOptions,
8282
watchOptions?: WatchOptions<Immediate>
83-
): WatchStopHandle
83+
): WatchHandle
8484

8585
// implementation
8686
export function watchExtractedObservable<T = any, E = unknown, Immediate extends Readonly<boolean> = false>(
@@ -89,7 +89,7 @@ export function watchExtractedObservable<T = any, E = unknown, Immediate extends
8989
callback: (snapshot: E) => void,
9090
subscriptionOptions?: WatchExtractedObservableOptions,
9191
watchOptions?: WatchOptions<Immediate>,
92-
): WatchStopHandle {
92+
): WatchHandle {
9393
let subscription: Subscription | undefined
9494

9595
tryOnScopeDispose(() => {

packages/shared/watchDebounced/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MaybeRefOrGetter, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { MaybeRefOrGetter, WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { DebounceFilterOptions, MapOldSources, MapSources } from '../utils'
33
import { debounceFilter } from '../utils'
44
import { watchWithFilter } from '../watchWithFilter'
@@ -8,16 +8,16 @@ export interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate
88
}
99

1010
// overloads
11-
export function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
12-
export function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
13-
export function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
11+
export function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchHandle
12+
export function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchHandle
13+
export function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchHandle
1414

1515
// implementation
1616
export function watchDebounced<Immediate extends Readonly<boolean> = false>(
1717
source: any,
1818
cb: any,
1919
options: WatchDebouncedOptions<Immediate> = {},
20-
): WatchStopHandle {
20+
): WatchHandle {
2121
const {
2222
debounce = 0,
2323
maxWait = undefined,

packages/shared/watchDeep/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { MapOldSources, MapSources } from '../utils/types'
33

44
import { watch } from 'vue'
@@ -11,13 +11,13 @@ export function watchDeep<
1111
source: [...T],
1212
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
1313
options?: Omit<WatchOptions<Immediate>, 'deep'>
14-
): WatchStopHandle
14+
): WatchHandle
1515

1616
export function watchDeep<T, Immediate extends Readonly<boolean> = false>(
1717
source: WatchSource<T>,
1818
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
1919
options?: Omit<WatchOptions<Immediate>, 'deep'>
20-
): WatchStopHandle
20+
): WatchHandle
2121

2222
export function watchDeep<
2323
T extends object,
@@ -26,7 +26,7 @@ export function watchDeep<
2626
source: T,
2727
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
2828
options?: Omit<WatchOptions<Immediate>, 'deep'>
29-
): WatchStopHandle
29+
): WatchHandle
3030

3131
/**
3232
* Shorthand for watching value with {deep: true}

packages/shared/watchImmediate/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { MapOldSources, MapSources } from '../utils/types'
33

44
import { watch } from 'vue'
@@ -8,19 +8,19 @@ export function watchImmediate<T extends Readonly<WatchSource<unknown>[]>>(
88
source: [...T],
99
cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,
1010
options?: Omit<WatchOptions<true>, 'immediate'>
11-
): WatchStopHandle
11+
): WatchHandle
1212

1313
export function watchImmediate<T>(
1414
source: WatchSource<T>,
1515
cb: WatchCallback<T, T | undefined>,
1616
options?: Omit<WatchOptions<true>, 'immediate'>
17-
): WatchStopHandle
17+
): WatchHandle
1818

1919
export function watchImmediate<T extends object>(
2020
source: T,
2121
cb: WatchCallback<T, T | undefined>,
2222
options?: Omit<WatchOptions<true>, 'immediate'>
23-
): WatchStopHandle
23+
): WatchHandle
2424

2525
/**
2626
* Shorthand for watching value with {immediate: true}

packages/shared/watchOnce/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { MapOldSources, MapSources } from '../utils'
33
import { watch } from 'vue'
44

@@ -7,19 +7,19 @@ export function watchOnce<T extends Readonly<WatchSource<unknown>[]>>(
77
source: [...T],
88
cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,
99
options?: Omit<WatchOptions<true>, 'once'>
10-
): WatchStopHandle
10+
): WatchHandle
1111

1212
export function watchOnce<T>(
1313
source: WatchSource<T>,
1414
cb: WatchCallback<T, T | undefined>,
1515
options?: Omit<WatchOptions<true>, 'once'>
16-
): WatchStopHandle
16+
): WatchHandle
1717

1818
export function watchOnce<T extends object>(
1919
source: T,
2020
cb: WatchCallback<T, T | undefined>,
2121
options?: Omit<WatchOptions<true>, 'once'>
22-
): WatchStopHandle
22+
): WatchHandle
2323

2424
/**
2525
* Shorthand for watching value with { once: true }

packages/shared/watchThrottled/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MaybeRefOrGetter, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { MaybeRefOrGetter, WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { MapOldSources, MapSources } from '../utils'
33
import { throttleFilter } from '../utils'
44
import { watchWithFilter } from '../watchWithFilter'
@@ -10,16 +10,16 @@ export interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate
1010
}
1111

1212
// overloads
13-
export function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
14-
export function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
15-
export function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
13+
export function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchHandle
14+
export function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchHandle
15+
export function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchHandle
1616

1717
// implementation
1818
export function watchThrottled<Immediate extends Readonly<boolean> = false>(
1919
source: any,
2020
cb: any,
2121
options: WatchThrottledOptions<Immediate> = {},
22-
): WatchStopHandle {
22+
): WatchHandle {
2323
const {
2424
throttle = 0,
2525
trailing = true,

packages/shared/watchWithFilter/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue'
1+
import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue'
22
import type { ConfigurableEventFilter, MapOldSources, MapSources } from '../utils'
33
import { watch } from 'vue'
44
import { bypassFilter, createFilterWrapper } from '../utils'
55

66
export interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {}
77

88
// overloads
9-
export function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
10-
export function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
11-
export function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
9+
export function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchHandle
10+
export function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchHandle
11+
export function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchHandle
1212

1313
// implementation
1414
export function watchWithFilter<Immediate extends Readonly<boolean> = false>(
1515
source: any,
1616
cb: any,
1717
options: WatchWithFilterOptions<Immediate> = {},
18-
): WatchStopHandle {
18+
): WatchHandle {
1919
const {
2020
eventFilter = bypassFilter,
2121
...watchOptions

0 commit comments

Comments
 (0)