I have some TypeScript code that has values as the PublicKey
type, that also uses the PublicKey
constructor to turns strings into PublicKey
s.
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?
CodePudding user response:
use an as
to rename the module:
import type { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { PublicKey as PublicKeyConstructor } from "@solana/web3.js";