monero-ts icon indicating copy to clipboard operation
monero-ts copied to clipboard

Add support for typescript via type definitions in @types folder.

Open BeanTosser opened this issue 2 years ago • 3 comments

Add support for typescript via type definitions in @types folder.

Install typescript, emit typedefs, and "fix" index.d.ts.

Replace all BigInteger math function calls with standard BigInt...

... overloads (BigInteger(value).multiply(BigInteger(value2)) -> BigInt(value) * BigInt(value2))

Type nearly everything in TestSampleCode.ts.

Fix all errors that were due to typing vars in "for...of" statements.

NOTE: keyImage is defined as string. This is probably correct but can't be verified due to lack of documentation and my inability to trace the method chain in the source code.

Intermediate progress writing script to replace BigInteger.compare.

Find lefthand terms of .compare operations.

Replacing BigInteger.compare() with BigIntegerCompare() in progress.

Fix all errors and finish converting TestSampleCode.js to Typescript.

Update "async" to version 2.6.4.

BeanTosser avatar Jun 02 '22 00:06 BeanTosser

This was a messy, messy merge/rebase. Please take a good look at the diffs to make sure nothing screwy is going on.

BeanTosser avatar Jun 02 '22 00:06 BeanTosser

Related issue: https://github.com/monero-ecosystem/monero-javascript/issues/81

woodser avatar Jun 06 '22 19:06 woodser

Wow. This is a crazy amount of code... it will be extremely useful for anyone using MoneroJs in the future. Great job. I was able to pull your PR into my active project by replacing monero-javascript in the package.json file with "monero-javascript": "BeanTosser/monero-javascript#add_typescript_support" (if anyone's interested)

It may be worth breaking things into additional index.d.ts files in each group (common, daemon, etc) just to make things a little less heavy in the big index file (though you would have to import the group indexes into the main index :upside_down_face: )

Bugs:

I'm not able to run this yet- first bug I'm seeing: Module not found: Error: Can't resolve './src/main/js/common/BigIntegerCompare' in 'node_modules/monero-javascript'

CryptoGrampy avatar Jun 25 '22 07:06 CryptoGrampy

Replacing with #108

woodser avatar Oct 14 '22 12:10 woodser