microsoft / microsoft/TypeScript

VS Code doesn't show autocomplete for Mongoose MongoDB operators (like $elemMatch, $match,$gte and ...) in JavaScript, while WebStorm does

Open
#61,666 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Completion Lists Experience Enhancement Help Wanted Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### Problem

When working with Mongoose in JavaScript (not TypeScript), VS Code does not show autocomplete suggestions for common MongoDB operators like `$inc`, `$eq`, `$ne`, etc.

However, when using WebStorm, these suggestions appear as expected.

### Example

```js
const result = await User.find({
$or: [
{ userName: { $elemMatch: { name: "Mehdi" } } },
{ age: { $gte: 18 } }
]
});
```
In the above example, $or doesn't appear in suggestions while typing in VS Code, but it does in WebStorm.

What I Know
I understand that VS Code relies heavily on TypeScript's language service for JavaScript intelligence.

But since this is a common pattern in many Node.js/Mongoose applications, I'm wondering:

Is there a way to configure VS Code (via jsconfig.json, type acquisition, or something else) to provide better autocomplete for these $ MongoDB operators in plain JavaScript files?

Environment
VS Code: latest

Language mode: JavaScript

Mongoose version: latest

Node.js version: 21

OS: Windows

Thanks for the awesome editor 🙌

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the missing suggestions in a plain JavaScript file using the Mongoose query from the issue. Investigate the mentioned jsconfig.json, type acquisition, and TypeScript language service behavior; done means establishing whether configuration or language-service support can provide MongoDB operator completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js, typescript
Domain
backend, databases, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.