-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
2 - S (<= 1 week)
-
4720
Problem
Recently, I was working through this blog post and went through the exercise of creating a custom context and hook for accessing Atlas data (read: exposing a Realm.Services.MongoDB type), however that particular type is not exported.
Upon further investigation (h/t @nlarew), it seems we are a bit inconsistent between realm and realm-web – while no service types are exported in web there are a few that are in the node/react-native package:
import Realm from "realm"; type Document = Realm.Services.MongoDB.Document // Works type DB = Realm.Services.MongoDB.MongoDBDatabase; // Error: Namespace 'Realm.Services.MongoDB' has no exported member 'MongoDBDatabase' type Collection<T extends Document> = Realm.Services.MongoDB.MongoDBCollection<T> // Works
Solution
Export the various service types and its related concepts (for instance, the typings for all the various mongo collection operations are very robust but private)
I haven't been as current with Typescript these days as I'd like so I won't pretend to have a strong opinion here on whether named exports or namespaced types are more ergonomic for this use-case. (I think I typically skew named exported but /shrug)
How important is this improvement for you?
I'd like to see it, but have a workaround