@@ -1116,34 +1116,53 @@ namespace ts.tscWatch {
1116
1116
assert . equal ( nowErrors [ 1 ] . start , intialErrors [ 1 ] . start ! - configFileContentComment . length ) ;
1117
1117
} ) ;
1118
1118
1119
- it ( "should not trigger recompilation because of program emit" , ( ) => {
1120
- const proj = "/user/username/projects/myproject" ;
1121
- const file1 : File = {
1122
- path : `${ proj } /file1.ts` ,
1123
- content : "export const c = 30;"
1124
- } ;
1125
- const file2 : File = {
1126
- path : `${ proj } /src/file2.ts` ,
1127
- content : `import {c} from "file1"; export const d = 30;`
1128
- } ;
1129
- const tsconfig : File = {
1130
- path : `${ proj } /tsconfig.json` ,
1131
- content : JSON . stringify ( {
1132
- compilerOptions : {
1133
- module : "amd" ,
1134
- outDir : "build"
1135
- }
1136
- } )
1137
- } ;
1138
- const host = createWatchedSystem ( [ file1 , file2 , libFile , tsconfig ] , { currentDirectory : proj } ) ;
1139
- const watch = createWatchOfConfigFile ( tsconfig . path , host , /*maxNumberOfFilesToIterateForInvalidation*/ 1 ) ;
1140
- checkProgramActualFiles ( watch ( ) , [ file1 . path , file2 . path , libFile . path ] ) ;
1119
+ describe ( "should not trigger should not trigger recompilation because of program emit" , ( ) => {
1120
+ function verifyWithOptions ( options : CompilerOptions , outputFiles : ReadonlyArray < string > ) {
1121
+ const proj = "/user/username/projects/myproject" ;
1122
+ const file1 : File = {
1123
+ path : `${ proj } /file1.ts` ,
1124
+ content : "export const c = 30;"
1125
+ } ;
1126
+ const file2 : File = {
1127
+ path : `${ proj } /src/file2.ts` ,
1128
+ content : `import {c} from "file1"; export const d = 30;`
1129
+ } ;
1130
+ const tsconfig : File = {
1131
+ path : `${ proj } /tsconfig.json` ,
1132
+ content : generateTSConfig ( options , emptyArray , "\n" )
1133
+ } ;
1134
+ const host = createWatchedSystem ( [ file1 , file2 , libFile , tsconfig ] , { currentDirectory : proj } ) ;
1135
+ const watch = createWatchOfConfigFile ( tsconfig . path , host , /*maxNumberOfFilesToIterateForInvalidation*/ 1 ) ;
1136
+ checkProgramActualFiles ( watch ( ) , [ file1 . path , file2 . path , libFile . path ] ) ;
1141
1137
1142
- assert . isTrue ( host . fileExists ( "build/file1.js" ) ) ;
1143
- assert . isTrue ( host . fileExists ( "build/src/file2.js" ) ) ;
1138
+ outputFiles . forEach ( f => host . fileExists ( f ) ) ;
1139
+
1140
+ // This should be 0
1141
+ host . checkTimeoutQueueLengthAndRun ( 0 ) ;
1142
+ }
1144
1143
1145
- // This should be 0
1146
- host . checkTimeoutQueueLengthAndRun ( 0 ) ;
1144
+ it ( "without outDir or outFile is specified" , ( ) => {
1145
+ debugger ;
1146
+ verifyWithOptions ( { module : ModuleKind . AMD } , [ "file1.js" , "src/file2.js" ] ) ;
1147
+ } ) ;
1148
+
1149
+ it ( "with outFile" , ( ) => {
1150
+ verifyWithOptions ( { module : ModuleKind . AMD , outFile : "build/outFile.js" } , [ "build/outFile.js" ] ) ;
1151
+ } ) ;
1152
+
1153
+ it ( "when outDir is specified" , ( ) => {
1154
+ verifyWithOptions ( { module : ModuleKind . AMD , outDir : "build" } , [ "build/file1.js" , "build/src/file2.js" ] ) ;
1155
+ } ) ;
1156
+
1157
+ it ( "when outDir and declarationDir is specified" , ( ) => {
1158
+ verifyWithOptions ( { module : ModuleKind . AMD , outDir : "build" , declaration : true , declarationDir : "decls" } ,
1159
+ [ "build/file1.js" , "build/src/file2.js" , "decls/file1.d.ts" , "decls/src/file2.d.ts" ] ) ;
1160
+ } ) ;
1161
+
1162
+ it ( "declarationDir is specified" , ( ) => {
1163
+ verifyWithOptions ( { module : ModuleKind . AMD , declaration : true , declarationDir : "decls" } ,
1164
+ [ "file1.js" , "src/file2.js" , "decls/file1.d.ts" , "decls/src/file2.d.ts" ] ) ;
1165
+ } ) ;
1147
1166
} ) ;
1148
1167
1149
1168
it ( "shouldnt report error about unused function incorrectly when file changes from global to module" , ( ) => {
0 commit comments