question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type error: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'

See original GitHub issue

Hi! 👋

Firstly, thanks for your work on this project! 🙂

I got this error from typescript while creating build version of nextjs. ( I am using 5.5.1 version of ethers on Ubuntu 20.04 LTS )

npm run build

> build
> next build

./node_modules/ethers/src.ts/ethers.ts:96:5
Type error: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

  94 |     // Types
  95 | 
> 96 |     ContractFunction,
     |     ^
  97 |     ContractReceipt,
  98 |     ContractTransaction,
  99 |     Event,
info  - Checking validity of types 

And here is the diff that solved my problem:

diff --git a/node_modules/ethers/src.ts/ethers.ts b/node_modules/ethers/src.ts/ethers.ts
index f192c6d..899f802 100644
--- a/node_modules/ethers/src.ts/ethers.ts
+++ b/node_modules/ethers/src.ts/ethers.ts

@@ -58,7 +58,7 @@ 

-export {
+export type {
     Signer,
 
     Wallet,
diff --git a/node_modules/ethers/src.ts/index.ts b/node_modules/ethers/src.ts/index.ts
index b1071dd..1622084 100644
--- a/node_modules/ethers/src.ts/index.ts
+++ b/node_modules/ethers/src.ts/index.ts
@@ -14,7 +14,7 @@ 
 
-export {
+export type {
     Signer,
 
     Wallet,
diff --git a/node_modules/ethers/src.ts/utils.ts b/node_modules/ethers/src.ts/utils.ts
index 7a4de87..e8f32e4 100644
--- a/node_modules/ethers/src.ts/utils.ts
+++ b/node_modules/ethers/src.ts/utils.ts
 
-export {
+export type {
     AbiCoder,
     defaultAbiCoder,
 

This issue body was partially generated by patch-package.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
YoungMaheshcommented, Dec 5, 2021

OK, thank you for the help.

0reactions
ricmoocommented, Dec 5, 2021

You might need to ping Hardhat for this problem. I don’t think it’s anything ethers can solve. 😒

Read more comments on GitHub >

github_iconTop Results From Across the Web

isolatedModules refusing to export a type created in the same ...
Actual behavior: Transpile is rejected with error: Cannot re-export a type when the '--isolatedModules' flag is provided.
Read more >
Cannot re-export a type when using the --isolatedModules ...
TS 3.8+. You can use type-only imports and exports with --isolatedModules : // types.ts export type MyType = { a: string; b: number;...
Read more >
isolatedmodules' flag is provided requires using 'export type'
Re -exporting a type when the '--isolatedModules' flag is provided requires using 'export ... You just need to use this syntax when re-exporting...
Read more >
isolatedModules - TSConfig Option - TypeScript
Exports of Non-Value Identifiers. In TypeScript, you can import a type and then subsequently export it: ts. import { someType , someFunction }...
Read more >
Re exporting a type when the isolatedModules flag is provided ...
'Re exporting a type when the isolatedModules flag is provided requires using export type. So far so good and that works without the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found