mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 12:15:34 -06:00
Raise error if mixing tsconfig.json and directives.
This commit is contained in:
parent
450112d28a
commit
90e31adea8
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user