Path: blob/main/extensions/copilot/src/util/common/backwardCompatSetting.ts
13397 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45/**6* Provides backward compatibility for settings by mapping old or new value types to the new type.7*8* Chat configuration service doesn't have great support for migrating settings between types.9* This utility function helps to maintain backward compatibility when a setting's type changes.10*11* @param settingValue The setting value of the new type.12* @param map A function that transforms the setting value (which can be either old or new type) to the new type.13* @returns The mapped setting value of the new type.14*/15export function backwardCompatSetting<TOld, TNew>(settingValue: TNew, map: (oldValue: TOld | TNew) => TNew): TNew {16return map(settingValue);17}181920