@@ -728,11 +728,38 @@ describe('ts-node', function () {
728728 it ( 'should create generic compiler instances' , ( ) => {
729729 const service = create ( { compilerOptions : { target : 'es5' } , skipProject : true } )
730730 const output = service . compile ( 'const x = 10' , 'test.ts' )
731-
732731 expect ( output ) . to . contain ( 'var x = 10;' )
733732 } )
734733 } )
735734
735+ describe ( 'issue #1098' , ( ) => {
736+ function testIgnored ( ignored : tsNodeTypes . Register [ 'ignored' ] , allowed : string [ ] , disallowed : string [ ] ) {
737+ for ( const ext of allowed ) {
738+ expect ( ignored ( join ( __dirname , `index${ ext } ` ) ) ) . equal ( false , `should accept ${ ext } files` )
739+ }
740+ for ( const ext of disallowed ) {
741+ expect ( ignored ( join ( __dirname , `index${ ext } ` ) ) ) . equal ( true , `should ignore ${ ext } files` )
742+ }
743+ }
744+
745+ it ( 'correctly filters file extensions from the compiler when allowJs=false and jsx=false' , ( ) => {
746+ const { ignored } = create ( { compilerOptions : { } , skipProject : true } )
747+ testIgnored ( ignored , [ '.ts' ] , [ '.js' , '.tsx' , '.jsx' , '.mjs' , '.cjs' , '.xyz' , '' ] )
748+ } )
749+ it ( 'correctly filters file extensions from the compiler when allowJs=true and jsx=false' , ( ) => {
750+ const { ignored } = create ( { compilerOptions : { allowJs : true } , skipProject : true } )
751+ testIgnored ( ignored , [ '.ts' , '.js' ] , [ '.tsx' , '.jsx' , '.mjs' , '.cjs' , '.xyz' , '' ] )
752+ } )
753+ it ( 'correctly filters file extensions from the compiler when allowJs=false and jsx=true' , ( ) => {
754+ const { ignored } = create ( { compilerOptions : { allowJs : false , jsx : 'preserve' } , skipProject : true } )
755+ testIgnored ( ignored , [ '.ts' , '.tsx' ] , [ '.js' , '.jsx' , '.mjs' , '.cjs' , '.xyz' , '' ] )
756+ } )
757+ it ( 'correctly filters file extensions from the compiler when allowJs=true and jsx=true' , ( ) => {
758+ const { ignored } = create ( { compilerOptions : { allowJs : true , jsx : 'preserve' } , skipProject : true } )
759+ testIgnored ( ignored , [ '.ts' , '.tsx' , '.js' , '.jsx' ] , [ '.mjs' , '.cjs' , '.xyz' , '' ] )
760+ } )
761+ } )
762+
736763 describe ( 'esm' , ( ) => {
737764 this . slow ( 1000 )
738765
0 commit comments