@@ -58,6 +58,21 @@ function ts_blank_space(context: Context<any, { ms: MagicString }>, node: any):
58
58
}
59
59
}
60
60
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
+
61
76
const visitors : Visitors < any , { ms : MagicString } > = {
62
77
_ ( node , context ) {
63
78
if ( node . typeAnnotation ) ts_blank_space ( context , node . typeAnnotation ) ;
@@ -85,7 +100,7 @@ const visitors: Visitors<any, { ms: MagicString }> = {
85
100
86
101
ts_blank_space ( context , {
87
102
start : s . start ,
88
- end : node . specifiers [ i + 1 ] ?. start || s . end
103
+ end : specifier_end ( node , i , s , context )
89
104
} ) ;
90
105
} ) ;
91
106
@@ -115,7 +130,7 @@ const visitors: Visitors<any, { ms: MagicString }> = {
115
130
116
131
ts_blank_space ( context , {
117
132
start : s . start ,
118
- end : node . specifiers [ i + 1 ] ?. start || s . end
133
+ end : specifier_end ( node , i , s , context )
119
134
} ) ;
120
135
} ) ;
121
136
0 commit comments