Moralis.transfer Property 'Units' does not exist on type 'typeof Moralis

Here;s my painfully simple component. I tried the const Moralis = require … etc variations thereof . I had this working before so I know it works, but I can’t get the declaration right I think

  import { useMoralis } from "react-moralis";
  import React from "react";
  //import ReactDOM from "react-dom";

  export default function FormComponent() {
    const { Moralis } = useMoralis();

    const options = {
        type: "erc20", 
        amount: Moralis.Units.Token("0.5", "18"), 
        receiver: "0x..",
        contractAddress: "0x.."
    const doClick = async () =>{
        let result = await Moralis.transfer(options)

        <button onClick={doClick}>
        Click me!

Moralis.Units.ETH("0.5"); seems to work fine for me in React.
Moralis.Units.Token("0.6", "18") * 1 works too. Sometimes you can get confused because it returns a BN number.

No I’m getting a compile time error on

Moralis.Units.Token("0.5", "18")



I think it’s because I am using

import { useMoralis } from "react-moralis";


const { user, Moralis } = useMoralis();

for declarations in same code above

“resource”: “/Users/ericnickus/moralisfriendapp/src/components/Example.tsx”,
“owner”: “typescript”,
“code”: “2339”,
“severity”: 8,
“message”: “Property ‘Units’ does not exist on type ‘typeof Moralis’.”,
“source”: “ts”,
“startLineNumber”: 13,
“startColumn”: 25,
“endLineNumber”: 13,
“endColumn”: 30

and Property ‘transfer’ does not exist on typeof Moralis

Maybe you have an old version of Moralis SDK

how do I check version?

Check the package.json file

“moralis”: “^0.0.58” and
“react-moralis”: “^0.2.3”
can i use both at the same time

Update moralis to 0.0.95 and
react-moralis to 0.2.6

react-moralis doesn’t work without moralis

Ok but if I don’t use this line

const { user , Moralis } = useMoralis();

I get Property transfer does not exist on typeOf Moralis - error

but if I do use that line, that requires

import { useMoralis } from "react-moralis";

which causes the Moralis.transfer to error .

IN OTHER WORDS… how can I do this

const {  Moralis } = useMoralis();

without useMoralis

import { Moralis } from "moralis";


import Moralis from "moralis";

Thats good and true, but it seems that Moralis.transfer doesn’t want to work for me unless I have this

const {  Moralis } = [doesn't matter what I put here it errors ();

but without the const , I can't use the Moralis.  functions

Do you get a simple warning or error message during the compiling?

It’s a problem in types. We will update them this week

If you use ts project. You can avoid this issue using any:

(Moralis as any).transfer(options)