@@ -144,6 +144,12 @@ test.each([
144144 source : 'type Value = (((string | number)));' ,
145145 expected : 'type Value = string | number;\n' ,
146146 } ,
147+ {
148+ name : 'single-member unions with comments' ,
149+ parser : 'swc-next-ts' as const ,
150+ source : 'type Value = | // value\nstring;' ,
151+ expected : 'type Value =\n // value\n string;\n' ,
152+ } ,
147153 {
148154 name : 'TypeScript template expressions' ,
149155 parser : 'swc-next-ts' as const ,
@@ -167,6 +173,20 @@ test.each([
167173 ) . resolves . toBe ( fixture . expected ) ;
168174} ) ;
169175
176+ test . each ( [ 'swc-next' , 'swc-next-ts' ] as const ) (
177+ 'normalizes nested template expressions with %s' ,
178+ async ( parser ) => {
179+ const source =
180+ 'const result=`outer ${(`inner ${(a || (b || c))}`)} ${/** @type {Foo} */ (value)}`' ;
181+ const formatted = await formatWithSwcNext ( source , { parser } ) ;
182+
183+ expect ( formatted ) . toBe (
184+ 'const result = `outer ${`inner ${a || b || c}`} ${/** @type {Foo} */ (value)}`;\n' ,
185+ ) ;
186+ expect ( await formatWithSwcNext ( formatted , { parser } ) ) . toBe ( formatted ) ;
187+ } ,
188+ ) ;
189+
170190test ( 'reuses Prettier options and pragma handling' , async ( ) => {
171191 await expect (
172192 formatWithSwcNext ( '/** @format */\nconst value={answer:"yes"}' , {
@@ -355,15 +375,6 @@ test('reports SWC Next diagnostics with Prettier locations', async () => {
355375 } ) ;
356376} ) ;
357377
358- test . each ( [ 'swc-next' , 'swc-next-ts' ] as const ) (
359- 'rejects malformed template literals with %s diagnostics' ,
360- async ( parser ) => {
361- await expect (
362- formatWithSwcNext ( 'const value = `value: ${}`' , { parser } ) ,
363- ) . rejects . toBeInstanceOf ( SyntaxError ) ;
364- } ,
365- ) ;
366-
367378test . each ( [ 'js' , 'jsx' , 'ts' , 'tsx' ] ) (
368379 'uses SWC Next by default for .%s files' ,
369380 async ( extension ) => {
0 commit comments