From 3020fcc9bb1af9ae40e84c08c3b44ea66344b27b Mon Sep 17 00:00:00 2001 From: V Date: Wed, 21 Jun 2023 02:00:38 +0200 Subject: [skip ci] Improve typings for settings.withPrivateSettings --- src/utils/types.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/utils') diff --git a/src/utils/types.ts b/src/utils/types.ts index 6af1bdc..7b682e9 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -260,25 +260,29 @@ type SettingsStore = { }; /** An instance of defined plugin settings */ -export interface DefinedSettings = {}> { +export interface DefinedSettings< + Def extends SettingsDefinition = SettingsDefinition, + Checks extends SettingsChecks = {}, + PrivateSettings extends object = {} +> { /** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */ - store: SettingsStore; + store: SettingsStore & PrivateSettings; /** * React hook for getting the settings for this plugin * @param filter optional filter to avoid rerenders for irrelavent settings */ - use>(filter?: F[]): Pick, F>; + use>(filter?: F[]): Pick & PrivateSettings, F>; /** Definitions of each setting */ - def: D; + def: Def; /** Setting methods with return values that could rely on other settings */ - checks: C; + checks: Checks; /** * Name of the plugin these settings belong to, * will be an empty string until plugin is initialized */ pluginName: string; - withPrivateSettings(): this & { store: T; }; + withPrivateSettings(): DefinedSettings; } export type PartialExcept = Partial & Required>; -- cgit