Simple support for generics off the settings store

Ideally the settings store returns the right type, but for now we can feed it the type we need/expect.
This commit is contained in:
Travis Ralston 2021-01-18 17:40:32 -07:00
parent 7b882c6393
commit 1f219d8530

View file

@ -276,7 +276,7 @@ export default class SettingsStore {
* @param {boolean} excludeDefault True to disable using the default value.
* @return {*} The value, or null if not found
*/
public static getValue(settingName: string, roomId: string = null, excludeDefault = false): any {
public static getValue<T = any>(settingName: string, roomId: string = null, excludeDefault = false): T {
// Verify that the setting is actually a setting
if (!SETTINGS[settingName]) {
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");