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 个 reaction 已指派 0 人 在 GitHub 查看
Domain: LS: Completion Lists Experience Enhancement Help Wanted Suggestion
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
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 摘要。