Issue
I have some TypeScript code that has values as the PublicKey type, that also uses the PublicKey constructor to turns strings into PublicKeys.
import type { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { PublicKey } from "@solana/web3.js";
This fails with the error:
Duplicate identifier 'PublicKey'
How can I use Keypair both as a type and a value?
Solution
use an as to rename the module:
import type { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { PublicKey as PublicKeyConstructor } from "@solana/web3.js";
Answered By - Liam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.