Moralis Cloud Code and Typescript

Issues

I’ve looked into how https://github.com/TurtleTower/Moralis-CloudCode-Boilerplate-Typescript works but I find the following problems when using its techniques to implement my own solution:

  1. Declaring Moralis as a constant externally throws errors when it is used as a type or namespace. This is important since Cloud Code provides a number of modules without needing to define them in the script.

  2. Lots of functions expected to work with Cloud Code either don’t work (such as Moralis.Cloud.units, Moralis.web3ByChain, Moralis.settings) or have incorrect definitions (Moralis.Cloud.define, Moralis.Units.Token). For tokens, the workaround was not to change the declarations but instead hunt for the source code and paste it directly.

  3. It’s not feasible to include our own source code unless we use webpack manually to create a bundled JS file. Without webpack, TS files can’t be treated as modules, in which case the internal ncc_webpack functionality of moralis-admin-cli bundles them appropriately.

I’m looking for

  1. A proper setup for TS and Moralis Cloud Code that assumes all the modules implicitly available are not known to the IDE.
    This can be similar to how Mocha is implicitly included in tests, such as those in Hardhat templates.

  2. A proper extensive class reference in JS, which I could not find without directly referring to the source code itself, and hopefully correct type declarations in TS. These can be the basis for a class reference as well.

Spec

Moralis: [email protected]
Server: 0.0.334
IDE: VS Code 1.63.2 production

Thanks we will have this in mind and see how we can support all this

2 Likes

I’ve been informed that I can suggest the Parse Server source code for hints about Moralis server as the latter is based on the former. This has helped me somewhat, but I’m still missing proper IDE support on this.

Yes I understand we will see what we can do in future releases

2 Likes