Raise error if mixing tsconfig.json and directives.

This commit is contained in:
unknown 2015-07-27 21:02:58 -07:00
parent 450112d28a
commit 90e31adea8

View File

@ -2476,6 +2476,17 @@ module FourSlash {
}
}
// @Filename is the only directive that can be used in a test that contains tsconfig.json file.
if (containTSConfigJson(files)) {
let directive = getNonFileNameOptionInFileList(files);
if (directive == null) {
directive = getNonFileNameOptionInObject(globalOptions);
}
if (directive !== null) {
throw Error("It is not allowed to use tsconfig.json along with directive '" + directive + "'");
}
}
return {
markerPositions,
markers,
@ -2485,6 +2496,34 @@ module FourSlash {
};
}
function containTSConfigJson(files: FourSlashFile[]): boolean {
for (let i = 0; i < files.length; ++i) {
if (files[i].fileOptions['Filename'] === 'tsconfig.json') {
return true;
}
}
return false;
}
function getNonFileNameOptionInFileList(files: FourSlashFile[]): string {
for (let i = 0; i < files.length; ++i) {
let option = getNonFileNameOptionInObject(files[i].fileOptions);
if (option !== null) {
return option;
}
}
return null;
}
function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string {
for (let option in optionObject) {
if (option !== metadataOptionNames.fileName) {
return option;
}
}
return null;
}
const enum State {
none,
inSlashStarMarker,