Skip to content

Commit 9cb4f3c

Browse files
authored
docs: Update TypeScript docs to include installing @types/ws (#1432)
Also remove an unused import in types/lib/client.d.ts. Fixes #1408
1 parent b2745d9 commit 9cb4f3c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,16 @@ About data consumption, obviously, QoS 2 > QoS 1 > QoS 0, if that's a concern to
789789
This repo bundles TypeScript definition files for use in TypeScript projects and to support tools that can read `.d.ts` files.
790790
791791
### Pre-requisites
792-
Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements:
792+
Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets these requirements:
793793
* TypeScript >= 2.1
794794
* Set tsconfig.json: `{"compilerOptions" : {"moduleResolution" : "node"}, ...}`
795-
* Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window:
796-
`npm install --save-dev @types/node`
797-
798-
### Typescript example
795+
* Includes the TypeScript definitions for Node and [ws](https://www.npmjs.com/package/ws). These types are used as
796+
parameters to some of the MQTT client's APIs and if you don't install them they get treated as `any`, which means you lose type
797+
safety.
798+
Use npm to install them by typing the following into a terminal window:
799+
`npm install --save-dev @types/node @types/ws`
800+
801+
### TypeScript example
799802
```
800803
import * as mqtt from "mqtt"
801804
let client : mqtt.MqttClient = mqtt.connect('mqtt://test.mosquitto.org')

types/lib/client.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
IClientReconnectOptions
99
} from './client-options'
1010
import { Store } from './store'
11-
import { IAuthPacket, IConnectPacket, IPublishPacket, IDisconnectPacket, IConnackPacket, Packet, QoS } from 'mqtt-packet'
11+
import { IAuthPacket, IPublishPacket, IDisconnectPacket, IConnackPacket, Packet, QoS } from 'mqtt-packet'
1212

1313
export interface ISubscriptionGrant {
1414
/**

0 commit comments

Comments
 (0)