-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with RDF/JS types #374
Comments
Let’s already open discussion for 1. Perhaps Collection could be a subclass of BlankNode; that actually makes sense. |
Working on it. I've reached out to the editor of the types and I've created a fork for PR. |
In the spec and RDF/JS repo it's a little unclear where extension should be allowed. Despite the IDL in the spec using If subclassing If subclassing |
The current types are strictly related to the core building blocks of RDF. The I have not looked at the code being discussed but it is definitely possible to extend a term. For example you might define a const factory: DataFactory = <any> {};
interface Collection extends BlankNode {}
const collectionNode: Collection = <any> {};
const predicate: NamedNode = <any> {};
const obj: NamedNode = <any> {};
factory.quad(collectionNode, predicate, obj); |
CC: @rubensworks |
I'm fine with making Terms more extensible in the typings, but we have to take into account that this would break certain TS implementations that depend on these strict types. For reference, this was the reasoning for making the typings like this a couple of years ago: https://lists.w3.org/Archives/Public/public-rdfjs/2017Sep/0001.html |
The RDF/JS taskforce data model spec specifies a set of classes and methods for RDF related models.
During the migration to Typescript (#373 #355) I decided to use RDF/JS types, and extend these in RDFlib when necessary. However, another set of typescript types already exists. I tried to use these types in RDFlib, but I could not resolve the type errors.
The most fundamental problem is that @types/rdf-js defines Term as a Union of its other Terms:
The RDF/JS spec defines Term as an abstract interface.
Since RDFlib uses custom terms (like Collection), it is compatible with the RDF/JS spec, and it works with my types, but it does not work with the types from @types/rdf-js. This problem with Term, unfortunately, trickles down quite a bit and makes it impossible to use these types, at the moment.
There are a couple of things we can do here:
tf-types.ts
that is included in Typescript #373The text was updated successfully, but these errors were encountered: