@@ -258,13 +258,13 @@ namespace FourSlash {
258
258
let startResolveFileRef : FourSlashFile ;
259
259
260
260
let configFileName : string ;
261
- ts . forEach ( testData . files , file => {
261
+ for ( const file of testData . files ) {
262
262
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
263
263
this . inputFiles . set ( file . fileName , file . content ) ;
264
- if ( isTsconfig ( file ) ) {
264
+ if ( isConfig ( file ) ) {
265
265
const configJson = ts . parseConfigFileTextToJson ( file . fileName , file . content ) ;
266
266
if ( configJson . config === undefined ) {
267
- throw new Error ( `Failed to parse test tsconfig.json : ${ configJson . error . messageText } ` ) ;
267
+ throw new Error ( `Failed to parse test ${ file . fileName } : ${ configJson . error . messageText } ` ) ;
268
268
}
269
269
270
270
// Extend our existing compiler options so that we can also support tsconfig only options
@@ -286,7 +286,7 @@ namespace FourSlash {
286
286
// If entry point for resolving file references is already specified, report duplication error
287
287
throw new Error ( "There exists a Fourslash file which has resolveReference flag specified; remove duplicated resolveReference flag" ) ;
288
288
}
289
- } ) ;
289
+ }
290
290
291
291
if ( configFileName ) {
292
292
const baseDir = ts . normalizePath ( ts . getDirectoryPath ( configFileName ) ) ;
@@ -295,12 +295,7 @@ namespace FourSlash {
295
295
const configJsonObj = ts . parseConfigFileTextToJson ( configFileName , this . inputFiles . get ( configFileName ) ) ;
296
296
assert . isTrue ( configJsonObj . config !== undefined ) ;
297
297
298
- const { options, errors } = ts . parseJsonConfigFileContent ( configJsonObj . config , host , baseDir ) ;
299
-
300
- // Extend our existing compiler options so that we can also support tsconfig only options
301
- if ( ! errors || errors . length === 0 ) {
302
- compilationOptions = ts . extend ( compilationOptions , options ) ;
303
- }
298
+ compilationOptions = ts . parseJsonConfigFileContent ( configJsonObj . config , host , baseDir , compilationOptions , configFileName ) . options ;
304
299
}
305
300
306
301
@@ -3401,13 +3396,14 @@ ${code}
3401
3396
}
3402
3397
3403
3398
// @Filename is the only directive that can be used in a test that contains tsconfig.json file.
3404
- if ( files . some ( isTsconfig ) ) {
3399
+ const config = ts . find ( files , isConfig ) ;
3400
+ if ( config ) {
3405
3401
let directive = getNonFileNameOptionInFileList ( files ) ;
3406
3402
if ( ! directive ) {
3407
3403
directive = getNonFileNameOptionInObject ( globalOptions ) ;
3408
3404
}
3409
3405
if ( directive ) {
3410
- throw Error ( " It is not allowed to use tsconfig.json along with directive '" + directive + "'" ) ;
3406
+ throw Error ( ` It is not allowed to use ${ config . fileName } along with directive '${ directive } '` ) ;
3411
3407
}
3412
3408
}
3413
3409
@@ -3420,8 +3416,8 @@ ${code}
3420
3416
} ;
3421
3417
}
3422
3418
3423
- function isTsconfig ( file : FourSlashFile ) : boolean {
3424
- return ts . getBaseFileName ( file . fileName ) . toLowerCase ( ) === "tsconfig.json" ;
3419
+ function isConfig ( file : FourSlashFile ) : boolean {
3420
+ return Harness . getConfigNameFromFileName ( file . fileName ) !== undefined ;
3425
3421
}
3426
3422
3427
3423
function getNonFileNameOptionInFileList ( files : FourSlashFile [ ] ) : string {
0 commit comments