In the documentation on custom events it shows the following example code for TypeScript:
class PaymentService {
async create(data: any, params: Params) {
const customer = await createStripeCustomer(params.user)
this.emit('status', { status: 'created' })
const payment = await createPayment(data)
this.emit('status', { status: 'completed' })
return payment
}
}
But this will produce a TypeScript error at this.emit:
Property 'emit' does not exist on type 'PaymentService'.
I can solve this with PaymentService extends EventEmitter, but it seems like it would be better if there was a Feathers typing solution. I've been unsuccessful solving the issue using Feathers' types. For example, the FeathersService type includes the emit() addon but since it is only an interface, PaymentService implements FeathersService<...> doesn't actually endow the class with this property. Any recommendations on the best way to type this?
In the documentation on custom events it shows the following example code for TypeScript:
But this will produce a TypeScript error at
this.emit:I can solve this with
PaymentService extends EventEmitter, but it seems like it would be better if there was a Feathers typing solution. I've been unsuccessful solving the issue using Feathers' types. For example, theFeathersServicetype includes theemit()addon but since it is only an interface,PaymentService implements FeathersService<...>doesn't actually endow the class with this property. Any recommendations on the best way to type this?