TechStark / opencv-js

OpenCV JavaScript version for node.js or browser
https://npmjs.com/@techstark/opencv-js
Apache License 2.0
408 stars 36 forks source link

Correct TypeScript signature for `minEnclosingCircle` to match opencv.js single parameter #57

Closed th-alexmak closed 6 months ago

th-alexmak commented 6 months ago

This pull request corrects the TypeScript definition of the minEnclosingCircle function to align with the opencv.js implementation, which accepts only a single parameter. The existing type definitions mistakenly required three parameters to be passed to this function, which conflicted with the actual opencv.js API and led to compile-time errors in TypeScript projects.

The erroneous type signature forced TypeScript developers to call minEnclosingCircle incorrectly with three arguments or to suppress type checking with a @ts-ignore comment, neither of which is an ideal solution.

To address this issue, I have updated the function signature in the TypeScript definitions to accept only one parameter, as per the opencv.js documentation. Additionally, I have introduced a new Circle class definition that encapsulates the return type of minEnclosingCircle, providing a structured object that contains both the center point and radius of the circle.

The Circle class enhances type safety and developer experience by offering clear insights into the expected return object structure, which includes:

By merging this pull request, we will ensure that the TypeScript definitions correctly represent the opencv.js library's API, thus preventing any confusion and errors when developers invoke minEnclosingCircle. This change will also promote better code quality and maintainability in TypeScript projects leveraging opencv.js.

ttt43ttt commented 6 months ago

@th-alexmak thanks