@@ -25,7 +25,7 @@ import TemplateScope from './nodes/shared/TemplateScope';
2525import fuzzymatch from '../utils/fuzzymatch' ;
2626import get_object from './utils/get_object' ;
2727import Slot from './nodes/Slot' ;
28- import { Node , ImportDeclaration , ExportNamedDeclaration , Identifier , ExpressionStatement , AssignmentExpression , Literal , Property , RestElement , ExportDefaultDeclaration , ExportAllDeclaration , FunctionDeclaration , FunctionExpression } from 'estree' ;
28+ import { Node , ImportDeclaration , ExportNamedDeclaration , Identifier , ExpressionStatement , AssignmentExpression , Literal , Property , RestElement , ExportDefaultDeclaration , ExportAllDeclaration , FunctionDeclaration , FunctionExpression , Pattern , Expression } from 'estree' ;
2929import add_to_set from './utils/add_to_set' ;
3030import check_graph_for_cycles from './utils/check_graph_for_cycles' ;
3131import { print , b } from 'code-red' ;
@@ -1034,7 +1034,7 @@ export default class Component {
10341034 const inserts = [ ] ;
10351035 const props = [ ] ;
10361036
1037- function add_new_props ( exported , local , default_value ) {
1037+ function add_new_props ( exported : Identifier , local : Pattern , default_value : Expression ) {
10381038 props . push ( {
10391039 type : 'Property' ,
10401040 method : false ,
@@ -1064,7 +1064,7 @@ export default class Component {
10641064 for ( let index = 0 ; index < node . declarations . length ; index ++ ) {
10651065 const declarator = node . declarations [ index ] ;
10661066 if ( declarator . id . type !== 'Identifier' ) {
1067- function get_new_name ( local ) {
1067+ function get_new_name ( local : Identifier ) : Identifier {
10681068 const variable = component . var_lookup . get ( local . name ) ;
10691069 if ( variable . subscribable ) {
10701070 inserts . push ( get_insert ( variable ) ) ;
@@ -1078,7 +1078,7 @@ export default class Component {
10781078 return local ;
10791079 }
10801080
1081- function rename_identifiers ( param : Node ) {
1081+ function rename_identifiers ( param : Pattern ) {
10821082 switch ( param . type ) {
10831083 case 'ObjectPattern' : {
10841084 const handle_prop = ( prop : Property | RestElement ) => {
@@ -1087,15 +1087,15 @@ export default class Component {
10871087 } else if ( prop . value . type === 'Identifier' ) {
10881088 prop . value = get_new_name ( prop . value ) ;
10891089 } else {
1090- rename_identifiers ( prop . value ) ;
1090+ rename_identifiers ( prop . value as Pattern ) ;
10911091 }
10921092 } ;
10931093
10941094 param . properties . forEach ( handle_prop ) ;
10951095 break ;
10961096 }
10971097 case 'ArrayPattern' : {
1098- const handle_element = ( element : Node , index : number , array : Node [ ] ) => {
1098+ const handle_element = ( element : Pattern | null , index : number , array : Array < Pattern | null > ) => {
10991099 if ( element ) {
11001100 if ( element . type === 'Identifier' ) {
11011101 array [ index ] = get_new_name ( element ) ;
@@ -1110,7 +1110,11 @@ export default class Component {
11101110 }
11111111
11121112 case 'RestElement' :
1113- param . argument = get_new_name ( param . argument ) ;
1113+ if ( param . argument . type === 'Identifier' ) {
1114+ param . argument = get_new_name ( param . argument ) ;
1115+ } else {
1116+ rename_identifiers ( param . argument ) ;
1117+ }
11141118 break ;
11151119
11161120 case 'AssignmentPattern' :
0 commit comments