Closed thatcort closed 4 years ago
This is related to https://github.com/linkeddata/rdflib.js/issues/376
@joepio is looking into it ^_^
You're using it correctly, the problem has to do with internal type inconsistencies that slipped through. Thanks for the detailed report. I've added tests for your use cases and fixed (loosened up) the types.
PR with fix is open: https://github.com/linkeddata/rdflib.js/pull/380
I'm having some type compatibility problems using the latest version
1.0.7-2
. This could be because I'm very inexperienced with the library, so any advice is appreciated.DataFactory.namedNode:
import { IndexedFormula, NamedNode, DataFactory } from 'rdflib'; const nn: NamedNode = DataFactory.namedNode('https://example.com/foo'); <--- ERROR
Type 'NamedNode' is missing the following properties from type 'NamedNode': classOrder, dir, site, doc, and 9 more.ts(2740)
It seems that DataFactory.namedNode returns an instance of an interface NamedNode defined in tf-types.d.ts, while NamedNode imported from rdflib is a class defined in named-node.d.ts. Which is correct? This seems to be the same problem as the next issue.
DataFactory.triple:
Argument of type 'NamedNode' is not assignable to parameter of type 'SubjectType'. Type 'import("...../node_modules/rdflib/lib/tf-types").NamedNode' is not assignable to type 'import("...../node_modules/rdflib/lib/named-node").default'.ts(2345)
IndexedFormula.remove:
Argument of type 'Statement' is not assignable to parameter of type 'Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]'. Type 'Statement' is not assignable to type 'Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>'. Types of property 'object' are incompatible. Type 'ObjectType' is not assignable to type 'Quad_Object'. Type 'Collection<Node | BlankNode | Literal | Collection | Variable>' is not assignable to type 'Quad_Object'.
Type 'Collection<Node | BlankNode | Literal | Collection | Variable>' is missing the following properties from type 'Literal': language, datatypets(2345)