@@ -205,6 +205,16 @@ describe('dependencyTree', function() {
205205 assert ( tree . length === 3 ) ;
206206 } ) ;
207207
208+ it ( 'resolves TypeScript imports to their type definition files by default' , function ( ) {
209+ const directory = path . join ( __dirname , 'example' , 'noTypeDefinitions' ) ;
210+ const filename = path . join ( directory , 'entrypoint.ts' ) ;
211+
212+ const list = dependencyTree . toList ( { filename, directory} ) ;
213+
214+ assert ( list . includes ( path . join ( directory , 'required.d.ts' ) ) ) ;
215+ assert ( ! list . includes ( path . join ( directory , 'required.js' ) ) ) ;
216+ } ) ;
217+
208218 describe ( 'when given a detective configuration' , function ( ) {
209219 it ( 'passes it through to precinct' , function ( ) {
210220 const spy = sinon . spy ( precinct , 'paperwork' ) ;
@@ -903,6 +913,32 @@ describe('dependencyTree', function() {
903913 } ) ;
904914 } ) ;
905915
916+ describe ( 'when noTypeDefinitions is set' , function ( ) {
917+ describe ( 'and it is set to false' , function ( ) {
918+ it ( 'resolves TypeScript imports to their definition files' , function ( ) {
919+ const directory = path . join ( __dirname , 'example' , 'noTypeDefinitions' ) ;
920+ const filename = path . join ( directory , 'entrypoint.ts' ) ;
921+
922+ const list = dependencyTree . toList ( { filename, directory, noTypeDefinitions : false } ) ;
923+
924+ assert ( list . includes ( path . join ( directory , 'required.d.ts' ) ) ) ;
925+ assert ( ! list . includes ( path . join ( directory , 'required.js' ) ) ) ;
926+ } ) ;
927+ } ) ;
928+
929+ describe ( 'and it is set to true' , function ( ) {
930+ it ( 'resolves TypeScript imports to their JavaScript implementation files' , function ( ) {
931+ const directory = path . join ( __dirname , 'example' , 'noTypeDefinitions' ) ;
932+ const filename = path . join ( directory , 'entrypoint.ts' ) ;
933+
934+ const list = dependencyTree . toList ( { filename, directory, noTypeDefinitions : true } ) ;
935+
936+ assert ( list . includes ( path . join ( directory , 'required.js' ) ) ) ;
937+ assert ( ! list . includes ( path . join ( directory , 'required.d.ts' ) ) ) ;
938+ } ) ;
939+ } ) ;
940+ } ) ;
941+
906942 describe ( 'Config' , function ( ) {
907943 describe ( 'when given a path to a typescript config' , function ( ) {
908944 it ( 'pre-parses the config for performance' , function ( ) {
0 commit comments