Skip to content

Commit

Permalink
fix(types): allow string for watch handlers in options (#10396)
Browse files Browse the repository at this point in the history
* Allow watch handler to be string as it is supported

* Move string type to WatchHandler itself

* Removed string type as it moved to WatchHandler
  • Loading branch information
OrkhanAlikhanov committed Sep 21, 2020
1 parent b8bd149 commit 668e1e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/options.d.ts
Expand Up @@ -76,7 +76,7 @@ export interface ComponentOptions<
propsData?: object;
computed?: Accessors<Computed>;
methods?: Methods;
watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any> | string>;
watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any>>;

el?: Element | string;
template?: string;
Expand Down Expand Up @@ -169,7 +169,7 @@ export interface ComputedOptions<T> {
cache?: boolean;
}

export type WatchHandler<T> = (val: T, oldVal: T) => void;
export type WatchHandler<T> = string | ((val: T, oldVal: T) => void);

export interface WatchOptions {
deep?: boolean;
Expand Down
4 changes: 4 additions & 0 deletions types/test/options-test.ts
Expand Up @@ -168,6 +168,10 @@ Vue.component('component', {
this.a = val
},
deep: true
},
d: {
handler: 'someMethod',
immediate: true
}
},
el: "#app",
Expand Down

0 comments on commit 668e1e6

Please sign in to comment.