Skip to content

What typescript feature allows GenericSlide to gain more properties as you import more plugins? #351

Closed Answered by igordanchenko
minijoo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @minijoo,

Great question! The behavior you're seeing, where the GenericSlide type gains properties like title and description when you import the Captions plugin, is due to a TypeScript feature called module augmentation combined with declaration merging.

What's Happening?

In the yet-another-react-lightbox library, the GenericSlide type is designed to be extensible. When you import the Captions plugin (e.g., import Captions from "yet-another-react-lightbox/plugins/captions"), the plugin's type definition file (index.d.ts) augments the GenericSlide interface to include additional properties like title and description. This allows the type system to recognize these properties on your sli…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by igordanchenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants