// @ts-ignore // tslint:disable-next-line: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); Object.defineProperty(this, propertyKey, { value: bound, configurable: true, writable: true }); return bound; } }; }