Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-1781

Allow SDK types to be imported and used

      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:

      Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: