import { Ctx } from "../Ctx"; import { Polyfill as WeakMap } from "minimal-polyfills/dist/lib/WeakMap"; type VoidCtx = import("../Ctx").VoidCtx; export function getCtxFactory() { const ctxByObj = new WeakMap(); function getCtx(obj: object): VoidCtx; //function getCtx(obj: object): Ctx; function getCtx(obj: object): Ctx { let ctx = ctxByObj.get(obj); if (ctx === undefined) { ctx = new Ctx(); ctxByObj.set(obj, ctx); } return ctx; } return getCtx; }