Visual studio 代码 - 跨 JS 模块的智能感知
Visual studio code - Intellisense across JS modules
在新的 VS Code 编辑器中,假设我有两个 javascript 文件 foo.js
和 bar.js
,其中 bar.js
包含:
module.exports.sayBar = function () {
console.log('bar')
}
在 foo.js
中,如果我键入 require('./bar').
并点击 ctrl+space
来激活智能感知,它不会检测到模块中的方法之一是 sayBar()
(我已经有了 VS Code 询问你是否要生成的默认 jsconfig.json
文件)。
是否有一些其他配置步骤可以为我编写的其他 JS 文件激活智能感知?我真的很喜欢 VS Express 中 C++ 项目的这个功能,它会导致 VS Code 将 Atom 完全从 IMO 中吹出来。
它确实适用于 CommonJS 模块。在您的示例中,它应该是:
exports.sayBar = function() {
console.log('bar');
};
或
module.exports = {
sayBar: function() {
console.log('bar');
}
};
在新的 VS Code 编辑器中,假设我有两个 javascript 文件 foo.js
和 bar.js
,其中 bar.js
包含:
module.exports.sayBar = function () {
console.log('bar')
}
在 foo.js
中,如果我键入 require('./bar').
并点击 ctrl+space
来激活智能感知,它不会检测到模块中的方法之一是 sayBar()
(我已经有了 VS Code 询问你是否要生成的默认 jsconfig.json
文件)。
是否有一些其他配置步骤可以为我编写的其他 JS 文件激活智能感知?我真的很喜欢 VS Express 中 C++ 项目的这个功能,它会导致 VS Code 将 Atom 完全从 IMO 中吹出来。
它确实适用于 CommonJS 模块。在您的示例中,它应该是:
exports.sayBar = function() {
console.log('bar');
};
或
module.exports = {
sayBar: function() {
console.log('bar');
}
};