CommunitySolidServer icon indicating copy to clipboard operation
CommunitySolidServer copied to clipboard

feat: Improve vocabulary typings

Open joachimvh opened this issue 2 years ago • 3 comments

📁 Related issues

Caused by discussion at https://github.com/CommunitySolidServer/CommunitySolidServer/pull/1388#discussion_r930262263

✍️ Description

Updates Vocabularies.ts with more precise typings so they can be used as type guards together with some utility types.

VocabularyLocals<typeof AS> is "Create" | "Delete" | "Update"

VocabularyValues<typeof AS> is AS.Create | AS.Delete | AS.Update is "https://www.w3.org/ns/activitystreams#Create" | "https://www.w3.org/ns/activitystreams#Delete" | "https://www.w3.org/ns/activitystreams#Update"

VocabularyTerms<typeof AS> is AS.terms.Create | AS.terms.Delete | AS.terms.Update is NamedNode<"https://www.w3.org/ns/activitystreams#Create"> | NamedNode<"https://www.w3.org/ns/activitystreams#Delete"> | NamedNode<"https://www.w3.org/ns/activitystreams#Update">

joachimvh avatar Aug 10 '22 12:08 joachimvh

Honestly these typings are so exciting that the file should be its own npm package.

RubenVerborgh avatar Aug 10 '22 20:08 RubenVerborgh

Honestly these typings are so exciting that the file should be its own npm package.

Now that CSS has its own namespace on github we could potentially extract some of the utility components and put them in separate repositories. Although it might become a bit more hassle to maintain.

joachimvh avatar Aug 11 '22 06:08 joachimvh

Yes some utilities wouldn't hurt. Maybe that one can move to N3.js (but then it needs TypeScript first).

RubenVerborgh avatar Aug 11 '22 09:08 RubenVerborgh