twilio-node icon indicating copy to clipboard operation
twilio-node copied to clipboard

Broken typescript definitions for twiml

Open controversial opened this issue 6 months ago • 1 comments

The type definitions that ship for TwiML classes should say what types the methods return, rather than specifying any, which is useless for type checking.

Image

In the following example:

const message = new twilio.twiml.MessagingResponse();
const markup = message.toString();

the type of markup is any, rather than string, which makes the value useless for type checking.

Typescript projects using typescript-eslint will struggle to use this value:

const myTwiml = new twilio.twiml.MessagingResponse();
const markup = myTwiml.toString();
return new Response(markup, { headers: { 'Content-Type': 'text/xml' } });

eslint will raise:

error  Unsafe assignment of an `any` value                                                          @typescript-eslint/no-unsafe-assignment
error  Unsafe argument of type `any` assigned to a parameter of type `BodyInit | null | undefined`  @typescript-eslint/no-unsafe-argument

controversial avatar May 30 '25 16:05 controversial

Thanks for raising the issue. We will check this

manisha1997 avatar Jun 03 '25 08:06 manisha1997