Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-103603

Support .d.ts typings for common "conn" and "db" variables

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Correctness
    • Correctness 2025-04-29
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Many JS tests do something like the following:

      const conn = MongoRunner.runMongod();
      const db = conn.getDB("test");
      const coll = db.getCollection(jsTestName());
      assert.commandWorked(coll.stats())
      coll.drop();
      

      But since the IDE can't put together what type the initial conn variable is (becomes an "any" or even a "never" due to overrides), the rest can't get any helpful hints from .d.ts type files.

      This might be a limitation of not having well-scoped variables (global, not using exports, etc), but some mitigation may exist to help provide devs with better UX without a large amount of churn (redesign!) to the system.

      Ideally, solutions should extend beyond just these two variables, or to at least demonstrate an example for others to follow suit.

            Assignee:
            steve.mcclure@mongodb.com Steve McClure
            Reporter:
            steve.mcclure@mongodb.com Steve McClure
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: