【发布时间】:2019-04-02 18:13:22
【问题描述】:
我是 TypeScript 的新手,我不知道在调用库函数/方法时要使用什么类型。例如,我在我的 Node.js 项目中使用了 headless chrome 模块。
import puppeteer = require("puppeteer");
async function launchBrowser () {
const browser = await puppeteer.launch();
return browser;
}
// In this case I do not know the return type of the launch method. What should I do?
async function launchBrowser (): Promise<any> {
const browser: any = await puppeteer.launch();
return browser;
}
我应该使用 any 还是不用类型?
【问题讨论】:
标签: javascript node.js typescript node-modules