Skip to content

Commit

Permalink
Improve unsubscribe typing
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Aug 2, 2024
1 parent dec1012 commit 42424c0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export interface IClientReconnectOptions {
}
export interface IClientSubscribeProperties {
/*
* MQTT 5.0 properies object of subscribe
* MQTT 5.0 properties object of subscribe
* */
properties?: ISubscribePacket['properties']
}
Expand Down Expand Up @@ -370,6 +370,13 @@ export type ISubscriptionMap = {
resubscribe?: boolean
}

export interface IClientUnsubscribeProperties {
/*

Check failure on line 374 in src/lib/client.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `··` with `↹`
* MQTT 5.0 properties object for unsubscribe

Check failure on line 375 in src/lib/client.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `··` with `↹`
* */

Check failure on line 376 in src/lib/client.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `··` with `↹`
properties?: IUnsubscribePacket['properties']

Check failure on line 377 in src/lib/client.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `··` with `↹`
}

export { IConnackPacket, IDisconnectPacket, IPublishPacket, Packet }
export type OnConnectCallback = (packet: IConnackPacket) => void
export type OnDisconnectCallback = (packet: IDisconnectPacket) => void
Expand Down Expand Up @@ -1300,20 +1307,20 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
public unsubscribe(topic: string | string[]): MqttClient
public unsubscribe(
topic: string | string[],
opts?: IClientSubscribeOptions,
opts?: IClientUnsubscribeProperties,
): MqttClient
public unsubscribe(
topic: string | string[],
callback?: PacketCallback,
): MqttClient
public unsubscribe(
topic: string | string[],
opts?: IClientSubscribeOptions,
opts?: IClientUnsubscribeProperties,
callback?: PacketCallback,
): MqttClient
public unsubscribe(
topic: string | string[],
opts?: IClientSubscribeOptions | PacketCallback,
opts?: IClientUnsubscribeProperties | PacketCallback,
callback?: PacketCallback,
): MqttClient {
if (typeof topic === 'string') {
Expand Down

0 comments on commit 42424c0

Please sign in to comment.