2

Upgrading from:

// package.json
"@polkadot/api": "^6.7.2",
"@polkadot/types": "^6.7.2",

to:

// package.json
"@polkadot/api": "^7.7.1",
"@polkadot/types": "^7.7.1",

causes major compilation problems when using TypeScript on the front-end. There are a lot of missing types from the @polkadot/types/lookup folder (for example: Error: node_modules/@polkadot/api-derive/balances/types.d.ts:3:15 - error TS2305: Module '"@polkadot/types/lookup"' has no exported member 'PalletBalancesBalanceLock').

Is there a problem with the packages or is there some way to fix these errors? (Note, I'm currently only hitting the Substrate node template. I don't personally have any custom runtime logic in there).

1 Answer 1

4

As described in the CHANGELOG of the 7.x release, you must add the line:

import '@polkadot/api-augment';

and the types should work again.

3
  • Wow, that was such a simple fix. Thanks for pointing me to the release notes. I should've thought of that.
    – tarrball
    Commented Feb 15, 2022 at 16:11
  • If anybody comes wondering, the notes say to put this import "somewhere". For an Angular project, that somewhere was polyfills.ts.
    – tarrball
    Commented Feb 15, 2022 at 16:13
  • This is not working for me. I have a tiny, single-file PoC to just get account information and I'm getting a huge pile of typescript errors (840), even with the above import as the top line. Can anyone give me a push? This is with @polkadot/api version 9.2.4.
    – kael
    Commented Aug 31, 2022 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.