@@ -353,3 +353,36 @@ test('execute a TypeScript test mocking module', { skip: isWindows && process.ar
353353 match ( result . stdout , / H e l l o , T y p e S c r i p t - C o m m o n J S ! / ) ;
354354 strictEqual ( result . code , 0 ) ;
355355} ) ;
356+
357+ test ( 'execute a TypeScript file with union types' , async ( ) => {
358+ const result = await spawnPromisified ( process . execPath , [
359+ '--experimental-strip-types' ,
360+ '--no-warnings' ,
361+ fixtures . path ( 'typescript/ts/test-union-types.ts' ) ,
362+ ] ) ;
363+
364+ strictEqual ( result . stderr , '' ) ;
365+ strictEqual ( result . stdout ,
366+ '{' +
367+ " name: 'Hello, TypeScript!' }\n" +
368+ '{ role: \'admin\', permission: \'all\' }\n' +
369+ '{\n foo: \'Testing Partial Type\',\n bar: 42,\n' +
370+ ' zoo: true,\n metadata: undefined\n' +
371+ '}\n' ) ;
372+ strictEqual ( result . code , 0 ) ;
373+ } ) ;
374+
375+ test ( 'expect error when executing a TypeScript file with generics' , async ( ) => {
376+ const result = await spawnPromisified ( process . execPath , [
377+ '--experimental-strip-types' ,
378+ fixtures . path ( 'typescript/ts/test-parameter-properties.ts' ) ,
379+ ] ) ;
380+
381+ // This error should be thrown during transformation
382+ match (
383+ result . stderr ,
384+ / T y p e S c r i p t p a r a m e t e r p r o p e r t y i s n o t s u p p o r t e d i n s t r i p - o n l y m o d e /
385+ ) ;
386+ strictEqual ( result . stdout , '' ) ;
387+ strictEqual ( result . code , 1 ) ;
388+ } ) ;
0 commit comments