fix(check): repair latest type drift batch

This commit is contained in:
Peter Steinberger
2026-04-06 15:03:49 +01:00
parent 380a396266
commit 732c18cd06
10 changed files with 152 additions and 83 deletions

View File

@@ -84,6 +84,11 @@ export function defineImportedCommandGroupSpecs<TRegisterArgs, TModule>(
}
type ProgramCommandRegistrar = (program: Command) => Promise<void> | void;
type AnyImportedProgramCommandGroupDefinition = {
commandNames: readonly string[];
loadModule: () => Promise<Record<string, unknown>>;
exportName: string;
};
export type ImportedProgramCommandGroupDefinition<
TModule extends Record<TKey, ProgramCommandRegistrar>,
@@ -108,10 +113,17 @@ export function defineImportedProgramCommandGroupSpec<
}
export function defineImportedProgramCommandGroupSpecs<
TModule extends Record<TKey, ProgramCommandRegistrar>,
TKey extends keyof TModule & string,
>(
definitions: readonly ImportedProgramCommandGroupDefinition<TModule, TKey>[],
): CommandGroupDescriptorSpec<(program: Command) => Promise<void>>[] {
return definitions.map((definition) => defineImportedProgramCommandGroupSpec(definition));
const TDefinitions extends readonly AnyImportedProgramCommandGroupDefinition[],
>(definitions: TDefinitions): CommandGroupDescriptorSpec<(program: Command) => Promise<void>>[] {
return definitions.map((definition) => ({
commandNames: definition.commandNames,
register: async (program: Command) => {
const module = await definition.loadModule();
const register = module[definition.exportName];
if (typeof register !== "function") {
throw new Error(`Missing program command registrar: ${definition.exportName}`);
}
await register(program);
},
}));
}