'TS2345: Argument of type x is not assignable to parameter of type y, x is extends y
I want to run the sigma.js\examples\custom-rendering example, when I run npm start, I got TS2345: Argument of type 'Graph<Attributes, Attributes, Attributes>' is not assignable to parameter of type 'AbstractGraph<Attributes, Attributes, Attributes>'. errors.
I find the Graph type declaration is the following.
export default class Graph<
NodeAttributes extends Attributes = Attributes,
EdgeAttributes extends Attributes = Attributes,
GraphAttributes extends Attributes = Attributes
> extends AbstractGraph<NodeAttributes, EdgeAttributes, GraphAttributes> {}
declare abstract class AbstractGraph<
NodeAttributes extends Attributes = Attributes,
EdgeAttributes extends Attributes = Attributes,
GraphAttributes extends Attributes = Attributes
> extends EventEmitter<NodeAttributes, EdgeAttributes, GraphAttributes> { ... }
It seems typescript does not accept Graph<Attributes, Attributes, Attributes> as an AbstractGraph<Attributes, Attributes, Attributes> instance. That's different from what I have learn in Java/C#.
What's wrong with it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
