Skip to content

Commit

Permalink
Addressing CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jramsay committed Nov 22, 2016
1 parent 70e130b commit a0ec828
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,17 @@ namespace ts {
let optionNameMapCache: OptionNameMap;

/* @internal */
export function replaceEnableAutoDiscoveryWithEnable(typeAcquisition: TypeAcquisition): void {
// Replace deprecated typingOptions.enableAutoDiscovery with typeAcquisition.enable
export function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition {
// Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable
if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
typeAcquisition.enable = typeAcquisition.enableAutoDiscovery;
delete typeAcquisition.enableAutoDiscovery;
const result: TypeAcquisition = {
enable: typeAcquisition.enableAutoDiscovery,
include: typeAcquisition.include || [],
exclude: typeAcquisition.exclude || []
};
return result;
}
return typeAcquisition;
}

/* @internal */
Expand Down Expand Up @@ -859,7 +864,8 @@ namespace ts {
}

let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
// typingOptions has been deprecated. Use typeAcquisition instead.
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
// It should be removed in future releases - use typeAcquisition instead.
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);

Expand Down Expand Up @@ -1034,8 +1040,8 @@ namespace ts {
basePath: string, errors: Diagnostic[], configFileName?: string): TypeAcquisition {

const options: TypeAcquisition = { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
replaceEnableAutoDiscoveryWithEnable(jsonOptions);
convertOptionsFromJson(typeAcquisitionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors);
const typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
convertOptionsFromJson(typeAcquisitionDeclarations, typeAcquisition, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors);

return options;
}
Expand Down
7 changes: 3 additions & 4 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,11 +1365,10 @@ namespace ts.server {

private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
// Replace deprecated typingOptions with typeAcquisition
// Convert deprecated typingOptions to typeAcquisition
if (request.arguments.typingOptions && !request.arguments.typeAcquisition) {
replaceEnableAutoDiscoveryWithEnable(request.arguments.typingOptions);
request.arguments.typeAcquisition = request.arguments.typingOptions;
delete request.arguments.typingOptions;
const typeAcquisition = convertEnableAutoDiscoveryToEnable(request.arguments.typingOptions);
request.arguments.typeAcquisition = typeAcquisition;
}
this.projectService.openExternalProject(request.arguments);
// TODO: report errors
Expand Down

0 comments on commit a0ec828

Please sign in to comment.