Skip to content

fix(types): propagate Reactivity generic through RxDocument in query return types#8318

Merged
pubkey merged 2 commits intomasterfrom
copilot/fix-issue-8311-add-tests
Apr 10, 2026
Merged

fix(types): propagate Reactivity generic through RxDocument in query return types#8318
pubkey merged 2 commits intomasterfrom
copilot/fix-issue-8311-add-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

find(), findOne(), and findByIds() return RxDocument<RxDocumentType, OrmMethods> without the Reactivity generic, so doc.$$ and doc.field$$ resolve to unknown instead of the configured reactive type.

// Before: doc.age$$ is typed as `unknown`
const doc = await db.collection.findOne().exec(true);
const age: Signal<number> = doc.age$$; // TS error

// After: Reactivity propagates correctly
const age: Signal<number> = doc.age$$; // ✓

Changes

  • src/rx-collection.ts — Add Reactivity as third generic to all RxDocument<RxDocumentType, OrmMethods> usages across insert, bulkInsert, bulkRemove, bulkUpsert, upsert, incrementalUpsert, find, findOne, findByIds, insertCRDT
  • src/types/rx-query.d.ts — Propagate OrmMethods and Reactivity in all query chaining method return types (equals, eq, or, gt, regex, etc.)
  • src/rx-query.ts — Propagate generics through where, sort, skip, limit, asRxQuery, tunnelQueryCache
  • test/typings.test.ts — Add compile-time type tests for Reactivity propagation through findOne().exec(), find().exec(), findByIds().exec(), and query chaining

… and RxCollection (#8311)

- Add Reactivity to RxDocument in find/findOne/findByIds return types
- Add Reactivity to all RxDocument usages in rx-collection.ts
- Propagate OrmMethods and Reactivity in rx-query.d.ts chaining methods
- Propagate generics in rx-query.ts where/sort/skip/limit/asRxQuery
- Add typing tests for #8311

Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/004cd08c-2536-43cc-b8ca-7c7c1ff2c69f

Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com>
@pubkey pubkey marked this pull request as ready for review April 10, 2026 07:17
@pubkey pubkey merged commit a0fca1f into master Apr 10, 2026
22 of 24 checks passed
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.

2 participants