fix: avoid eval in makeInspectable

This commit is contained in:
alina 🌸 2024-09-07 19:18:42 +03:00
parent 4bd57316a1
commit 927ff1cf4e
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -47,8 +47,7 @@ export function makeInspectable<T>(
} }
// dirty hack to set name for inspect result // dirty hack to set name for inspect result
// eslint-disable-next-line ts/no-implied-eval, no-new-func const proto = ({ [obj.name]: class {} })[obj.name].prototype
const proto = new Function(`return function ${obj.name}(){}`)().prototype
obj.prototype.toJSON = function () { obj.prototype.toJSON = function () {
const ret: any = Object.create(proto) const ret: any = Object.create(proto)