Closed jacque006 closed 3 years ago
Okay, I'll make it. Please wait a moment.
I'm developing https://github.com/herumi/mcl-wasm/blob/typescript/src/index.d.ts and it seems to run mostly well.
But it has something wrong.
If I comment out mapToG1
,
% npx tsc test/test-ts.ts
test/test-ts.ts:247:13 - error TS2345: Argument of type 'Fr' is not assignable to parameter of type 'Fp'.
Property 'mapToG1' is missing in type 'IntType' but required in type 'Fp'.
247 z.set_a(c)
~
src/index.d.ts:49:5
49 mapToG1(): G1; // QQQ : why does this cause an error?
~~~~~~~
'mapToG1' is declared here.
test/test-ts.ts:447:25 - error TS2345: Argument of type 'Fr' is not assignable to parameter of type 'G1'.
Type 'IntType' is missing the following properties from type 'G1': setX, setY, setZ, getX, and 5 more.
447 const e = mcl.pairing(mcl.mul(mpk, r), Q)
I I wonder why mcl.add
for Fp
returns mcl.Fr
.
I'm just starting to study TypeScript and I'm not sure.
I've solved it by adding a never
member to distinguish Fp and Fr.
Thanks @herumi !
Would be nice to have Typescript typing for this library, either in this repo or via DefinetlyTyped (
@types/mcl-wasm
).