diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 5e44efc4235cc..414e1f117f52e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -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 */ @@ -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); @@ -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; } diff --git a/src/server/session.ts b/src/server/session.ts index 282964611e4ed..c83ccd29ff142 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -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