web3-token icon indicating copy to clipboard operation
web3-token copied to clipboard

Type error: 'Web3Token' only refers to a type, but is being used as a value here.

Open coindegen opened this issue 3 years ago • 2 comments

In a NextJS 12.0.4 app using Typescript, I am getting npm run build errors when I import the package like this:

import Web3Token from "web3-token";

The error:

Failed to compile.

./components/providers/Modal.tsx:125:23
Type error: 'Web3Token' only refers to a type, but is being used as a value here.

  123 |       });
  124 |       if (!token) {
> 125 |         token = await Web3Token.sign(
      |                       ^

Please advise.

coindegen avatar Jan 22 '22 01:01 coindegen

I am getting this same error. @bytesbay can you please provide better typescript support? Thank you!

mikefortney avatar Feb 07 '22 07:02 mikefortney

In the meantime I suggest going:

import * as Web3Token from "web3-token";
import { sign } from "web3-token";

coindegen avatar Feb 07 '22 08:02 coindegen