Skip to content

Commit

Permalink
Merge pull request #2550 from joshstevens19/update-readme-to-get-type…
Browse files Browse the repository at this point in the history
…s-with-commonjs

docs: show how you can get the types to work in a `commonjs` module
  • Loading branch information
nivida authored Mar 22, 2019
2 parents 96a1a9f + b518014 commit ae35123
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 ae35123

Please sign in to comment.