Skip to content

Commit 3ce450b

Browse files
committed
use more proper flow type syntax
1 parent d83088a commit 3ce450b

File tree

3 files changed

+161
-160
lines changed

3 files changed

+161
-160
lines changed

flow/compiler.js

Lines changed: 103 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,147 @@
11
declare type CompilerOptions = {
2-
warn?: Function, // allow customizing warning in different environments, e.g. node
3-
isIE?: boolean, // for detecting IE SVG innerHTML bug
4-
expectHTML?: boolean, // only false for non-web builds
5-
modules?: Array<ModuleOptions>, // platform specific modules, e.g. style, class
6-
staticKeys?: string, // a list of AST properties to be considered static, for optimization
7-
directives?: { [key: string]: Function }, // platform specific directives
8-
isUnaryTag?: (tag: string) => ?boolean, // check if a tag is unary for the platform
9-
isReservedTag?: (tag: string) => ?boolean, // check if a tag is a native for the platform
10-
mustUseProp?: (attr: string) => ?boolean, // check if an attribute should be bound as a property
11-
getTagNamespace?: (tag: string) => ?string, // check the namespace for a tag
12-
transforms?: Array<Function>, // a list of transforms on parsed AST before codegen
13-
preserveWhitespace?: boolean,
2+
warn?: Function; // allow customizing warning in different environments; e.g. node
3+
isIE?: boolean; // for detecting IE SVG innerHTML bug
4+
expectHTML?: boolean; // only false for non-web builds
5+
modules?: Array<ModuleOptions>; // platform specific modules; e.g. style; class
6+
staticKeys?: string; // a list of AST properties to be considered static; for optimization
7+
directives?: { [key: string]: Function }; // platform specific directives
8+
isUnaryTag?: (tag: string) => ?boolean; // check if a tag is unary for the platform
9+
isReservedTag?: (tag: string) => ?boolean; // check if a tag is a native for the platform
10+
mustUseProp?: (attr: string) => ?boolean; // check if an attribute should be bound as a property
11+
getTagNamespace?: (tag: string) => ?string; // check the namespace for a tag
12+
transforms?: Array<Function>; // a list of transforms on parsed AST before codegen
13+
preserveWhitespace?: boolean;
14+
shouldDecodeAttr?: boolean;
1415

1516
// runtime user-configurable
16-
delimiters?: [string, string] // template delimiters
17+
delimiters?: [string, string]; // template delimiters
1718
}
1819

1920
declare type CompiledResult = {
20-
ast: ?ASTElement,
21-
render: string,
22-
staticRenderFns: Array<string>,
23-
errors?: Array<string>
21+
ast: ?ASTElement;
22+
render: string;
23+
staticRenderFns: Array<string>;
24+
errors?: Array<string>;
2425
}
2526

2627
declare type CompiledFunctionResult = {
27-
render: Function,
28-
staticRenderFns: Array<Function>
28+
render: Function;
29+
staticRenderFns: Array<Function>;
2930
}
3031

3132
declare type ModuleOptions = {
32-
transformNode: (el: ASTElement) => void, // transform an element's AST node
33-
genData: (el: ASTElement) => string, // generate extra data string for an element
34-
transformCode?: (el: ASTElement, code: string) => string, // further transform generated code for an element
35-
staticKeys?: Array<string> // AST properties to be considered static
33+
transformNode: (el: ASTElement) => void; // transform an element's AST node
34+
genData: (el: ASTElement) => string; // generate extra data string for an element
35+
transformCode?: (el: ASTElement, code: string) => string; // further transform generated code for an element
36+
staticKeys?: Array<string>; // AST properties to be considered static
3637
}
3738

3839
declare type ASTElementHandler = {
39-
value: string,
40-
modifiers: ?{ [key: string]: true }
40+
value: string;
41+
modifiers: ?{ [key: string]: true };
4142
}
4243

4344
declare type ASTElementHandlers = {
44-
[key: string]: ASTElementHandler | Array<ASTElementHandler>
45+
[key: string]: ASTElementHandler | Array<ASTElementHandler>;
4546
}
4647

4748
declare type ASTElementHooks = { [key: string]: Array<string> }
4849

