We are using the typegen to create types for our custom chain. Following the docs

The code that is generated is kinda strange. In the augment-api.ts file it tries to import all the other generated ts files, but it tries to import them as .js files which causes an error and our app wont build until we manually remove the ".js" from each line every time we generate.

// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */

import './augment-api-consts.js';
import './augment-api-errors.js';
import './augment-api-events.js';
import './augment-api-query.js';
import './augment-api-tx.js';
import './augment-api-rpc.js';
import './augment-api-runtime.js';

The other strange thing is that most all of the types used in the generated files are not found. For example in augment-api-query.ts in the

 assets: {
      asset: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletAssetsAssetDetails>>, [u32]>;

The PalletAssetsAssetDetails is not found. Many other types in all the generated files are also not found...

using @polkadot/typegen 10.9.1

1 Answer 1


The way I resolved this problem is by switching away from ts-node and using tsx instead. Add tsx to your project with: yarn add --dev tsx

Then change your script in package.json where you are using:

ts-node --skip-project node_modules/.bin/polkadot-types-from-defs ...

replace with:

tsx node_modules/.bin/polkadot-types-from-defs ...

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.