new Twilio(accountSid, authToken) 给出 "Only a void function can be called with the 'new' keyword" 错误

new Twilio(accountSid, authToken) gives "Only a void function can be called with the 'new' keyword" Error

我正在将 Twilio 节点从 2.x 升级到 3.x this guide.Twilio 我系统中的当前版本是 3.6.3 并且输入 Twilio(@ types/twilio) 是 0.0。9.I 在我的代码中导入了 twilio 作为

import * as Twilio from "twilio";

在 2.x 中,Twilio 的新实例创建为

const twilio=new Twilio.RestClient(accountSid, authToken);

然而这在 3.x 中不起作用。当我控制台登录 twilio 时,没有任何内容被打印出来,而且我也没有得到教程中提到的任何 error.As,我尝试使用

const twilio=new Twilio(accountSid, authToken);

这显示了以下错误,

 Only a void function can be called with the 'new' keyword.
'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.

Similar question 没有答案。 这个问题是因为 Twilio(@types/twilio) 的打字没有更新以支持版本 3.x 吗?(我也无法在打字中找到方法 fetch()) .

我认为这个问题是因为 Twilio (@types/twilio version:0.09) 的类型与 Twilio 3.x.

不兼容

Twilio 打字功能请求 3.x :- https://github.com/twilio/twilio-node/issues/250

相关问题:- https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18992