Closed nirvdrum closed 2 years ago
Thanks for reporting this @nirvdrum. There is indeed an issue there caused by how Typescript tries to narrow inferred types, which is also not specific to RxDB 11. It will be fixed by #41, but I will have to settle on a travis ci alternative before merging, so it's not 100% ready yet.
Issue should be fixed in 4.0.1
.
I'm just getting started with RxDB and have run into a very similar issue to #14. Given how much RxDB and its TypeScript support has changed since then, I can't say for certain that they're the same issue. If they are, please feel free to merge the issues.
Following the RxDB TypeScript docs, the
createRxDatabase
call will return a typed instance of a specific database (e.g.,MyDatabase
in the linked page). This type is not equivalent toRxDatabase
and as such, can't be supplied as thedb
prop on rxdb-hook'sProvider
. Instead, you get a type error like:I've worked around it locally by just ignoring the type:
That's enough to get most of the hooks working. However, the
useRxDB
hook will not return a reference typed asMyDatabase
, so you can't do much with the reference without type casting.