biati-digital / glightbox

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
MIT License
2.03k stars 228 forks source link

Add @types/Glightbox #405

Closed tomasvn closed 1 week ago

tomasvn commented 1 year ago

Please describe the feature you want to be implemented.

Add types for the package

gingerchew commented 1 year ago

Hey there @tomasvn

Currently, adding things like types or other typescript adjacent things isn't a high priority.

That said, if you are able to get the ball rolling, I'd be more than happy to help out/check your work.

tomasvn commented 1 year ago

@gingerchew Hi, I am not that well versed in TS, but I can try it.

gingerchew commented 1 year ago

If you want, we can start at creating types/interface for the config object (I imagine that's what people would want typing for the most) and then work from there.

tomasvn commented 1 year ago

@gingerchew this is my draft for DefinitelyTyped package or the types should be here in the main repo?

TS playground

gingerchew commented 1 year ago

That's a good question, I'm leaning towards just adding an index.d.ts file to the root. @biati-digital what are your thoughts?

gingerchew commented 1 year ago

@gingerchew this is my draft for DefinitelyTyped package or the types should be here in the main repo?

TS playground

The typescript in the link you gave looks good to me, I wonder if there's a way to get the types from Plyr so that we don't need to constantly update our own in parallel. (This may be wishful thinking though)

tomasvn commented 1 year ago

Install plyr types as peerDep? So plyr options could be imported?

gingerchew commented 1 year ago

I couldn't find a @types package for plyr or a .d.ts file. So we may be in between a rock and a hard place.

I'm also leaning away from peerDeps, I see them causing more trouble than benefit (maybe biased by personal experience.)

tomasvn commented 1 year ago

I did find them, but it seems that is has different options https://github.com/sampotts/plyr/blob/master/src/js/plyr.d.ts

411 - Draft PR

gingerchew commented 1 year ago

You can actually pass the plyr config to glightbox,the ones documented here are just the ones you're most likely to use.

rokozeit commented 1 year ago

Hi, I am rather new to Angular and TypeScript. I found this library and it is exactly what I need. However, for using it I would need the types. Can you tell me if this is provided soon or give me some information on how to include the types definition into a Angular project?

tomasvn commented 1 year ago

@rokozeit There is an opened PR that is still in progress

gingerchew commented 1 year ago

@rokozeit https://github.com/biati-digital/glightbox/pull/411 you can find our WIP pr here. what is there should cover you or at least give you a reasonable head start