4950
declare type ASTDirective = {
50-
name: string,
51-
value: ?string,
52-
arg: ?string,
53-
modifiers: ?{ [key: string]: true }
51+
name: string;
52+
value: ?string;
53+
arg: ?string;
54+
modifiers: ?{ [key: string]: true };
5455
}
5556

5657
declare type ASTNode = ASTElement | ASTText | ASTExpression
5758

5859
declare type ASTElement = {
59-
type: 1,
60-
tag: string,
61-
attrsList: Array<{ name: string, value: string }>,
62-
attrsMap: { [key: string]: string | null },
63-
parent: ASTElement | void,
64-
children: Array<ASTNode>,
65-
66-
static?: boolean,
67-
staticRoot?: boolean,
68-
staticProcessed?: boolean,
69-
70-
text?: string,
71-
attrs?: Array<{ name: string, value: string }>,
72-
props?: Array<{ name: string, value: string }>,
73-
staticAttrs?: Array<{ name: string, value: string }>,
74-
plain?: boolean,
75-
pre?: true,
76-
ns?: string,
77-
78-
component?: string,
79-
keepAlive?: boolean,
80-
inlineTemplate?: true,
81-
transitionMode?: string | null,
82-
slotName?: ?string,
83-
slotTarget?: ?string,
84-
85-
ref?: string,
86-
refInFor?: boolean,
87-
88-
if?: string,
89-
ifProcessed?: boolean,
90-
else?: true,
91-
elseBlock?: ASTElement,
92-
93-
for?: string,
94-
forProcessed?: boolean,
95-
key?: string,
96-
alias?: string,
97-
iterator1?: string,
98-
iterator2?: string,
99-
100-
staticClass?: string,
101-
classBinding?: string,
102-
styleBinding?: string,
103-
hooks?: ASTElementHooks,
104-
events?: ASTElementHandlers,
105-
nativeEvents?: ASTElementHandlers,
106-
107-
transition?: string | true,
108-
transitionOnAppear?: boolean,
109-
110-
directives?: Array<ASTDirective>,
111-
112-
forbidden?: true,
113-
once?: true
60+
type: 1;
61+
tag: string;
62+
attrsList: Array<{ name: string; value: string }>;
63+
attrsMap: { [key: string]: string | null };
64+
parent: ASTElement | void;
65+
children: Array<ASTNode>;
66+
67+
static?: boolean;
68+
staticRoot?: boolean;
69+
staticProcessed?: boolean;
70+
71+
text?: string;
72+
attrs?: Array<{ name: string; value: string }>;
73+
props?: Array<{ name: string; value: string }>;
74+
staticAttrs?: Array<{ name: string; value: string }>;
75+
plain?: boolean;
76+
pre?: true;
77+
ns?: string;
78+
79+
component?: string;
80+
keepAlive?: boolean;
81+
inlineTemplate?: true;
82+
transitionMode?: string | null;
83+
slotName?: ?string;
84+
slotTarget?: ?string;
85+
86+
ref?: string;
87+
refInFor?: boolean;
88+
89+
if?: string;
90+
ifProcessed?: boolean;
91+
else?: true;
92+
elseBlock?: ASTElement;
93+
94+
for?: string;
95+
forProcessed?: boolean;
96+
key?: string;
97+
alias?: string;
98+
iterator1?: string;
99+
iterator2?: string;
100+
101+
staticClass?: string;
102+
classBinding?: string;
103+
styleBinding?: string;
104+
hooks?: ASTElementHooks;
105+
events?: ASTElementHandlers;
106+
nativeEvents?: ASTElementHandlers;
107+
108+
transition?: string | true;
109+
transitionOnAppear?: boolean;
110+
111+
directives?: Array<ASTDirective>;
112+
113+
forbidden?: true;
114+
once?: true;
114115
}
115116

116117
declare type ASTExpression = {
117-
type: 2,
118-
expression: string,
119-
text: string,
120-
static?: boolean
118+
type: 2;
119+
expression: string;
120+
text: string;
121+
static?: boolean;
121122
}
122123

123124
declare type ASTText = {
124-
type: 3,
125-
text: string,
126-
static?: boolean
125+
type: 3;
126+
text: string;
127+
static?: boolean;
127128
}
128129

129130
// SFC-parser related declarations
130131

