bytesbay / web3-token

Web3 Token is a new way to authenticate users in a hybrid dApps using signed messages. Implementation of EIP-4361.
380 stars 50 forks source link

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

Closed coindegen closed 2 years ago

coindegen commented 2 years ago

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.

mikefortney commented 2 years ago

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

coindegen commented 2 years ago

In the meantime I suggest going:

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