// @ts-ignore (target) // eslint-disable-next-line @typescript-eslint/ban-types export function bind(target: object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor { if (!descriptor || (typeof descriptor.value !== 'function')) { throw new TypeError(`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`); } return { configurable: true, get(this: T): T { const bound: T = descriptor.value?.bind(this) || false; Object.defineProperty(this, propertyKey, { value: bound, configurable: true, writable: true }); return bound; } }; }