我是 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;
}
Run Code Online (Sandbox Code Playgroud)
我应该使用 any 还是不打字?