@@ -263,13 +263,14 @@ namespace FourSlash {
263
263
let startResolveFileRef : FourSlashFile ;
264
264
265
265
let configFileName : string ;
266
- ts . forEach ( testData . files , file => {
266
+ for ( const file of testData . files ) {
267
267
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
268
268
this . inputFiles . set ( file . fileName , file . content ) ;
269
- if ( ts . getBaseFileName ( file . fileName ) . toLowerCase ( ) === "tsconfig.json" ) {
269
+ const config = Harness . getConfigNameFromFileName ( file . fileName ) ;
270
+ if ( config ) {
270
271
const configJson = ts . parseConfigFileTextToJson ( file . fileName , file . content ) ;
271
272
if ( configJson . config === undefined ) {
272
- throw new Error ( `Failed to parse test tsconfig.json : ${ configJson . error . messageText } ` ) ;
273
+ throw new Error ( `Failed to parse test ${ config } : ${ configJson . error . messageText } ` ) ;
273
274
}
274
275
275
276
// Extend our existing compiler options so that we can also support tsconfig only options
@@ -291,7 +292,7 @@ namespace FourSlash {
291
292
// If entry point for resolving file references is already specified, report duplication error
292
293
throw new Error ( "There exists a Fourslash file which has resolveReference flag specified; remove duplicated resolveReference flag" ) ;
293
294
}
294
- } ) ;
295
+ }
295
296
296
297
if ( configFileName ) {
297
298
const baseDir = ts . normalizePath ( ts . getDirectoryPath ( configFileName ) ) ;
@@ -3098,13 +3099,11 @@ ${code}
3098
3099
}
3099
3100
3100
3101
// @Filename is the only directive that can be used in a test that contains tsconfig.json file.
3101
- if ( containTSConfigJson ( files ) ) {
3102
- let directive = getNonFileNameOptionInFileList ( files ) ;
3103
- if ( ! directive ) {
3104
- directive = getNonFileNameOptionInObject ( globalOptions ) ;
3105
- }
3102
+ const config = ts . forEach ( files , f => Harness . getConfigNameFromFileName ( f . fileName ) ) ;
3103
+ if ( config ) {
3104
+ const directive = ts . forEach ( files , f => getNonFileNameOptionInObject ( f . fileOptions ) ) || getNonFileNameOptionInObject ( globalOptions ) ;
3106
3105
if ( directive ) {
3107
- throw Error ( " It is not allowed to use tsconfig.json along with directive '" + directive + "'" ) ;
3106
+ throw Error ( ` It is not allowed to use ${ config } along with directive '${ directive } '` ) ;
3108
3107
}
3109
3108
}
3110
3109
@@ -3117,14 +3116,6 @@ ${code}
3117
3116
} ;
3118
3117
}
3119
3118
3120
- function containTSConfigJson ( files : FourSlashFile [ ] ) : boolean {
3121
- return ts . forEach ( files , f => f . fileOptions [ "Filename" ] === "tsconfig.json" ) ;
3122
- }
3123
-
3124
- function getNonFileNameOptionInFileList ( files : FourSlashFile [ ] ) : string {
3125
- return ts . forEach ( files , f => getNonFileNameOptionInObject ( f . fileOptions ) ) ;
3126
- }
3127
-
3128
3119
function getNonFileNameOptionInObject ( optionObject : { [ s : string ] : string } ) : string {
3129
3120
for ( const option in optionObject ) {
3130
3121
if ( option !== metadataOptionNames . fileName ) {
0 commit comments