-
Notifications
You must be signed in to change notification settings - Fork 215
Typescript plans? Need help? #217
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
Comments
Hi @jskrzypek,
This is something @manjeshbhargav and I have talked about often. Yes, we'd like to!
Nice 👍 Mind linking it? Others may find it helpful.
Yes, it's on the table. We've planned the migration in pieces, roughly
Challenges
Short-term Alternatives Short of fully converting to TypeScript, we could also consider maintaining some declarations ourselves. We might have some of the same challenges as above WRT API contracts. @jskrzypek any input from your or the community would be great 👍 |
Hey @markandrus I'm glad to hear that you guys are interested in the switch. I have some comments/feedback on your reply, I'll lay them out inline.
Sure, I'll try to throw up a gist this week sometime.
This definitely comes in handy and it can be good to help maintain a common style across the company.
That's an interesting idea. So the there would be to have the un-converted files just use the compiled output of the converted ones?
You can also leave these as-is. Tests don't strictly need to be in
This is actually the easy part, when you run the typescript compiler, it produces the declarations for you, and then you simply include a
Actually I believe this is not so difficult to do, as long as you commit the compiled code along with the git. It does perhaps get tricky to ensure that the One of easier ways I can imagine to do this that would be to implement a sort of nightly/mini-release process where you make a chore commit with the compiled code at that state. You can use a specific format for the commit message and also tag it so it is easy to reference directly. For the rest of the commits you don't worry about obeying this contract.
Good point & counterpoint. I think there is something to be said for a version bump/breaking change, lots of projects have turned the switch to TS into an opportunity for a major version change with a breaking of previous contracts. That question specifically seems like one you need to answer internally as also involves thing like customer eduction, internal APIs, and branding. I do think that since the native SDKs have jumped to 2, it could make sense to follow suit for a TS refactor, even if you do keep the same APIs, simply to signal that the library is taking a somewhat different direction. The other consideration of being stuck with a specific contract for the whole lib is not actually the case as long as you type your library correctly. You can have your whole project be strongly typed without tight coupling between internal and external classes. The way to maintain this separation is to create interfaces containing the public methods and properties you want consumers to use. If you consume/re-export the interfaces from the public-facing classes & modules, then you don't expose the internal/private classes that implement those interfaces. Given that, as long as the public contract of the interfaces are kept, the internal classes and APIs can change as much as you want. As another thought on that topic, it could even make sense to do this for the public-facing classes/APIs first, as this you might help ensure a separation of concerns for the public and private APIs of the library, since the interfaces would simply describe the contract fulfilled by the internal javascript components.
This is potentially a challenge, agreed. But I think it's one that the whole community is having to deal with. One alternative could be to provide additional declaration files compiled against older TypeScript versions, but that's probably just additional work for little-to-no reward. If this is a concern for consumers of twilio-video.js, it would make more sense to simply compile the whole lib against an older typescript version and publish that, as the compiler is supposed to be compatible with older declarations, even if the declarations don't work with older compilers.
This should be relatively easy to do, given your extensive use of jsdoc, and I'll be happy to donate my declarations to the effort if desired. |
related: twilio/twilio-node#250 (comment) |
Thanks, @omidkrad—I've started attempting the mostly mechanical translations on another branch. I realized that at least one of the lebab transforms, |
That's great @markandrus. If you are using vscode, the ">Format Document" command may come handy. 😉 Also I've noticed lebab will recognize class inheritance from |
@jskrzypek Care to share your typings? I'd love to slap a few in my project. Until then, here's a starter. This was just the minimum to cover the API surface area I was using; I'm sure yours are more complete 😀 |
Hi guys, we also use TypeScript and I was a bit annoyed that this library had none. I have just created @types/twilio-video and I am constantly keeping an eye and updating the types. For now it works quite well and it was not so difficult to create typings, as the documentation in https://media.twiliocdn.com/sdk/js/video/releases/2.0.0-beta1 is quite good. I just focused on twilio video 2.0, sorry! I also encourage the twilio team to create their own typings in this library, as it really was not a big deal after looking the docs. Hope it helps! |
Hey @alalonde here's what I have for an older version, I think 1.10.0. Sorry for the delay 🙏 https://gist.github.com/jskrzypek/b6478881fc3bda887c60c9b37a1245c7 @darioblanco if you want to take these and use them in a pr/maintain them definitely feel free |
@darioblanco I did the following:
|
@absin1 Are you installing the twilio Can you try if it works for you with 2.x? Edit: oh! i see that @jskrzypek created some types, I will take a look and see how they can be integrated |
any update on this? I am also getting the webpack_require (bootstrap:78) error (actually for me it's at line 83) To add some info to this, I currently do have it working with Angular 5 (so thus TypeScript) and ng-bootstrap 1.1.2. When I tried upgrading to Angular 7 and ng-bootstrap 4 it broke. Any help would be greatly appreciated! |
Which version of You should do |
Regarding the types for V1, if you want to add them (for instance in a namespace called Just an MR and I would be happy to review or contribute. I sadly don't have much time to test the V1 types :( |
@darioblanco I have actually resolved the issue by adding the following to my polyfills.ts:
After adding that line Twilio Video once again works as expected. Thanks for your help! |
@darioblanco you and @minddocdev @ktsn are the true MVPs on this one. Thanks for making the dev process that much faster for me/my team. |
Uh oh!
There was an error while loading. Please reload this page.
@markandrus I noticed in #136 that you mentioned you may be planning to move to typescript at some point. I am thrilled to hear it!
I've been maintaining a twilio-video declaration file for use in our angular apps as we go along, building off of your jsdoc comments (I was actually in the process of updating it when I stumbled across your comment in #136).
I am curious, is the typescript thing still on the table and do you have a timeline for when you might switch? (I'm certainly eager for it since it would mean that we get our declarations out of the box rather than ad-hoc 😄).
If I can be of any help with the rewrite, please let me know!
The text was updated successfully, but these errors were encountered: