Skip to content

Fix "elements" type to accept array instead of only an empty tuple (or null)#572

Open
TomNaessens wants to merge 1 commit intobiati-digital:masterfrom
TomNaessens:patch-1
Open

Fix "elements" type to accept array instead of only an empty tuple (or null)#572
TomNaessens wants to merge 1 commit intobiati-digital:masterfrom
TomNaessens:patch-1

Conversation

@TomNaessens
Copy link
Copy Markdown

Hi, 👋

I've encountered an issue when assigning an array of elements to the GLightbox.Options:

TS2322: Type ImageObject[] is not assignable to type []
  Target allows only 0 element(s) but source may have more.

The cause is that the type of elements?: [] | null accepts an empty array, or null, while we want to accept any array (or null), so it should have been any[] | null. I've used any[] here since the types of the helper methods on elements (setElements and getElements) also accept any[] as types.

`[] | null` accepts an empty array, or null, while we want to accept any array (or null): `any[] | null`
@TomNaessens TomNaessens marked this pull request as ready for review November 5, 2025 09:29
@TomNaessens TomNaessens changed the title Fix "elements" type to accept array Fix "elements" type to accept array instead of only an empty tuple (or null) Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant