@@ -58,6 +58,21 @@ function ts_blank_space(context: Context<any, { ms: MagicString }>, node: any):
5858 }
5959}
6060
61+ function specifier_end ( node : any , i : number , s : any , context : Context < any , { ms : MagicString } > ) {
62+ let end = node . specifiers [ i + 1 ] ?. start ;
63+ if ( end === undefined ) {
64+ end = s . end ;
65+ // Look for a comma after s.end, skipping whitespace
66+ let j = end ;
67+ const original = context . state . ms . original ;
68+ while ( j < original . length && / \s / . test ( original [ j ] ) ) j ++ ;
69+ if ( original [ j ] === ',' ) {
70+ end = j + 1 ;
71+ }
72+ }
73+ return end ;
74+ }
75+
6176const visitors : Visitors < any , { ms : MagicString } > = {
6277 _ ( node , context ) {
6378 if ( node . typeAnnotation ) ts_blank_space ( context , node . typeAnnotation ) ;
@@ -85,7 +100,7 @@ const visitors: Visitors<any, { ms: MagicString }> = {
85100
86101 ts_blank_space ( context , {
87102 start : s . start ,
88- end : node . specifiers [ i + 1 ] ?. start || s . end
103+ end : specifier_end ( node , i , s , context )
89104 } ) ;
90105 } ) ;
91106
@@ -115,7 +130,7 @@ const visitors: Visitors<any, { ms: MagicString }> = {
115130
116131 ts_blank_space ( context , {
117132 start : s . start ,
118- end : node . specifiers [ i + 1 ] ?. start || s . end
133+ end : specifier_end ( node , i , s , context )
119134 } ) ;
120135 } ) ;
121136
0 commit comments