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 ouverte le 6 mai 2025

Voir sur GitHub
 (4 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Domain: LS: Completion ListsExperience EnhancementHelp WantedSuggestion

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

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

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 🙌

Guide contributeur