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