@@ -268,7 +268,7 @@ function genInlineTemplate (el: ASTElement): ?string {
268
268
}
269
269
}
270
270
271
- function genScopedSlots ( slots ) {
271
+ function genScopedSlots ( slots : { [ key : string ] : ASTElement } ) : string {
272
272
return `scopedSlots:{${
273
273
Object . keys ( slots ) . map ( key => genScopedSlot ( key , slots [ key ] ) ) . join ( ',' )
274
274
} }`
@@ -306,32 +306,35 @@ function genChildren (el: ASTElement, checkSkip?: boolean): string | void {
306
306
// 0: no normalization needed
307
307
// 1: simple normalization needed (possible 1-level deep nested array)
308
308
// 2: full normalization needed
309
- function getNormalizationType ( children ) : number {
309
+ function getNormalizationType ( children : Array < ASTNode > ) : number {
310
310
let res = 0
311
311
for ( let i = 0 ; i < children . length ; i ++ ) {
312
- const el : any = children [ i ]
312
+ const el : ASTNode = children [ i ]
313
+ if ( el . type !== 1 ) {
314
+ continue
315
+ }
313
316
if ( needsNormalization ( el ) ||
314
- ( el . if && el . ifConditions . some ( c => needsNormalization ( c . block ) ) ) ) {
317
+ ( el . ifConditions && el . ifConditions . some ( c => needsNormalization ( c . block ) ) ) ) {
315
318
res = 2
316
319
break
317
320
}
318
321
if ( maybeComponent ( el ) ||
319
- ( el . if && el . ifConditions . some ( c => maybeComponent ( c . block ) ) ) ) {
322
+ ( el . ifConditions && el . ifConditions . some ( c => maybeComponent ( c . block ) ) ) ) {
320
323
res = 1
321
324
}
322
325
}
323
326
return res
324
327
}
325
328
326
- function needsNormalization ( el : ASTElement ) {
327
- return el . for || el . tag === 'template' || el . tag === 'slot'
329
+ function needsNormalization ( el : ASTElement ) : boolean {
330
+ return el . for !== undefined || el . tag === 'template' || el . tag === 'slot'
328
331
}
329
332
330
- function maybeComponent ( el : ASTElement ) {
331
- return el . type === 1 && ! isPlatformReservedTag ( el . tag )
333
+ function maybeComponent ( el : ASTElement ) : boolean {
334
+ return ! isPlatformReservedTag ( el . tag )
332
335
}
333
336
334
- function genNode ( node : ASTNode ) {
337
+ function genNode ( node : ASTNode ) : string {
335
338
if ( node . type === 1 ) {
336
339
return genElement ( node )
337
340
} else {
@@ -365,7 +368,7 @@ function genSlot (el: ASTElement): string {
365
368
}
366
369
367
370
// componentName is el.component, take it as argument to shun flow's pessimistic refinement
368
- function genComponent ( componentName , el ) : string {
371
+ function genComponent (componentName: string , el: ASTElement ): string {
369
372
const children = el.inlineTemplate ? null : genChildren(el, true)
370
373
return ` _c ( $ { componentName} , $ { genData ( el ) } ${
371
374
children ? `,${ children } ` : ''
0 commit comments