mwbot-ts - v1.2.7
    Preparing search index...

    Interface MwConfig<V, TX>Private

    The structure of Mwbot.config, designed to provide user-friendly Intellisense suggestions.

    This interface is essentially a TypeScript representation of mw.config from MediaWiki core, with some adjustments for improved usability.

    See Mwbot.config for implementation details.

    interface MwConfig<V extends Record<string, any>, TX = unknown> {
        exists(selection: keyof V): boolean;
        exists(selection: string): boolean;
        get<S extends string | number | symbol | (keyof V)[], TD>(
            selection: S,
            fallback: TD,
        ): PickOrDefault<V, S, TD, TX>;
        get<S extends MultiValue<string>, TD>(
            selection: S,
            fallback: TD,
        ): PickOrDefault<V, S, TD, TX>;
        get<S extends string | number | symbol | (keyof V)[]>(
            selection: S,
        ): PickOrDefault<V, S, null, TX>;
        get<S extends MultiValue<string>>(
            selection: S,
        ): PickOrDefault<V, S, null, TX>;
        get(): V & Record<string, TX>;
        set<S extends string | number | symbol>(selection: S, value: V[S]): boolean;
        set<S extends string>(selection: S, value: TX): boolean;
        set<S extends Partial<V> & Record<string, TX>>(selection: S): boolean;
    }

    Type Parameters

    • V extends Record<string, any>
    • TX = unknown
    Index

    Methods

    Methods

    • Checks if a given configuration key exists.

      Parameters

      • selection: keyof V

        Key to check.

      Returns boolean

      true if the key exists.

    • Parameters

      • selection: string

      Returns boolean

    • Gets the value of one or more keys.

      If called with no arguments, all values are returned.

      Type Parameters

      • S extends string | number | symbol | (keyof V)[]
      • TD

      Parameters

      • selection: S

        Key or array of keys to retrieve values for.

      • fallback: TD

        Value for keys that don't exist.

      Returns PickOrDefault<V, S, TD, TX>

      If selection was a string, returns the value. If selection was an array, returns an object of key/values. If no selection is passed, a new object with all key/values is returned. Any type of the return value is a deep copy of the original stored in the instance.

    • Type Parameters

      Parameters

      • selection: S
      • fallback: TD

      Returns PickOrDefault<V, S, TD, TX>

    • Type Parameters

      • S extends string | number | symbol | (keyof V)[]

      Parameters

      • selection: S

      Returns PickOrDefault<V, S, null, TX>

    • Type Parameters

      Parameters

      • selection: S

      Returns PickOrDefault<V, S, null, TX>

    • Returns V & Record<string, TX>

    • Sets the value of one or more keys.

      Type Parameters

      • S extends string | number | symbol

      Parameters

      • selection: S

        Key to set value for, or object mapping keys to values.

      • value: V[S]

        Value to set (optional, only in use when key is a string).

      Returns boolean

      true on success, false on failure.

      NOTE: The pre-set wg-configuration variables are read-only, and attempts to set a new value for them always return false.

    • Type Parameters

      • S extends string

      Parameters

      • selection: S
      • value: TX

      Returns boolean

    • Type Parameters

      • S extends Partial<V> & Record<string, TX>

      Parameters

      • selection: S

      Returns boolean