This commit is contained in:
Thomas Roberts 2021-06-17 08:50:52 +01:00 committed by GitHub
parent 60b95041ff
commit 984c5a0eb1
1 changed files with 3 additions and 3 deletions

View File

@ -15,14 +15,14 @@ import { allSettings } from './settings-init';
* the `fallback` will be returned instead. An optional `filter`
* callback can be passed to format the returned value.
*/
export const getSetting = (
export const getSetting = < T >(
name: string,
fallback: unknown = false,
filter = ( val: unknown, fb: unknown ) =>
typeof val !== 'undefined' ? val : fb
): unknown => {
): T => {
const value = name in allSettings ? allSettings[ name ] : fallback;
return filter( value, fallback );
return filter( value, fallback ) as T;
};
/**