Type error: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type' #2383
Replies: 7 comments
-
Thanks! Glad you like it. :) It’s definitely not safe to export the objects as types though, as that would mean you cannot use them as values, which the classes and variables are. What version of TypeScript are you using? What is the purpose of isolateModules? I’ve not ever used that flag. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the reply @ricmoo My node_modules have tyescript version The We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default.
The following mandatory changes were made to your tsconfig.json:
- isolatedModules was set to true (requirement for SWC / Babel) This is my {
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"node_modules"
]
} And here is my package.json file {
"name": "eth-tools",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "patch-package"
},
"dependencies": {
"@emotion/react": "^11.7.0",
"@emotion/styled": "^11.6.0",
"@fontsource/roboto": "^4.5.1",
"@mui/icons-material": "^5.2.0",
"@mui/lab": "^5.0.0-alpha.58",
"@mui/material": "^5.2.1",
"@openzeppelin/contracts": "^4.4.0",
"date-fns": "^2.27.0",
"dotenv": "^10.0.0",
"hardhat": "^2.7.0",
"next": "12.0.4",
"patch-package": "^6.4.7",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-etherscan": "^2.1.8",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"chai": "^4.3.4",
"eslint": "7.32.0",
"eslint-config-next": "12.0.4",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.5.1"
}
} |
Beta Was this translation helpful? Give feedback.
-
It looks like it is supposed to be |
Beta Was this translation helpful? Give feedback.
-
I am using test files with mocha-syntax as mentioned in the above stackoverflow-page you mentioned. I put export { }
^^^^^^
SyntaxError: Unexpected token 'export'` I used I also put {
"extends": "../tsconfig.json",
"compilerOptions": {
"isolatedModules": false
},
} inside my test folder as mentioned in the second most popular answer on the stackoverflow-page you mentioned above, but the I am using |
Beta Was this translation helpful? Give feedback.
-
You might need to ping Hardhat for this problem. I don’t think it’s anything ethers can solve. :s |
Beta Was this translation helpful? Give feedback.
-
OK, thank you for the help. |
Beta Was this translation helpful? Give feedback.
-
import type { Contract } from "ethers/src.ts/index"; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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 )And here is the diff that solved my problem:
This issue body was partially generated by patch-package.
Beta Was this translation helpful? Give feedback.
All reactions