I'm building a typescript project and I'm trying to do the very simplest thing as a first step with Polkadot: Connect to a node and get account information. However, when I run tsc
, it totally blows up.
I've read all kinds of stuff in their docs and online about type generation and importing these "augmentations" (including this SO question), but I haven't managed to break through yet.
On top of that, it seems crazy to me that you would actually have to do this complex type generation step to make the library work, so I wanted to gut check it and see if anyone maybe has a super simple typescript repo out there that I can use as an example. I did see this example, but its wildly out of date, and it also doesn't have any explanation to go along with it.
For the benefit of googlers, here are a few of the errors I'm getting (of 127 in total):
node_modules/@polkadot/api-derive/accounts/flags.d.ts:3:15 - error TS2305: Module '"@polkadot/types/lookup"' has no exported member 'PalletElectionsPhragmenSeatHolder'.
3 import type { PalletElectionsPhragmenSeatHolder } from '@polkadot/types/lookup';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@polkadot/api-derive/accounts/identity.d.ts:4:15 - error TS2305: Module '"@polkadot/types/lookup"' has no exported member 'PalletIdentityRegistration'.
4 import type { PalletIdentityRegistration } from '@polkadot/types/lookup';
And here's the entire contents of what I'm trying to compile:
import * as Polkadot from "@polkadot/api";
const provider = new Polkadot.WsProvider("wss://westend-rpc.polkadot.io");
export const client = Polkadot.ApiPromise.create({ provider });
// TODO: use the client to do something