MostafaMDZH/Awesome-Image-Viewer

TS error: Property 'index' comes from an index signature

Opened this issue · 2 comments

Hey there,

thanks for this simple and easy to use image viewer! I found one issue with the package added to my Angular 16 project which is the following error message:

Error: node_modules/awesome-image-viewer/src/imageViewer.ts:265:43 - error TS4111: Property 'index' comes from an index signature, so it must be accessed with ['index'].

265                 const index = tar.dataset.index;
                                              ~~~~~


Error: node_modules/awesome-image-viewer/src/imageViewer.ts:290:44 - error TS4111: Property 'url' comes from an index signature, so it must be accessed with ['url'].

290         const url = imageContainer.dataset.url;
                                               ~~~

The workaround right now is to just edit the tsconfig.json:

"compilerOptions": {
  "noPropertyAccessFromIndexSignature": false,
}

However, would be nice to change replace those lines.

Hi @RaminGe
Happy to see it's useful for you, I'll check the error soon.
Thanks for your feedback. ✌✌✌

@MostafaMDZH I have created a small PR to address this issue :) Might look into #3 if I have time