Loxer - v3.0.0
    Preparing search index...

    Type Alias RegisteredModules<M>

    RegisteredModules: [keyof LoxerModuleRegistry] extends [never]
        ? LoxerModules
        : Record<Extract<keyof LoxerModuleRegistry, string>, Module> & Partial<
            Record<DefaultModuleId, Module>,
        > & { [K in keyof M]: K extends ModuleId ? Module : never }

    The modules Loxer.init accepts, checked against the LoxerModuleRegistry.

    • it is LoxerModules as long as the registry is not augmented - any set of module ids is accepted
    • once modules are registered there, every registered id has to be defined, the built-in ids may be overwritten, and no other id is accepted
      declare module 'loxer' {
    interface LoxerModuleRegistry extends Record<'PERS' | 'DB', true> {}
    }

    Loxer.init({ modules: { PERS, DB } }); // ✔
    Loxer.init({ modules: { PERS, DB, NONE } }); // ✔ - a built-in module, overwritten
    Loxer.init({ modules: { PERS } }); // ✘ - 'DB' is registered but not defined
    Loxer.init({ modules: { PERS, DB, PRES } }); // ✘ - 'PRES' is not a registered module id

    The type parameter carries the object that is passed in, which is what lets an unregistered id be reported even when that object is declared elsewhere and handed over as a variable: its key resolves to never. An object typed by a : LoxerModules annotation carries an index signature instead of its keys and can therefore not be checked at all - declare it with satisfies LoxerModules to keep its keys.

    Type Parameters

    • M = unknown