Skip to content

Commit 73c5614

Browse files
committed
update types for new features
1 parent 8d25e8f commit 73c5614

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

flow/component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ declare interface Component {
6969
_vnode: ?VNode;
7070
_staticTrees: ?Array<VNode>;
7171
_hasHookEvent: boolean;
72+
_provided: ?Object;
7273

7374
// private methods
7475
// lifecycle

flow/options.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,44 @@ declare type ComponentOptions = {
2424
cache?: boolean
2525
}
2626
};
27-
methods?: {
28-
[key: string]: Function
29-
};
30-
watch?: {
31-
[key: string]: Function | string
32-
};
27+
methods?: { [key: string]: Function };
28+
watch?: { [key: string]: Function | string };
29+
3330
// DOM
3431
el?: string | Element;
3532
template?: string;
3633
render: (h: () => VNode) => VNode;
3734
renderError?: (h: () => VNode, err: Error) => VNode;
3835
staticRenderFns?: Array<() => VNode>;
36+
3937
// lifecycle
4038
beforeCreate?: Function;
4139
created?: Function;
4240
beforeMount?: Function;
4341
mounted?: Function;
4442
beforeUpdate?: Function;
4543
updated?: Function;
44+
activated?: Function;
45+
deactivated?: Function;
46+
beforeDestroy?: Function;
47+
destroyed?: Function;
48+
4649
// assets
4750
directives?: { [key: string]: Object };
4851
components?: { [key: string]: Class<Component> };
4952
transitions?: { [key: string]: Object };
5053
filters?: { [key: string]: Function };
54+
55+
// context
56+
provide?: Object | () => Object;
57+
inject?: { [key: string]: string } | Array<string>;
58+
59+
// component v-model customization
60+
model?: {
61+
prop?: string;
62+
event?: string;
63+
};
64+
5165
// misc
5266
parent?: Component;
5367
mixins?: Array<Object>;

src/core/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Config = {
99
productionTip: boolean;
1010
performance: boolean;
1111
devtools: boolean;
12-
errorHandler: ?Function;
12+
errorHandler: ?(err: Error, vm: Component, info: string) => void;
1313
ignoredElements: Array<string>;
1414
keyCodes: { [key: string]: number };
1515
// platform

src/core/instance/inject.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
export function initInjections (vm) {
2-
const { provide, inject } = vm.$options
1+
/* @flow */
2+
3+
export function initInjections (vm: Component) {
4+
const provide = vm.$options.provide
5+
const inject: any = vm.$options.inject
36
if (provide) {
47
vm._provided = typeof provide === 'function'
58
? provide.call(vm)
69
: provide
710
}
811
if (inject) {
12+
// inject is :any because flow is not smart enough to figure out cached
13+
// isArray here
914
const isArray = Array.isArray(inject)
1015
const keys = isArray ? inject : Object.keys(inject)
1116
for (let i = 0; i < keys.length; i++) {

types/options.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export interface ComponentOptions<V extends Vue> {
4040
transitions?: { [key: string]: Object };
4141
filters?: { [key: string]: Function };
4242

43+
provide?: Object | (() => Object);
44+
inject?: { [key: string]: string } | Array<string>;
45+
46+
model?: {
47+
prop?: string;
48+
event?: string;
49+
};
50+
4351
parent?: Vue;
4452
mixins?: (ComponentOptions<Vue> | typeof Vue)[];
4553
name?: string;

types/vue.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export declare class Vue {
7171
silent: boolean;
7272
optionMergeStrategies: any;
7373
devtools: boolean;
74-
errorHandler(err: Error, vm: Vue): void;
74+
productionTip: boolean;
75+
performance: boolean;
76+
errorHandler(err: Error, vm: Vue, info: string): void;
77+
ignoredElements: string[];
7578
keyCodes: { [key: string]: number };
7679
}
7780

0 commit comments

Comments
 (0)