@@ -564,16 +564,29 @@ export default class Compiler {
564
564
if ( templateProperties . computed ) {
565
565
const dependencies = new Map ( ) ;
566
566
567
+ const fullStateComputations = [ ] ;
568
+
567
569
templateProperties . computed . value . properties . forEach ( ( prop : Node ) => {
568
570
const key = getName ( prop . key ) ;
569
571
const value = prop . value ;
570
572
571
- const deps = value . params [ 0 ] . properties . map ( prop => prop . key . name ) ;
572
-
573
- deps . forEach ( dep => {
574
- this . expectedProperties . add ( dep ) ;
573
+ addDeclaration ( key , value , false , 'computed' , {
574
+ state : true ,
575
+ changed : true
575
576
} ) ;
576
- dependencies . set ( key , deps ) ;
577
+
578
+ const param = value . params [ 0 ] ;
579
+
580
+ if ( param . type === 'ObjectPattern' ) {
581
+ const deps = param . properties . map ( prop => prop . key . name ) ;
582
+
583
+ deps . forEach ( dep => {
584
+ this . expectedProperties . add ( dep ) ;
585
+ } ) ;
586
+ dependencies . set ( key , deps ) ;
587
+ } else {
588
+ fullStateComputations . push ( { key, deps : null } )
589
+ }
577
590
} ) ;
578
591
579
592
const visited = new Set ( ) ;
@@ -590,16 +603,15 @@ export default class Compiler {
590
603
computations . push ( { key, deps } ) ;
591
604
592
605
const prop = templateProperties . computed . value . properties . find ( ( prop : Node ) => getName ( prop . key ) === key ) ;
593
-
594
- addDeclaration ( key , prop . value , false , 'computed' , {
595
- state : true ,
596
- changed : true
597
- } ) ;
598
606
} ;
599
607
600
608
templateProperties . computed . value . properties . forEach ( ( prop : Node ) =>
601
609
visit ( getName ( prop . key ) )
602
610
) ;
611
+
612
+ if ( fullStateComputations . length > 0 ) {
613
+ computations . push ( ...fullStateComputations ) ;
614
+ }
603
615
}
604
616
605
617
if ( templateProperties . data ) {
0 commit comments