Skip to content

Commit

Permalink
TypeScript: Update README and include demo with types
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheworiordan committed Apr 4, 2018
1 parent 63fe490 commit 392689a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ For React Native, do not use this package. Instead use the [ably-react-native](h

The TypeScript typings are included in the package and so all you have to do is:

```javascript
import * as Ably from 'ably';
let realtime = new Ably.Realtime(options);
```typescript
import * as Ably from './ably';
let options : Ably.Types.ClientOptions = { key: 'foo' };
let client = new Ably.Realtime(options); /* inferred type Ably.Realtime */
let channel = client.channels.get('feed'); /* inferred type Ably.Types.RealtimeChannel */
```

Additionally, the type definitions are registered with [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ably).
Intellisense in IDEs with TypeScript support is supported:

![TypeScript suggestions](./resources/typescript-demo.gif)

If your need to explicitly import the type definitions, see [ably.d.ts](./ably.d.ts).

### Using WebPack

Expand Down
Binary file added resources/typescript-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 392689a

Please sign in to comment.