Issue with Typescript
See original GitHub issueI have been following this documentation(https://github.com/TwilioDevEd/api-snippets/blob/master/rest/access-tokens/video-example/video-example.3.x.js) to generate a auth token.
Using "twilio": "^3.19.1"
with "@types/twilio": "0.0.9",
seems like the VideoGrant
is unavailable and the Typescript and AccessToken.toJwt()
requires a String parameter which is not necessary.
I ended up doing the following, but it would be nice to fix these.
Version: ^3.19.1
Code Snippet
const VideoGrant = require('twilio').AccessToken.VideoGrant;
//...
res.json({ jwt: token.toJwt('HS256') });
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Issues · microsoft/TypeScript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issues · microsoft/TypeScript.
Read more >7 really good reasons not to use TypeScript - everyday.codes
Everyone loves TypeScript. It “solves” many problems JS has, it is a “superset” of JS, it will make your code error-prone and pleasant...
Read more >The Trouble with TypeScript
TypeScript is Noisy. As in it has a higher noise to signal ratio. Less of the code you are looking at is functional....
Read more >Common TypeScript module problems and how to solve ...
Without configuring the TypeScript compiler as discussed earlier, TypeScript will adopt the Node.js run-time resolution strategy by default in ...
Read more >Problems with TypeScript
TypeScript's major weakness is that it doesn't want to break away from Javascript. That strict dedication to being a superset means the type ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome.
For those of you who want to define the type for the
client
too, this is what I did:and now you’ll have nice autocompletion:
Hey folks,
Yes we silently released TS bindings with the latest release and definitely require feedback with this 😃
@Crazometer your comment is correct. I made that decision because of the way that the Twilio lib is written I had to decide between
twilio
being a function or a class. The recommended way to use it right now is (as per TypeScript documentation for libs written in such a way)The first two examples are both from the old library. Since version 3.X TwiML is nested under
twiml
and specific to the type likeVoiceResponse
,MessagingResponse
andFaxResponse
:Note There is a known issue where right now you have to pass options to the respective TwiML methods. I hope it gets fixed soon. The code snippet above is also depending on a PR being merged that fixes a few of these issues.
For the AccessTokens, they are now under
jwt
nested since version 3.X and I open a PR to make the algorithm optional. Then this should work:I hope this helps and your feedback is definitely wanted and helpful 😃