Skip to content
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

GetQuads has a false Typescript definition #322

Open
mauritsderoover opened this issue Feb 9, 2023 · 4 comments
Open

GetQuads has a false Typescript definition #322

mauritsderoover opened this issue Feb 9, 2023 · 4 comments

Comments

@mauritsderoover
Copy link

mauritsderoover commented Feb 9, 2023

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

@mauritsderoover mauritsderoover changed the title GetQuads has a false Typescript Defi GetQuads has a false Typescript definition Feb 9, 2023
@jeswr
Copy link
Collaborator

jeswr commented Feb 9, 2023

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.

@jeswr
Copy link
Collaborator

jeswr commented Feb 9, 2023

Also something that should probably be updated at the same time is ensuring that Quads are valid subject and object Terms

@mauritsderoover
Copy link
Author

mauritsderoover commented Feb 9, 2023

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 implements RDF.NamedNode {

readonly termType = "NamedNode";

readonly value: Iri;

constructor(value: Iri);

equals(other?: RDF.Term | null): boolean;

}`

N3

`export class NamedNode implements RDF.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.

@jeswr
Copy link
Collaborator

jeswr commented Feb 9, 2023

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 BaseQuads in any position; but whether to expose that in the TS interface is another question)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants