新的Twilio(accountSid,authToken)给出“只能使用'new'关键字调用void函数”错误

时间:2017-08-22 08:38:24

标签: twilio twilio-api

我正在使用this指南将Twilio节点从2.x升级到3.x.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时,没有任何内容被打印出来,而且我没有得到任何错误。正如教程中提到的,我尝试使用

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吗?(Iam也无法在打字中找到方法 fetch()

1 个答案:

答案 0 :(得分:1)

我认为这个问题是因为Twilio(@ types / twilio版本:0.09)的类型与Twilio 3.x不兼容。

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

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