I'm faced with a situation where I need to create a class using a third-party interface (more specifically D3).
I want to create a class implementing the D3.Force interface, but my compiler just wont have it.
class CustomForce<NodeDatum extends D3.SimulationNodeDatum> implements D3.Force<NodeDatum, any> {
// Some more code at some point
}
This throws the following error:
Class 'CustomForce<NodeDatum>' incorrectly implements interface 'Force<NodeDatum, any>'.
Type 'CustomForce<NodeDatum>' provides no match for the signature '(alpha: number): void'
By inspecting the definition for D3.Force, I see the following:
export interface Force<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> {
(alpha: number): void;
initialize?(nodes: NodeDatum[]): void;
}
How do I implement an anonymous function taking in alpha as argument?!