Sec-ant / barcode-detector

A Barcode Detection API polyfill that uses ZXing-C++ WebAssembly under the hood.
https://www.npmjs.com/package/barcode-detector/v/latest
MIT License
100 stars 7 forks source link

Version range issue with @types/dom-webcodecs #120

Closed lebck closed 1 week ago

lebck commented 1 month ago

I'm using your library in an angular project which has currently pinned its typescript version to 5.4.5, since the later versions of typescript are not supported yet.

When I install the barcode-detector, the dependency @types/dom-webcodecs will be installed in the latest version 0.1.13 since it is marked with the ^0.1.8. This uses types not existing in typescript 5.4.5 breaking my compilation.

I just explicitly installed 0.1.8 in my project, but a better solution might be to pin your dependency version explicitly to 0.1.8 to support a broader range of typescript versions.

Sec-ant commented 1 month ago

Thanks for reporting, I'll look into this issue.

Sec-ant commented 1 week ago

I finally looked into this issue. The @types/dom-webcodecs is now pinned to 0.1.11 temporarily for the following reasons:

  1. According to the package's npm page, the tag names of 0.1.11 is ts5.2 to ts5.6, so it should work properly in your 5.4.5 project.
  2. This is the only issue that gives concerns about the version of @types/dom-webcodecs.
  3. Using overrides or pnpm.overrides is a trivial workaround on the consumer side to solve the problem.
  4. I plan to vendor the webcodecs types inside this package in the next major version as only two named types in @types/dom-webcodecs are related and actually used, so we can get rid of the unwanted side effects:
type CanvasImageSourceWebCodecs =
    | HTMLOrSVGImageElement
    | HTMLVideoElement
    | HTMLCanvasElement
    | ImageBitmap
    | OffscreenCanvas
    | VideoFrame;

type ImageBitmapSourceWebCodecs = CanvasImageSourceWebCodecs | Blob | ImageData;