Lisk-sdk: Error when compiling TS project that imports lisk-sdk package

Created on 5 Mar 2021  路  4Comments  路  Source: LiskHQ/lisk-sdk

After importing lisk-sdk into a TS project and trying to compile that project, I ran into this error :

/node_modules/lisk-sdk/dist-node/samples/genesis_block_devnet"' uses 'export =' and cannot be used with 'export *'.

Changing node_modules/lisk-sdk/dist-node/samples/index.d.ts content

export * as genesisBlockDevnet from './genesis_block_devnet.json';
export * as configDevnet from './config_devnet.json';

to the following fixes the issue

import genesisBlockDevnet from './genesis_block_devnet.json';
import configDevnet from './config_devnet.json';

export { genesisBlockDevnet, configDevnet }

My project's tsconfig.json :

{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "target": "es2019",
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "pretty": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "outDir": "./dist",
    "declaration": true
  },
  "exclude": [
    "node_modules",
    "dist"
  ]
}

Which version(s) does this affect? (Environment, OS, etc...)

[email protected]

bug

All 4 comments

In our tsconfig.json, we dont use esModuleInterop: true. I think if you make it false it should work.
Any particular reason you want to enable esModuleInterop?

I think if you make it false it should work.

Nope

I think there were breaking change in typescript 4.x. Are you using the same typescript version "typescript": "3.8.3",?

TS 3.8.3 works !
It should be added to the doc if it's not already present ;)

Was this page helpful?
0 / 5 - 0 ratings