Skip to content

Commit

Permalink
docs: show how you can get the types to work in a commonjs module
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstevens19 committed Mar 21, 2019
1 parent cd32de2 commit 4183cdc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ web3.eth.getAccounts()

### Usage with TypeScript

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

You can use `web3.js` as follows:

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

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:

```js
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
....
```
## Documentation
Documentation can be found at [read the docs][docs]
Expand Down

0 comments on commit 4183cdc

Please sign in to comment.