update to typesafe all-settings provider
This commit is contained in:
parent
99eafcb352
commit
964af82904
2 changed files with 8 additions and 3 deletions
|
@ -31,8 +31,13 @@ export default abstract class SettingHelper {
|
|||
email: new EmailConverter(),
|
||||
};
|
||||
|
||||
public static getAllSettings() {
|
||||
return cloneDeep(this.settings);
|
||||
public static getAllSettings(): { [key in SettingString]: SettingValueMapping[key] } {
|
||||
return Object.keys(settingsType).reduce((acc, key) => {
|
||||
const typedKey = key as SettingString;
|
||||
//@ts-expect-error
|
||||
acc[typedKey] = this.getSetting(typedKey);
|
||||
return acc;
|
||||
}, {} as { [key in SettingString]: SettingValueMapping[key] });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ export type SettingValueMapping = {
|
|||
// Typsicherer Zugriff auf Settings
|
||||
export type SettingDefinition<T extends SettingType | SettingTypeAtom[]> = {
|
||||
type: T;
|
||||
default?: string | number | boolean;
|
||||
default?: string | number | boolean | ms.StringValue;
|
||||
optional?: boolean;
|
||||
min?: T extends "number" | `number/crypt` | `number/rand` ? number : never;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue