Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get Twilio class type? #913

Closed
jgeurts opened this issue Feb 8, 2023 · 7 comments · Fixed by #914
Closed

How to get Twilio class type? #913

jgeurts opened this issue Feb 8, 2023 · 7 comments · Fixed by #914
Labels
status: help wanted requesting help from the community type: bug bug in the library

Comments

@jgeurts
Copy link

jgeurts commented Feb 8, 2023

Issue Summary

With v3.84, we were able to pull in the type of the Twilio client and reference it in our application:

import { Twilio } from 'twilio';

export async function doSomething(twilioClient: Twilio) {
  const message = await twilioClient.messages.create({ ... });
  console.log(`Success: ${message.sid}`);
}

However, now with v4.7, the same code not longer works, with the following message:

error TS2749: 'Twilio' refers to a value, but is being used as a type here. Did you mean 'typeof Twilio'

However, typeof Twilio does not work and is not what we're looking for. We are looking to reference an instance of the Twilio class. Any advice on how to do this with v4?

@jgeurts jgeurts changed the title How to get Twilio type? How to get Twilio class type? Feb 8, 2023
@alexander-reyes-wainwright

We've also just found this on a new project when attempting to use [email protected] - seems like the twilio client type definition isn't exported, or is exported incorrectly, compared to [email protected].

Seems like it either:

needs to be fixed at the typing itself
or
needs a new example on how to define typescript types properly for the new way of instantiating the twilio client if that has drastically changed.

@aaronhuggins-carewell
Copy link
Contributor

We also found this to be an issue on upgrading one of our projects. I've submitted #914 which should fix this.

@JenniferMah JenniferMah added type: bug bug in the library status: help wanted requesting help from the community labels Feb 10, 2023
@JenniferMah
Copy link
Contributor

Hi @jgeurts! Thank you for bringing this to our attention and thank you @aaronhuggins-carewell for opening a PR to solve this bug! Our team will review #914 and we will update this issue with the expected release date for the next version of the twilio-node library that will include a fix.

@aaronhuggins
Copy link

@JenniferMah Thanks! I'll run Prettier in the AM and push. Should otherwise be ready for review.

@aaronhuggins-carewell
Copy link
Contributor

@JenniferMah Corrected style formatting. Everything appears to pass locally running npm run ci. I had only run jscs and test before.

@Hunga1
Copy link
Contributor

Hunga1 commented Feb 14, 2023

Thanks again, @aaronhuggins-carewell for opening a PR (#914) to solve this issue. I've gone ahead and merged your changes. These changes will be included in our next version release of the library, expected on February 22nd.

@sattarab
Copy link

sattarab commented May 29, 2023

when doing

import { Twilio } from "twilio/lib"
const twilio_client = new Twilio( <SID>, <AUTH> )

the type of twilio_client is any in version 4 where as in version 3 it used to be of the correct type. Please do let me know if I am doing something wrong here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants