Browse Source

types: typing for Vue.observable

dev
Evan You 6 years ago
parent
commit
fe2b27ffb9
  1. 2
      flow/global-api.js
  2. 2
      src/core/global-api/index.js
  3. 3
      types/test/vue-test.ts
  4. 2
      types/vue.d.ts

2
flow/global-api.js

@ -16,6 +16,8 @@ declare interface GlobalAPI {
component: (id: string, def?: Class<Component> | Object) => Class<Component>;
filter: (id: string, def?: Function) => Function | void;
observable: <T>(value: T) => T;
// allow dynamic method registration
[key: string]: any
};

2
src/core/global-api/index.js

@ -46,7 +46,7 @@ export function initGlobalAPI (Vue: GlobalAPI) {
Vue.nextTick = nextTick
// 2.6 explicit observable API
Vue.observable = (obj: any): any => {
Vue.observable = <T>(obj: T): T => {
observe(obj)
return obj
}

3
types/test/vue-test.ts

@ -200,3 +200,6 @@ declare function decorate<VC extends typeof Vue>(v: VC): VC;
class Decorated extends Vue {
a = 123;
}
const obj = Vue.observable({ a: 1 })
obj.a++

2
types/vue.d.ts

@ -119,6 +119,8 @@ export interface VueConstructor<V extends Vue = Vue> {
staticRenderFns: (() => VNode)[];
};
observable<T>(obj: T): T;
config: VueConfiguration;
}

Loading…
Cancel
Save