sqlite-wasm
sqlite-wasm copied to clipboard
Declarations mismatch
sqlite3.vfs.installVfs({
io: {
methods: {
// \/ Should be bigint as bigint is actually passed
xRead(fid, dest, n, offset) {
...
}
}
}
})
Not sure about these, but
// Are named without $ in declarations, but it does not work without $
let vfs = new sqlite3.capi.sqlite3_vfs();
vfs.$iVersion = ...;
vfs.$mxPathname = ...;
vfs.$zName = ...;
vfs.$szOsFile = ...;
// And
let file = new sqlite3.capi.sqlite3_file();
file.$pMethods = ...;
Also there is no capi.sqlite3_file.structInfo in declarations, would be nice to have it.
Closing here as per the warning in the README, but @sgbeal FYI.
i looked at this when it was initially posted. The upstream project has nothing to do with "declarations" and type info - those are typescript-isms (or non-vanilla-JS-isms, in any case).
Oh, I see that now, sorry.
So for the first point, this seems to be declared as number here: https://github.com/sqlite/sqlite-wasm/blob/870dca9f29dc06d051e5f9ca656d942a31ea06f3/index.d.ts#L1719
The second point seems to be declared here: https://github.com/sqlite/sqlite-wasm/blob/870dca9f29dc06d051e5f9ca656d942a31ea06f3/index.d.ts#L1652-L1657
@qt-kaneko, since you seem to have looked into this already, are you in a position to suggest fixes?
@tomayac I came across this issue as well, and forked the repo with my fixes. PR here: #107
There's undoubtedly more examples of this missing $ but I couldn't find an easy way to find them all besides using all the APIs and noting where the expected behavior does not happen. Ideally the types would be generated upstream when the C types (or generated Emscripten types) are still known, but I couldn't find a way to do that either.
Not to mention that the symbols without the $ would be preferable for the sake of consistency with the more-detailed C API docs.
The $ are an artifact of the C-struct-to-JS wrapper. We "need" those in JS so someone reading/writing the code (🙋♂️) can unambiguously ensure that they're dealing with C-struct members instead of JS object properties. Without those $ it's simply too easy to confuse C struct members with JS properties.