找不到类型定义
Type definition not found
我开始将 VS Code 与 expressJs 结合使用。我决定使用 Route.use 函数将路由拆分到不同的文件中。
在新文件中,我想让 intellisense 向我建议应用程序参数中的所有方法,因此我添加了 /**@param type {Express} app */
jsdoc。关键是 Intellisense 无法找到类型定义。我需要做什么才能让它找到 Express 的类型定义?
这是我写的代码:
///<reference path="../../node_modules/@types/express/index.d.ts"/>
/**@param {Express} app */
module.exports=function(app){
app.get('/testRoute',function(req,res){
res.send('Hi, I\'m just a simple test');
});
};
Automatic typings acquisition 应该会自动为普通 import
选择那些类型
或 require
语句,所以通常你不应该再写 /// reference path=
.
试试这样的:
import express from 'express';
module.exports = function (/** @type {express.Express} */ app) {
app.get('/testRoute', function (req, res) {
res.send('Hi, I\'m just a simple test');
});
};
目前在使用 require
时存在一个错误,会阻止类型 IntelliSense 正常工作。 This TypeScript issue 跟踪可能的解决方案
我开始将 VS Code 与 expressJs 结合使用。我决定使用 Route.use 函数将路由拆分到不同的文件中。
在新文件中,我想让 intellisense 向我建议应用程序参数中的所有方法,因此我添加了 /**@param type {Express} app */
jsdoc。关键是 Intellisense 无法找到类型定义。我需要做什么才能让它找到 Express 的类型定义?
这是我写的代码:
///<reference path="../../node_modules/@types/express/index.d.ts"/>
/**@param {Express} app */
module.exports=function(app){
app.get('/testRoute',function(req,res){
res.send('Hi, I\'m just a simple test');
});
};
Automatic typings acquisition 应该会自动为普通 import
选择那些类型
或 require
语句,所以通常你不应该再写 /// reference path=
.
试试这样的:
import express from 'express';
module.exports = function (/** @type {express.Express} */ app) {
app.get('/testRoute', function (req, res) {
res.send('Hi, I\'m just a simple test');
});
};
目前在使用 require
时存在一个错误,会阻止类型 IntelliSense 正常工作。 This TypeScript issue 跟踪可能的解决方案