bytesbay / web3-token

Web3 Token is a new way to authenticate users in a hybrid dApps using signed messages. Implementation of EIP-4361.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

coindegen opened this issue · 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.

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

In the meantime I suggest going:

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