lib-jitsi-meet icon indicating copy to clipboard operation
lib-jitsi-meet copied to clipboard

Conversion of Resolutions to typescript (and named export)

Open garyhuntddn opened this issue 2 years ago • 7 comments

garyhuntddn avatar Mar 14 '22 16:03 garyhuntddn

Hi, thanks for your contribution! If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

jitsi-jenkins avatar Mar 14 '22 16:03 jitsi-jenkins

Jenkins please test this please.

saghul avatar Mar 14 '22 16:03 saghul

@garyhuntddn Currently as you have declared the IDE gives this suggestion. image

However you could change it so to alias each individual member to Resolution giving a suggestion that enumerates the object keys image

My two cents.

NewEraCracker avatar Mar 18 '22 14:03 NewEraCracker

Weird - my reply by email whilst I was on hols didn't get to you.

@NewEraCracker - I agree with what you are saying and that it's better to have the intellisense there.

I'd originally tried something similar as I want enum semantics but with a Resolution rather than string value (something that typescript doesn't support as far as I am aware)

I've just pushed an update which attempts to satisfy both requirements (ensuring that all member properties are of type Resolution and that the intellisense works well) - see what you think.

If anybody knows better type manipulation that can do this is a better way then please make a suggestion - I'm sure there is a better way but I can't seem to find it

garyhuntddn avatar Mar 21 '22 09:03 garyhuntddn

Cracked what I was trying to do - we now have a type ResolutionsMap which means that any member of resolutions must be of type Resolution without the need to use as Resolution which I consider a bit dangerous (and not very DRY)

garyhuntddn avatar Mar 21 '22 09:03 garyhuntddn

Jenkins please test this please.

saghul avatar Mar 29 '22 20:03 saghul

Yeah - I wanted enum semantics and also to constrain that each element was a Resolution. But enums in typescript can only be strings or numbers not objects :-(

I agree that the intellisense is better off without the type constraint.

The current usage across the other modules is to pass in a string but I wander if I can improve that with the use of keyof? Worth a try isn’t it.

The other complication is that the entries are strings containing numbers which was limiting what I could pull off.

Let me see if I can do a bit of type voodoo and export a constant that is both a map of string and also the known set of keys and therefore get the best of both worlds.

Sent from my iPhone

On 18 Mar 2022, at 15:17, Jorge Oliveira @.***> wrote:

 @garyhuntddn Currently as you have declared the IDE gives this suggestion.

However you could change it so to alias each individual member to Resolution giving a suggestion that enumerates the object keys

My two cents.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

garyhuntddn avatar Oct 11 '22 09:10 garyhuntddn