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

Twilio client is of type of any when using Twilio import in typescript #935

Open
sattarab opened this issue May 31, 2023 · 4 comments
Open
Labels
type: bug bug in the library

Comments

@sattarab
Copy link

Issue Summary

When using Twilio v4 library the Twilio client is of type any.

Steps to Reproduce

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

the type of twilio_client is any in version 4 whereas in version 3 it used to be the correct type i.e. TwilioClient.

Code Snippet

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

Technical details:

  • twilio-node version: v4
  • node version: v14.17.3
@charan678
Copy link

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@charan678 charan678 added the type: bug bug in the library label Jun 2, 2023
@jfbaquerocelis
Copy link

Hi everyone!

I started to face the same issue when I updated the twilio library from v3.x to v4.x:

  import twilio from 'twilio';

  const accountSid = process.env.TWILIO_ACCOUNT_SID;
  const authToken = process.env.TWILIO_AUTH_TOKEN;
  const client = twilio(accountSid, authToken, { accountSid: subaccountSid });

But the linter show me this rule error:

Unsafe assignment of an any value. eslint(@typescript-eslint/no-unsafe-assignment)

Technical details:

twilio-node version: v4.19.0
node version: v16.18.0

@leangl
Copy link

leangl commented Dec 20, 2023

Adding the following to my tsconfig.json fixed the issue

"compilerOptions": {
  "esModuleInterop": true
}

@RobWelbourn
Copy link

RobWelbourn commented Jun 11, 2024

My somewhat less-than-elegant workaround was to do this:

import twilio from 'twilio';

const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const accountSid = process.env.TWILIO_ACCOUNT_SID;

if (apiKey && apiSecret && accountSid {
    const client=new twilio.Twilio(
        apiKey, 
        apiSecret, 
        { accountSid }
    )
}

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

No branches or pull requests

5 participants