const type = Symbol(); export type PlugableRecord = Record; export type Key = symbol & { [type]: T }; export type Val = K[typeof type]; export const plugableRecord = { key(desc: string) { return Symbol(desc) as Key; }, set(map: PlugableRecord, key: K, value: Val) { map[key] = value; }, get(map: PlugableRecord, key: K): Val | undefined { return map[key]; }, getAssure(map: PlugableRecord, key: K): Val { if (!map[key]) { throw new Error(`key ${key.description} is missing on map`); } return map[key]; }, getUnsafe(map: PlugableRecord, key: K): Val { return map[key]; }, };