Add propertybag to parsed tsconfig.json file.

This allows consumers of the LS to read properties added to the tsconfig.json
without having to worry about dealing with comments.
This commit is contained in:
Paul van Brenk
2016-05-04 14:50:58 -07:00
parent e9122a9f34
commit 4bc2314cbe
3 changed files with 20 additions and 0 deletions

View File

@@ -664,6 +664,22 @@ namespace ts {
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
const options = extend(existingOptions, compilerOptions);
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
// Contains the properties on the json we don't recognize, but the
// host might so we return them as a property bag. This allows the host to handle
// them, but doesn't have to deal with removing comments from the source json.
const other: any = {};
const knownProperties = ["compilerOptions", "typingOptions", "files", "exclude"];
for (const prop in json) {
if (knownProperties.indexOf(prop) >= 0) {
continue;
}
other[prop] = json[prop];
}
options.configFilePath = configFileName;
const fileNames = getFileNames(errors);
@@ -672,6 +688,7 @@ namespace ts {
options,
fileNames,
typingOptions,
other,
errors
};

View File

@@ -2592,6 +2592,7 @@ namespace ts {
options: CompilerOptions;
typingOptions?: TypingOptions;
fileNames: string[];
other?: any;
errors: Diagnostic[];
}

View File

@@ -997,6 +997,7 @@ namespace ts {
options: {},
typingOptions: {},
files: [],
other: {},
errors: [realizeDiagnostic(result.error, "\r\n")]
};
}
@@ -1008,6 +1009,7 @@ namespace ts {
options: configFile.options,
typingOptions: configFile.typingOptions,
files: configFile.fileNames,
other: configFile.other,
errors: realizeDiagnostics(configFile.errors, "\r\n")
};
});