export type Constructor = new (...args: any[]) => T; export class Registry = Record> { private is_set: boolean = false; private items: Items = {} as Items; set>(items: Actual) { if (this.is_set) { throw new Error("Registry is already set"); } // @ts-ignore this.items = items; this.is_set = true; return this as unknown as Registry; } add(name: string, item: Item) { // @ts-ignore this.items[name] = item; return this; } get(name: Name): Items[Name] { return this.items[name]; } all() { return this.items; } }