rdfjs / types

Authoritative TypeScript typings for all RDFJS specifications
MIT License
17 stars 13 forks source link

Export Quad Component Types #5

Open blake-regalia opened 4 years ago

blake-regalia commented 4 years ago

I'd like to propose adding simple union types for the various quad components. Generally, I am all for adding these types of semantic shortcuts that provide utility to implementations since there really is no overhead to consider. Of course though, the naming and organization of such additions is paramount.

// for 'hard' RDF 1.1 data; which excludes Quads and Variables 
export namespace Role {  // idk, it's shorter than 'Component'
   export type Subject = NamedNode | BlankNode;
   export type Predicate = NamedNode;
   export type Object = NamedNode | BlankNode | Literal;
   export type Graph = DefaultGraph | NamedNode | BlankNode;
   export type Datatype = NamedNode;
}

There could be another namespace for RDF-star, although it still seems quite uncertain to me at this point whether it will survive the standards track. IMO, Variables can be union'ed in on user-side for each of these component types.

I would also like to see Quad_Subject and the like put into a namespace, but I'm sure others had reasons for not doing that initially so I'd like to hear from them.