Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ts config info to docs #3321

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,28 @@ If this property is ``null`` you should connect to a remote/local node.
var web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");

That's it! now you can use the ``web3`` object.


Usage with TypeScript
=====================

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:

.. code-block:: typescript

import Web3 from 'web3';
const web3 = new Web3('ws://localhost:8546');


If you are using the types in a ``commonjs`` module like a Node app you need to enable
``esModuleInterop`` in your `tsconfig` compile option. Also enable ``allowSyntheticDefaultImports``
for typesystem compatibility:

.. code-block:: javascript

"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
....