我使用WebStorm,并编写了一个nodeJS应用程序。
启用节点js支持('Node.js核心库已启用‘选项)
导入并启用definitelyTyped: node-DefinitelyTyped
(.WebStorm2016.2/config/javascript/extLibs/http_github.com_borisyankov_DefinitelyTyped_raw_master_node_node.d.ts)
例如,我想要http.ServerResponse
的智能
在.d.ts文件中,我有如下内容:
declare module "http" {
//...
export interface ServerResponse extends events.EventEmitter, stream.Writable {
//...
writeHead(statusCode: number, headers?: any): void;
//...
}
}
现在我想在我的js代码中获得方法自动编译:
/**
* @param {http.ServerResponse} response such jsdoc does not work, what type is it?
*/
function handleResponse(response){
response.writeHead(200); //here i want the autocompletion
}
问题:如何记录js /使用.d.ts来获得正确的代码完成?
发布于 2018-12-08 01:02:59
您忘记了参数(Response)。
/** * @param {http.ServerResponse} response Now it should work */ ...
发布于 2019-05-15 03:44:46
试一试
/**
* @param {module:http.ServerResponse}
*/
https://stackoverflow.com/questions/38225745
复制相似问题