Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit ae35123

Browse files
authored
Merge pull request #2550 from joshstevens19/update-readme-to-get-types-with-commonjs
docs: show how you can get the types to work in a `commonjs` module
2 parents 96a1a9f + b518014 commit ae35123

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ web3.eth.getAccounts()
6565

6666
### Usage with TypeScript
6767

68-
We do support types within the repo itself. Please open an issue here if you find any wrong types.
68+
We support types within the repo itself. Please open an issue here if you find any wrong types.
6969

7070
You can use `web3.js` as follows:
7171

@@ -74,6 +74,15 @@ import Web3 from 'web3';
7474
const web3 = new Web3("ws://localhost:8546");
7575
```
7676

77+
If you are using the types in a `commonjs` module like for example a node app you just have to enable `esModuleInterop` in your `tsconfig` compile option, also enable `allowSyntheticDefaultImports` for typesystem compatibility:
78+
79+
```js
80+
"compilerOptions": {
81+
"allowSyntheticDefaultImports": true,
82+
"esModuleInterop": true,
83+
....
84+
```
85+
7786
## Documentation
7887
7988
Documentation can be found at [read the docs][docs]

0 commit comments

Comments
 (0)