@@ -873,28 +873,26 @@ module Harness {
873873 }
874874
875875 function findResultCodeFile ( fileName : string ) {
876- var dTsFileName = ts . forEach ( result . program . getSourceFiles ( ) , sourceFile => {
877- if ( sourceFile . filename === fileName ) {
878- // Is this file going to be emitted separately
879- var sourceFileName : string ;
880- if ( ts . isExternalModule ( sourceFile ) || ! options . out ) {
881- if ( options . outDir ) {
882- var sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . filename , result . currentDirectoryForProgram ) ;
883- sourceFilePath = sourceFilePath . replace ( result . program . getCommonSourceDirectory ( ) , "" ) ;
884- sourceFileName = ts . combinePaths ( options . outDir , sourceFilePath ) ;
885- }
886- else {
887- sourceFileName = sourceFile . filename ;
888- }
889- }
890- else {
891- // Goes to single --out file
892- sourceFileName = options . out ;
893- }
894-
895- return ts . removeFileExtension ( sourceFileName ) + ".d.ts" ;
876+ var sourceFile = result . program . getSourceFile ( fileName ) ;
877+ assert ( sourceFile , "Program has no source file with name '" + fileName + "'" ) ;
878+ // Is this file going to be emitted separately
879+ var sourceFileName : string ;
880+ if ( ts . isExternalModule ( sourceFile ) || ! options . out ) {
881+ if ( options . outDir ) {
882+ var sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . filename , result . currentDirectoryForProgram ) ;
883+ sourceFilePath = sourceFilePath . replace ( result . program . getCommonSourceDirectory ( ) , "" ) ;
884+ sourceFileName = ts . combinePaths ( options . outDir , sourceFilePath ) ;
885+ }
886+ else {
887+ sourceFileName = sourceFile . filename ;
896888 }
897- } ) ;
889+ }
890+ else {
891+ // Goes to single --out file
892+ sourceFileName = options . out ;
893+ }
894+
895+ var dTsFileName = ts . removeFileExtension ( sourceFileName ) + ".d.ts" ;
898896
899897 return ts . forEach ( result . declFilesCode , declFile => declFile . fileName === dTsFileName ? declFile : undefined ) ;
900898 }
0 commit comments