Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
Eliminate pyproxy leaks. Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
exports.handlers = {
  jsdocCommentFound: function (e) {
    // JsDoc cannot handle Typescript type guards. Replace them with "boolean"
    // for JsDoc. Without this output docs get messed up.
    e.comment = e.comment.replace(/\{\s*\w*\s*\bis\b\s*\w*\s*\}/g, "{boolean}");
    // Remove typedefs from file. JsDoc can't parse these. Docs are produced
    // correctly without this but JsDoc produces very very noisy error messages.
    e.comment = e.comment.replace(/@typedef[^*]*/g, "");
    // There's still a couple of JsDoc parse errors we could fix...
  },
};

exports.handlers = {
  jsdocCommentFound: function (e) {
    // JsDoc cannot handle Typescript type guards. Replace them with "boolean"
    // for JsDoc. Without this output docs get messed up.
    e.comment = e.comment.replace(/\{\s*\w*\s*\bis\b\s*\w*\s*\}/g, "{boolean}");
    // Remove typedefs from file. JsDoc can't parse these. Docs are produced
    // correctly without this but JsDoc produces very very noisy error messages.
    e.comment = e.comment.replace(/@typedef[^*]*/g, "");
    // There's still a couple of JsDoc parse errors we could fix...
  },
};
