Augment this interface to type Loxer.init({ modules }), .module(...), .m(...),
Loxer.getModuleLevel(...) and the moduleId trace option after the modules your project
declares.
While this interface is empty — the default — a module id is an ordinary string and nothing
changes. Register your modules once and every module id becomes autocompleted and typo-checked:
From then on Loxer.m('PERS') is accepted and Loxer.m('PRES') is a compile error, while the
built-in ids (see DefaultModuleId) stay valid. Only the property keys are read — their
value type is irrelevant, true is just the cheapest thing to write.
The modules given to Loxer.init(...) are held to the same registry: a registered id that the
object does not define, and an id the object defines without registering it, are both compile
errors — see RegisteredModules. Deriving the registry from the object with
Record<keyof typeof modules, true>, as above, keeps the two in lockstep by construction.
satisfies LoxerModules, never : LoxerModules: an annotation widens the keys back to
string, which silently turns the whole check off again with no error to tell you.
the augmentation must live in a file that is a module. If it has no other import / export,
add an export {}; — otherwise TypeScript reads it as an ambient declaration that replaces
the package.
a misspelled module specifier (declare module 'loxr') fails silently, so check that a
deliberate typo really errors after wiring this up.
the registry is global to a compilation, matching Loxer's single set of modules. Several
packages may each augment it; the declarations merge.
ModuleId is the resolved id type, should you need to name it.
Registry for type-safe module ids
Augment this interface to type
Loxer.init({ modules }),.module(...),.m(...),Loxer.getModuleLevel(...)and themoduleIdtrace option after the modules your project declares.While this interface is empty — the default — a module id is an ordinary
stringand nothing changes. Register your modules once and every module id becomes autocompleted and typo-checked:From then on
Loxer.m('PERS')is accepted andLoxer.m('PRES')is a compile error, while the built-in ids (see DefaultModuleId) stay valid. Only the property keys are read — their value type is irrelevant,trueis just the cheapest thing to write.The
modulesgiven toLoxer.init(...)are held to the same registry: a registered id that the object does not define, and an id the object defines without registering it, are both compile errors — see RegisteredModules. Deriving the registry from the object withRecord<keyof typeof modules, true>, as above, keeps the two in lockstep by construction.satisfies LoxerModules, never: LoxerModules: an annotation widens the keys back tostring, which silently turns the whole check off again with no error to tell you.import/export, add anexport {};— otherwise TypeScript reads it as an ambient declaration that replaces the package.declare module 'loxr') fails silently, so check that a deliberate typo really errors after wiring this up.Loxer's single set of modules. Several packages may each augment it; the declarations merge.