Skip to content

Commit 892fb6d

Browse files
committed
types: use more consistent naming for apiWatch type exports
BREAKING CHANGE: Some watch API types are renamed. - `BaseWatchOptions` -> `WatchOptionsBase` - `StopHandle` -> `WatchStopHandle`
1 parent 8ab44e1 commit 892fb6d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/runtime-core/src/apiWatch.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ type MapOldSources<T, Immediate> = {
5454

5555
type InvalidateCbRegistrator = (cb: () => void) => void
5656

57-
export interface BaseWatchOptions {
57+
export interface WatchOptionsBase {
5858
flush?: 'pre' | 'post' | 'sync'
5959
onTrack?: ReactiveEffectOptions['onTrack']
6060
onTrigger?: ReactiveEffectOptions['onTrigger']
6161
}
6262

63-
export interface WatchOptions<Immediate = boolean> extends BaseWatchOptions {
63+
export interface WatchOptions<Immediate = boolean> extends WatchOptionsBase {
6464
immediate?: Immediate
6565
deep?: boolean
6666
}
6767

68-
export type StopHandle = () => void
68+
export type WatchStopHandle = () => void
6969

7070
const invoke = (fn: Function) => fn()
7171

7272
// Simple effect.
7373
export function watchEffect(
7474
effect: WatchEffect,
75-
options?: BaseWatchOptions
76-
): StopHandle {
75+
options?: WatchOptionsBase
76+
): WatchStopHandle {
7777
return doWatch(effect, null, options)
7878
}
7979

@@ -85,7 +85,7 @@ export function watch<T, Immediate extends Readonly<boolean> = false>(
8585
source: WatchSource<T>,
8686
cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>,
8787
options?: WatchOptions<Immediate>
88-
): StopHandle
88+
): WatchStopHandle
8989

9090
// overload #2: array of multiple sources + cb
9191
// Readonly constraint helps the callback to correctly infer value types based
@@ -98,14 +98,14 @@ export function watch<
9898
sources: T,
9999
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
100100
options?: WatchOptions<Immediate>
101-
): StopHandle
101+
): WatchStopHandle
102102

103103
// implementation
104104
export function watch<T = any>(
105105
source: WatchSource<T> | WatchSource<T>[],
106106
cb: WatchCallback<T>,
107107
options?: WatchOptions
108-
): StopHandle {
108+
): WatchStopHandle {
109109
if (__DEV__ && !isFunction(cb)) {
110110
warn(
111111
`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
@@ -120,7 +120,7 @@ function doWatch(
120120
source: WatchSource | WatchSource[] | WatchEffect,
121121
cb: WatchCallback | null,
122122
{ immediate, deep, flush, onTrack, onTrigger }: WatchOptions = EMPTY_OBJ
123-
): StopHandle {
123+
): WatchStopHandle {
124124
if (__DEV__ && !cb) {
125125
if (immediate !== undefined) {
126126
warn(
@@ -274,7 +274,7 @@ export function instanceWatch(
274274
source: string | Function,
275275
cb: Function,
276276
options?: WatchOptions
277-
): StopHandle {
277+
): WatchStopHandle {
278278
const publicThis = this.proxy as any
279279
const getter = isString(source)
280280
? () => publicThis[source]

packages/runtime-core/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ export {
159159
export {
160160
// types
161161
WatchEffect,
162-
BaseWatchOptions,
163162
WatchOptions,
163+
WatchOptionsBase,
164164
WatchCallback,
165165
WatchSource,
166-
StopHandle
166+
WatchStopHandle
167167
} from './apiWatch'
168168
export { InjectionKey } from './apiInject'
169169
export {

0 commit comments

Comments
 (0)