Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories MongoDB Shell
Created by Segev Finer
Created on Oct 26, 2025

Add a global types package for use in MongoDB Shell js scripts

What problem are you trying to solve?

Focus on the what and why of the need you have, not the how you'd like it solved.

When writing MongoDB Shell js scripts, I want to have autocompletion, and possibly type checking, by utilizing TypeScript types in js files (Or in the future, in ts files, when supported by mongosh, via for example tsx)

There currently exists @mongosh/shell-api, through the types in it are not clearly documented, and the global stuff that mongosh defines in js scripts or in the REPL are not defined there. e.g. db, connect, Mongo, and so on

What would you like to see happen?

Describe the desired outcome or enhancement.

Add a TypeScript declarations file (d.ts) that can be used in js/ts via /// <reference types="@mongosh/shell-api/globals"> for example that will define all such globals. By installing the package and just adding this comment to your scripts, or utilizing types in [jt]sconfig.json , you can then have types auto completion (And checking if you also add @ts-check to js files, or enable checkJs in [jt]sconfig.json).

Why is this important to you or your team?

Explain how the request adds value or solves a business need.

Will make it easier to develop or play around with js scripts for mongosh. And considering that the hard part of writing types is already mostly done it shouldn't be too difficult to add (and document, otherwise no one will know that it exists, I had to dig in the mongosh code to find that package)

What steps, if any, are you taking today to manage this problem?

Leaving without types in mongosh js scripts. Or later trying to create my own global definitions file for this.