Skip to content

feat: export WrappingSet and narrow SetFrom's return type to WrappingSet<T> - #92

Draft
jeswr wants to merge 1 commit into
rdfjs:mainfrom
jeswr:feat/export-wrapping-set
Draft

feat: export WrappingSet and narrow SetFrom's return type to WrappingSet<T>#92
jeswr wants to merge 1 commit into
rdfjs:mainfrom
jeswr:feat/export-wrapping-set

Conversation

@jeswr

@jeswr jeswr commented Jul 6, 2026

Copy link
Copy Markdown
Member

Makes WrappingSet part of the public API and lets the type system say so.

WrappingSet is the concrete type behind every set-mapped model property, but it was internal: consuming code could not name the type, and SetFrom.subjectPredicate could only advertise the plain Set<T> interface. This is a prerequisite for set-level features (e.g. the per-set change notifications explored in #73), which need the concrete class to be publicly nameable.

Changes

  • src/mod.ts: export * from "./WrappingSet.js"
  • src/mapping/SetFrom.ts: narrow subjectPredicate's return type from Set<T> to WrappingSet<T>. Non-breaking: WrappingSet<T> implements Set<T>, so every existing annotation (e.g. model properties typed Set<Child>) still type-checks; the runtime value is unchanged.
  • src/WrappingSet.ts: class and constructor JSDoc (live-view semantics, SetFrom.subjectPredicate as the intended entry point, a paired turtle/ts example).
  • test/unit/wrapping_set.test.ts: asserts a set-mapped model property is an instanceof WrappingSet, and (at compile time, via the model's WrappingSet<string> property type) that the narrowed return type is exposed through the package surface.

Relationship to #73

Supersedes one slice of the #73 omnibus: the SetFrom.subjectPredicate return-type narrowing and the mod.ts WrappingSet export (including the non-events portion of its WrappingSet JSDoc). The event-emission machinery itself (on/off, listener registry, notifying dataset) is intentionally not included here and remains for follow-up PRs.

Review timing: This draft was prepared with Claude; I (@jeswr) will personally review it before it progresses. I'm currently batching a lot of work in flight, so expect active review Wednesday-Friday (8-10 July).

…Set<T>

WrappingSet is the concrete type behind every set-mapped model property,
but it was internal, so its type could not be named by consuming code and
SetFrom.subjectPredicate could only advertise the plain Set<T> interface.

- Export WrappingSet from mod.ts
- Narrow SetFrom.subjectPredicate's return type from Set<T> to
  WrappingSet<T> (non-breaking: WrappingSet implements Set<T>)
- Document the WrappingSet class and constructor
- Test that set-mapped model properties are WrappingSet instances

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant