Typescript type declarations

Where can I find typescript declarations for the Moralis SDK package? The package on npm says they should be available here:

npm install @types/moralis

But this returns a 404.


It’s officially not yet supported, and the one you are trying to get is not yet completed. At this current time, it is no completely correct or maintained, so when you use it, use it with caution.

Would be nice to get official typings :pray:

Are these safe to use?:
react-moralis/moralis.d.ts at main · MoralisWeb3/react-moralis (github.com)

hello, any updates to the typings?:slight_smile:

Unfortunately we don’t have any updates as of now. We will make sure to let you know once we release it.

Thank you for all the support. Have a wonderful day ! :slight_smile:

Hm I think we added but need to verify with team!

Hi @malik @ivan, any luck with adding typescript type declarations?

Moralis does not support all type declarations correctly?
I checked react-moralis github as well, but does not defined types in many case.
Any Update to support typescript freely?

Hi, currently we support type definitions out-of-the box if you use the latest version of moralis. So no need to install anything from @types.

You can see them in our sdk repo: https://github.com/MoralisWeb3/Moralis-JS-SDK/tree/main/types

Please let us know if you notice any types that are missing. We want to have it completely typed :slight_smile:

1 Like

Hey, I use latest version of Moralis and react-moralis in my react.js project.
Currently i’m converting Etherscan Clone project (https://github.com/MoralisWeb3/demo-apps/tree/main/moralis-scan to Typescript version.
But I have no idea how to declare all types & interfaces correctly for all variables and method params, return types and props, etc

For example Moralis.Cloud.run(methodName, options.params).
what is the options type in here and where I have to import this type?, and other many things

In this case you have to provide the options typings yourself. As the cloud function is code on your server, and not part of the codebase. There is no way to know what the types of any cloud function are. It can be any function that you want.

You can use the generic types to make the cloudfunction typesafe, if you want. But you still have to provide the interfaces.


interface CloudParams {
  id: string;
interface CloudResponse {
  name: string;
  score: number;
type CloudFunction = (params: CloudParams) => Promise<CloudResponse>;

const result = await Moralis.Cloud.run<CloudFunction>("test", { id: "12" });

This will warn you when you do not provide correct params, and the result will be typed.