fix: align TypeScript types with native bindings - #115
Merged
lukaszkurantdev merged 1 commit intoAug 3, 2026
Merged
Conversation
Correct four places where the published TS types disagree with the library's own native argument parsing, verified against the C++ source. - Mat.create: make rows/cols/dataType required (native reads args[0..2] unconditionally in MatFactory.cpp; calling with no args segfaults). - getPerspectiveTransform: type src/dst as Point2fVector (native reads asPoint2fVectorPtr in FOCV_Function.cpp; PointVector throws at runtime). - Mat.saveToFile: type the format and compression params (native reads path/format/compression in MatDelegate.cpp). - saveToFile native guard: change `count < 4` to `count < 3` so a correct 3-argument call no longer throws (handler only reads args[0..2]).
lukaszkurantdev
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four places where the published TypeScript types disagree with the library's own native (C++/JSI) argument parsing. Each fix is verified against the repo's own native source on
main; these were not runtime-tested on a device.1.
Mat.create— required params typed as optional (segfault)cpp/structures/mat/MatFactory.cpp:13-15readsargs[0].asNumber(),args[1].asNumber(),args[2].asNumber()unconditionally (the data argument is guarded bycount > 3at line 21, but rows/cols/type are not).static create(rows?: number, cols?: number, dataType?: DataTypes, data?: number[])insrc/objects/Objects.ts.Mat.create()with fewer than 3 args, which reads non-existent JSI arguments and segfaults.rows,cols,dataTyperequired; keepdata?optional.2.
getPerspectiveTransform— wrong vector typecpp/FOCV_Function.cpp:1221-1222readsargs.asPoint2fVectorPtr(1)/asPoint2fVectorPtr(2)for src and dst.src/dsttyped asPointVectorinsrc/functions/ImageProcessing/ImageTransform.ts.PointVectorthrowsArgument is not a Point2fVectorat runtime.src/dstasPoint2fVectorand update the type import.3.
Mat.saveToFile— missing paramscpp/structures/mat/MatDelegate.cppreadspath = args[0](string, line 100),format = args[1](string, must be"jpeg"or"png", line 107),compression = args[2](number 0..1, line 110).saveToFile(path: string): voidinsrc/objects/Objects.ts.pathand fail native validation.saveToFile(path: string, format: 'jpeg' | 'png', compression: number): void.4.
saveToFilenative arg-count guard is off by onecpp/structures/mat/MatDelegate.cpp:93guards withif (count < 4)but the handler only readsargs[0..2](3 args).saveToFile requires 3 arguments: path, format, compression.if (count < 3).Verification
Verified against the repo's native source (not runtime-tested).
yarn typecheckandyarn lintpass locally; the lefthook pre-commit hook (types, lint, commitlint) passed on commit.