@@ -728,11 +728,38 @@ describe('ts-node', function () {
728
728
it ( 'should create generic compiler instances' , ( ) => {
729
729
const service = create ( { compilerOptions : { target : 'es5' } , skipProject : true } )
730
730
const output = service . compile ( 'const x = 10' , 'test.ts' )
731
-
732
731
expect ( output ) . to . contain ( 'var x = 10;' )
733
732
} )
734
733
} )
735
734
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
+
736
763
describe ( 'esm' , ( ) => {
737
764
this . slow ( 1000 )
738
765
0 commit comments