Skip to content

Commit 4183cdc

Browse files
committed
docs: show how you can get the types to work in a commonjs module
1 parent cd32de2 commit 4183cdc

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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)