/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ interface Watcher { dispose(): void; } type StringPolicy = { type: "string" }; type NumberPolicy = { type: "number" }; type BooleanPolicy = { type: "boolean" }; type PolicyType = "string" | "number" | "boolean"; type UnionPolicy = { type: readonly [PolicyType, ...PolicyType[]] }; export interface Policies { [policyName: string]: StringPolicy | NumberPolicy | BooleanPolicy | UnionPolicy; } export interface WatcherOptions { /** Windows only: custom registry key path. Defaults to `Software\Policies\Microsoft\`. */ registryPath?: string; } export type PolicyUpdate = { [K in keyof T]: | undefined | (T[K]["type"] extends readonly PolicyType[] ? PolicyTypeValue : PolicyTypeValue); }; type PolicyTypeValue = T extends "string" ? string : T extends "boolean" ? boolean : T extends "number" ? number : never; export function createWatcher( vendorName: string, productName: string, policies: T, onDidChange: (update: PolicyUpdate) => void, options?: WatcherOptions ): Watcher;