@@ -1127,29 +1127,27 @@ module Harness {
11271127 }
11281128
11291129 function findResultCodeFile ( fileName : string ) {
1130- var dTsFileName = ts . forEach ( result . program . getSourceFiles ( ) , sourceFile => {
1131- if ( sourceFile . filename === fileName ) {
1132- // Is this file going to be emitted separately
1133- var sourceFileName : string ;
1134- if ( ts . isExternalModule ( sourceFile ) || ! options . out ) {
1135- if ( options . outDir ) {
1136- var sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . filename , result . currentDirectoryForProgram ) ;
1137- sourceFilePath = sourceFilePath . replace ( result . program . getCommonSourceDirectory ( ) , "" ) ;
1138- sourceFileName = ts . combinePaths ( options . outDir , sourceFilePath ) ;
1139- }
1140- else {
1141- sourceFileName = sourceFile . filename ;
1142- }
1143- }
1144- else {
1145- // Goes to single --out file
1146- sourceFileName = options . out ;
1147- }
1148-
1149- return ts . removeFileExtension ( sourceFileName ) + ".d.ts" ;
1130+ var sourceFile = result . program . getSourceFile ( fileName ) ;
1131+ assert ( sourceFile , "Program has no source file with name '" + fileName + "'" ) ;
1132+ // Is this file going to be emitted separately
1133+ var sourceFileName : string ;
1134+ if ( ts . isExternalModule ( sourceFile ) || ! options . out ) {
1135+ if ( options . outDir ) {
1136+ var sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . filename , result . currentDirectoryForProgram ) ;
1137+ sourceFilePath = sourceFilePath . replace ( result . program . getCommonSourceDirectory ( ) , "" ) ;
1138+ sourceFileName = ts . combinePaths ( options . outDir , sourceFilePath ) ;
11501139 }
1151- } ) ;
1140+ else {
1141+ sourceFileName = sourceFile . filename ;
1142+ }
1143+ }
1144+ else {
1145+ // Goes to single --out file
1146+ sourceFileName = options . out ;
1147+ }
11521148
1149+ var dTsFileName = ts . removeFileExtension ( sourceFileName ) + ".d.ts" ;
1150+
11531151 return ts . forEach ( result . declFilesCode , declFile => declFile . fileName === dTsFileName ? declFile : undefined ) ;
11541152 }
11551153
0 commit comments