@@ -268,7 +268,7 @@ function genInlineTemplate (el: ASTElement): ?string {
268268 }
269269}
270270
271- function genScopedSlots ( slots ) {
271+ function genScopedSlots ( slots : { [ key : string ] : ASTElement } ) : string {
272272 return `scopedSlots:{${
273273 Object . keys ( slots ) . map ( key => genScopedSlot ( key , slots [ key ] ) ) . join ( ',' )
274274 } }`
@@ -306,32 +306,35 @@ function genChildren (el: ASTElement, checkSkip?: boolean): string | void {
306306// 0: no normalization needed
307307// 1: simple normalization needed (possible 1-level deep nested array)
308308// 2: full normalization needed
309- function getNormalizationType ( children ) : number {
309+ function getNormalizationType ( children : Array < ASTNode > ) : number {
310310 let res = 0
311311 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+ }
313316 if ( needsNormalization ( el ) ||
314- ( el . if && el . ifConditions . some ( c => needsNormalization ( c . block ) ) ) ) {
317+ ( el . ifConditions && el . ifConditions . some ( c => needsNormalization ( c . block ) ) ) ) {
315318 res = 2
316319 break
317320 }
318321 if ( maybeComponent ( el ) ||
319- ( el . if && el . ifConditions . some ( c => maybeComponent ( c . block ) ) ) ) {
322+ ( el . ifConditions && el . ifConditions . some ( c => maybeComponent ( c . block ) ) ) ) {
320323 res = 1
321324 }
322325 }
323326 return res
324327}
325328
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'
328331}
329332
330- function maybeComponent ( el : ASTElement ) {
331- return el . type === 1 && ! isPlatformReservedTag ( el . tag )
333+ function maybeComponent ( el : ASTElement ) : boolean {
334+ return ! isPlatformReservedTag ( el . tag )
332335}
333336
334- function genNode ( node : ASTNode ) {
337+ function genNode ( node : ASTNode ) : string {
335338 if ( node . type === 1 ) {
336339 return genElement ( node )
337340 } else {
@@ -365,7 +368,7 @@ function genSlot (el: ASTElement): string {
365368}
366369
367370// 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 {
369372 const children = el.inlineTemplate ? null : genChildren(el, true)
370373 return ` _c ( $ { componentName} , $ { genData ( el ) } ${
371374 children ? `,${ children } ` : ''
0 commit comments