microsoft / microsoft/TypeScript

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

オープン
#61,666 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
Domain: LS: Completion Lists Experience Enhancement Help Wanted Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 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 🙌

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、issue にある Mongoose クエリを使って、単純な JavaScript ファイルで不足している候補を再現します。言及されている jsconfig.json、型の取得、TypeScript language service の動作を調査します。完了の条件は、設定または language service のサポートによって MongoDB 演算子の補完を提供できるかどうかを明らかにすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, mongodb, node.js, typescript
領域
backend, databases, developer-experience
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。