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 ba0a6e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,14 @@ 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
const result = typeAcquisition;
if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
typeAcquisition.enable = typeAcquisition.enableAutoDiscovery;
delete typeAcquisition.enableAutoDiscovery;
result.enable = typeAcquisition.enableAutoDiscovery;
delete result.enableAutoDiscovery;
}
return result;
}

/* @internal */
Expand Down Expand Up @@ -859,7 +861,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 +1037,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 ba0a6e9

Please sign in to comment.