@@ -175,6 +175,99 @@ func TestBuildClean(t *testing.T) {
175175 }
176176}
177177
178+ func TestBuildConfigFileErrors (t * testing.T ) {
179+ t .Parallel ()
180+ testCases := []* tscInput {
181+ {
182+ subScenario : "when tsconfig extends the missing file" ,
183+ files : FileMap {
184+ "/home/src/workspaces/project/tsconfig.first.json" : stringtestutil .Dedent (`
185+ {
186+ "extends": "./foobar.json",
187+ "compilerOptions": {
188+ "composite": true
189+ }
190+ }` ),
191+ "/home/src/workspaces/project/tsconfig.second.json" : stringtestutil .Dedent (`
192+ {
193+ "extends": "./foobar.json",
194+ "compilerOptions": {
195+ "composite": true
196+ }
197+ }` ),
198+ "/home/src/workspaces/project/tsconfig.json" : stringtestutil .Dedent (`
199+ {
200+ "compilerOptions": {
201+ "composite": true
202+ },
203+ "references": [
204+ { "path": "./tsconfig.first.json" },
205+ { "path": "./tsconfig.second.json" }
206+ ]
207+ }` ),
208+ },
209+ commandLineArgs : []string {"--b" },
210+ },
211+ {
212+ subScenario : "reports syntax errors in config file" ,
213+ files : FileMap {
214+ "/home/src/workspaces/project/a.ts" : "export function foo() { }" ,
215+ "/home/src/workspaces/project/b.ts" : "export function bar() { }" ,
216+ "/home/src/workspaces/project/tsconfig.json" : stringtestutil .Dedent (`
217+ {
218+ "compilerOptions": {
219+ "composite": true,
220+ },
221+ "files": [
222+ "a.ts"
223+ "b.ts"
224+ ]
225+ }` ),
226+ },
227+ commandLineArgs : []string {"--b" },
228+ edits : []* tscEdit {
229+ {
230+ caption : "reports syntax errors after change to config file" ,
231+ edit : func (sys * testSys ) {
232+ sys .replaceFileText ("/home/src/workspaces/project/tsconfig.json" , "," , `, "declaration": true` )
233+ },
234+ },
235+ {
236+ caption : "reports syntax errors after change to ts file" ,
237+ edit : func (sys * testSys ) {
238+ sys .appendFile ("/home/src/workspaces/project/a.ts" , "export function fooBar() { }" )
239+ },
240+ },
241+ noChange ,
242+ {
243+ caption : "builds after fixing config file errors" ,
244+ edit : func (sys * testSys ) {
245+ sys .writeFileNoError ("/home/src/workspaces/project/tsconfig.json" , stringtestutil .Dedent (`
246+ {
247+ "compilerOptions": {
248+ "composite": true, "declaration": true
249+ },
250+ "files": [
251+ "a.ts",
252+ "b.ts"
253+ ]
254+ }` ), false )
255+ },
256+ },
257+ },
258+ },
259+ {
260+ subScenario : "missing config file" ,
261+ files : FileMap {},
262+ commandLineArgs : []string {"--b" , "bogus.json" },
263+ },
264+ }
265+
266+ for _ , test := range testCases {
267+ test .run (t , "configFileErrors" )
268+ }
269+ }
270+
178271func getBuildCommandLineDifferentOptionsMap (optionName string ) FileMap {
179272 return FileMap {
180273 "/home/src/workspaces/project/tsconfig.json" : stringtestutil .Dedent (fmt .Sprintf (`
0 commit comments