131132
// an object format describing a single-file component.
132133
declare type SFCDescriptor = {
133-
template: ?SFCBlock,
134-
script: ?SFCBlock,
135-
styles: Array<SFCBlock>
134+
template: ?SFCBlock;
135+
script: ?SFCBlock;
136+
styles: Array<SFCBlock>;
136137
}
137138

138139
declare type SFCBlock = {
139-
type: string,
140-
content: string,
141-
start?: number,
142-
end?: number,
143-
lang?: string,
144-
src?: string,
145-
scoped?: boolean
140+
type: string;
141+
content: string;
142+
start?: number;
143+
end?: number;
144+
lang?: string;
145+
src?: string;
146+
scoped?: boolean;
146147
}

flow/options.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
declare type InternalComponentOptions = {
2-
_isComponent: true,
3-
parent: Component,
4-
propsData: ?Object,
5-
_parentVnode: VNode,
6-
_parentListeners: ?Object,
7-
_renderChildren: ?VNodeChildren,
8-
_componentTag: ?string,
9-
render?: Function,
2+
_isComponent: true;
3+
parent: Component;
4+
propsData: ?Object;
5+
_parentVnode: VNode;
6+
_parentListeners: ?Object;
7+
_renderChildren: ?VNodeChildren;
8+
_componentTag: ?string;
9+
render?: Function;
1010
staticRenderFns?: Array<Function>
1111
}
1212

1313
declare type ComponentOptions = {
1414
// data
15-
data: Object | Function | void,
16-
props?: { [key: string]: PropOptions },
17-
propsData?: ?Object,
15+
data: Object | Function | void;
16+
props?: { [key: string]: PropOptions };
17+
propsData?: ?Object;
1818
computed?: {
1919
[key: string]: Function | {
20-
get?: Function,
21-
set?: Function,
20+
get?: Function;
21+
set?: Function;
2222
cache?: boolean
2323
}
24-
},
24+
};
2525
methods?: {
2626
[key: string]: Function
27-
},
27+
};
2828
watch?: {
2929
[key: string]: Function | string
30-
},
30+
};
3131
// DOM
32-
el?: string | Element,
33-
template?: string,
34-
render: () => VNode,
35-
staticRenderFns?: Array<() => VNode>,
32+
el?: string | Element;
33+
template?: string;
34+
render: () => VNode;
35+
staticRenderFns?: Array<() => VNode>;
3636
// lifecycle
37-
init?: Function,
38-
created?: Function,
39-
beforeMount?: Function,
40-
mounted?: Function,
41-
beforeUpdate?: Function,
42-
updated?: Function,
37+
init?: Function;
38+
created?: Function;
39+
beforeMount?: Function;
40+
mounted?: Function;
41+
beforeUpdate?: Function;
42+
updated?: Function;
4343
// assets
44-
directives?: { [key: string]: Object },
45-
components?: { [key: string]: Class<Component> },
46-
transitions?: { [key: string]: Object },
47-
filters?: { [key: string]: Function },
44+
directives?: { [key: string]: Object };
45+
components?: { [key: string]: Class<Component> };
46+
transitions?: { [key: string]: Object };
47+
filters?: { [key: string]: Function };
4848
// misc
49-
parent?: Component,
50-
mixins?: Array<Object>,
51-
name?: string,
52-
extends?: Class<Component> | Object,
53-
delimiters?: [string, string],
49+
parent?: Component;
50+
mixins?: Array<Object>;
51+
name?: string;
52+
extends?: Class<Component> | Object;
53+
delimiters?: [string, string];
5454

5555
// private
56-
_isComponent?: true,
57-
_propKeys?: Array<string>,
58-
_parentVnode?: VNode,
59-
_parentListeners?: ?Object,
56+
_isComponent?: true;
57+
_propKeys?: Array<string>;
58+
_parentVnode?: VNode;
59+
_parentListeners?: ?Object;
6060
_renderChildren?: ?VNodeChildren
6161
}
6262

6363
declare type PropOptions = {
64-
type: Function | Array<Function> | null,
65-
default: any,
66-
required: ?boolean,
67-
validator: ?Function
64+
type: Function | Array<Function> | null;
65+
default: any;
66+
required: ?boolean;
67+
validator: ?Function;
6868
}

0 commit comments

Comments
 (0)