I have an object remote which is not a class instance itself. Due to the nature of Angular 2-5 I need to wrap this Object in a service so I can inject it into components. The object has an interface declared 'Remote'.
How would I make the following work?
import { Injectable } from '@angular/core';
import { remote, Remote } from 'electron';
@Injectable()
export class RemoteService implements Remote {
constructor() {
Object.assign(this, remote);
}
}
I.e., how do I make a service class RemoteService which instances look like Remote, without having to manually wrap all remote's members? I cannot use extend because remote is not itself an instance of a class, just an object.
In the example above the Typescript compiler will complain that RemoteService incorrectly implements Remote (naturally). Is there any way to coerce the compiler into understand RemoteService as implementing Remote?
Remote?remoteimplements those, but that to use DI in angular 2+ I needremoteto be wrapped in a class. So what I want is a class that exports theRemoteinterface, but I don't want to have to wrap every single method in a public method on the class. Hence theObject.assign(this, remote), which should copy allremotereferences tothis. However, typescript complains thatRemoteServicedoesn't implementRemote. Which I understand. But how to circumvent it?