declare global { interface LenientGlobalVariableTypes { game : never ; canvas : never ; } interface String { /** Localizes the string via the global `game.i18n.localize()` function. */ localize ( ) : string ; } type AnyFunction = ( ... args : any ) => any ; } export default class SETTINGS { static MOD_NAME : string ; static init ( moduleName ) { this . MOD_NAME = moduleName ; if ( ! String . prototype . localize ) { String . prototype . localize = function ( ) { return game . i18n . localize ( this . valueOf ( ) ) ; } ; } } static register < T > ( key , config ) { game . settings . register ( SETTINGS . MOD_NAME , key , config ) ; } static registerMenu ( key , config ) { game . settings . registerMenu ( SETTINGS . MOD_NAME , key , config ) ; } static get < T > ( key ) { return < T > game . settings . get ( SETTINGS . MOD_NAME , key ) ; } static async set < T > ( key , value ) { return await game . settings . set ( SETTINGS . MOD_NAME , key , value ) ; } static default < T > ( key ) { return < T > game . settings . settings . get ( SETTINGS . MOD_NAME + '.' + key ) . default ; } /** helper for referencing a Typed constructor for the `type` field of a setting { type: SETTINGS.typeOf<MyClass>() } */ static typeOf < T > ( ) { return Object as any ; } }