X Tutup
Skip to content

Types - Add undefined for EmblaPluginsType members.#1293

Open
tetarchus wants to merge 2 commits intodavidjerleke:masterfrom
tetarchus:master
Open

Types - Add undefined for EmblaPluginsType members.#1293
tetarchus wants to merge 2 commits intodavidjerleke:masterfrom
tetarchus:master

Conversation

@tetarchus
Copy link

Adds undefined to plugins returned by the api.plugins() function.

This ensures that the types are more accurate as a typescript will currently list a plugin as a definite value returned by the plugins() function if its module is imported (due to interface merging), however if it is not passed to the embla carousel, it will fail at runtime due to that plugin not being loaded.

The documentation for calling functions on the plugin uses optional chaining to get around this, however lint rules such as @typescript-eslint/no-unnecessary-condition will flag this as not required, and typescript will not alert that this is required - this change will resolve both issues and bring the types in-line with suggested usage to allow editor hints.

@davidjerleke davidjerleke added the typescript Issue is related to TypeScript label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Issue is related to TypeScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup