Open mauritsderoover opened 1 year ago
Generally speaking I would recommend using #match()
rather than #getQuads()
as #match()
is the method used by the RDF/JS dataset interface.
I'm also happy to review a PR to definitelyTyped updating the types.
Also something that should probably be updated at the same time is ensuring that Quad
s are valid subject and object Term
s
Are you referring to for example to the different implementations of RDF.NamedNode in rdf-data-factory and N3?
Rdf-data-factory => this seems to be the correct implementation of the rdf-js specification
`export declare class NamedNode
readonly termType = "NamedNode";
readonly value: Iri;
constructor(value: Iri);
equals(other?: RDF.Term | null): boolean;
}`
N3
`export class NamedNode
readonly termType: "NamedNode";
readonly value: Iri;
constructor(iri: Iri);
readonly id: string;
toJSON(): {};
equals(other: RDF.Term): boolean;
static subclass(type: any): void;
}`
This basically means that I cannot use a quad from the factory with a N3.store without asserting types.
I mean that
export type Quad_Subject = NamedNode | BlankNode | Variable;
export type Quad_Predicate = NamedNode | Variable;
export type Quad_Object = NamedNode | Literal | BlankNode | Variable;
export type Quad_Graph = DefaultGraph | NamedNode | BlankNode | Variable;
at the very least should be
export type Quad_Subject = NamedNode | BlankNode | Variable | BaseQuad;
export type Quad_Predicate = NamedNode | Variable;
export type Quad_Object = NamedNode | Literal | BlankNode | Variable | BaseQuad;
export type Quad_Graph = DefaultGraph | NamedNode | BlankNode | Variable;
to reflect the fact that the store supports rdf-star nested triples (in actual fact the implementation really supports BaseQuad
s in any position; but whether to expose that in the TS interface is another question)
Every parameter in GetQuads should accept null or undefined but in the type definition file it is required to provide a OTerm.
I could change the type definitions and create a pull request if you would point me in the right direction.
Related to #139 #298