@@ -1266,17 +1266,15 @@ const a = {
1266
1266
) ,
1267
1267
changes : [
1268
1268
sys => {
1269
- const content = sys . readFile ( `${ projectsLocation } /reexport/src/pure/session.ts` ) ! ;
1270
- sys . writeFile ( `${ projectsLocation } /reexport/src/pure/session.ts` , content . replace ( "// " , "" ) ) ;
1269
+ replaceFileText ( sys , `${ projectsLocation } /reexport/src/pure/session.ts` , "// " , "" ) ;
1271
1270
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src/pure
1272
1271
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src/main
1273
1272
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src
1274
1273
sys . checkTimeoutQueueLength ( 0 ) ;
1275
1274
return "Introduce error" ;
1276
1275
} ,
1277
1276
sys => {
1278
- const content = sys . readFile ( `${ projectsLocation } /reexport/src/pure/session.ts` ) ! ;
1279
- sys . writeFile ( `${ projectsLocation } /reexport/src/pure/session.ts` , content . replace ( "bar: " , "// bar: " ) ) ;
1277
+ replaceFileText ( sys , `${ projectsLocation } /reexport/src/pure/session.ts` , "bar: " , "// bar: " ) ;
1280
1278
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src/pure
1281
1279
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src/main
1282
1280
sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build src
@@ -1286,4 +1284,63 @@ const a = {
1286
1284
]
1287
1285
} ) ;
1288
1286
} ) ;
1287
+
1288
+ describe ( "unittests:: tsbuild:: watchMode:: configFileErrors:: reports syntax errors in config file" , ( ) => {
1289
+ verifyTscWatch ( {
1290
+ scenario : "configFileErrors" ,
1291
+ subScenario : "reports syntax errors in config file" ,
1292
+ sys : ( ) => createWatchedSystem (
1293
+ [
1294
+ { path : `${ projectRoot } /a.ts` , content : "export function foo() { }" } ,
1295
+ { path : `${ projectRoot } /b.ts` , content : "export function bar() { }" } ,
1296
+ {
1297
+ path : `${ projectRoot } /tsconfig.json` ,
1298
+ content : Utils . dedent `
1299
+ {
1300
+ "compilerOptions": {
1301
+ "composite": true,
1302
+ },
1303
+ "files": [
1304
+ "a.ts"
1305
+ "b.ts"
1306
+ ]
1307
+ }`
1308
+ } ,
1309
+ libFile
1310
+ ] ,
1311
+ { currentDirectory : projectRoot }
1312
+ ) ,
1313
+ commandLineArgs : [ "--b" , "-w" ] ,
1314
+ changes : [
1315
+ sys => {
1316
+ replaceFileText ( sys , `${ projectRoot } /tsconfig.json` , "," , `,
1317
+ "declaration": true,` ) ;
1318
+ sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build the project
1319
+ sys . checkTimeoutQueueLength ( 0 ) ;
1320
+ return "reports syntax errors after change to config file" ;
1321
+ } ,
1322
+ sys => {
1323
+ replaceFileText ( sys , `${ projectRoot } /a.ts` , "foo" , "fooBar" ) ;
1324
+ sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build the project
1325
+ sys . checkTimeoutQueueLength ( 0 ) ;
1326
+ return "reports syntax errors after change to ts file" ;
1327
+ } ,
1328
+ sys => {
1329
+ replaceFileText ( sys , `${ projectRoot } /tsconfig.json` , "" , "" ) ;
1330
+ sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build the project
1331
+ sys . checkTimeoutQueueLength ( 0 ) ;
1332
+ return "reports error when there is no change to tsconfig file" ;
1333
+ } ,
1334
+ sys => {
1335
+ sys . writeFile ( `${ projectRoot } /tsconfig.json` , JSON . stringify ( {
1336
+ compilerOptions : { composite : true , declaration : true } ,
1337
+ files : [ "a.ts" , "b.ts" ]
1338
+ } ) ) ;
1339
+ sys . checkTimeoutQueueLengthAndRun ( 1 ) ; // build the project
1340
+ sys . checkTimeoutQueueLength ( 0 ) ;
1341
+ return "builds after fixing config file errors" ;
1342
+ }
1343
+ ]
1344
+ } ) ;
1345
+ } ) ;
1289
1346
}
0 commit comments