Skip to content

Commit 13c2a49

Browse files
committed
Fix typings
1 parent ed691ef commit 13c2a49

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/cbor/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function toCloudProtocolV2(cborValue: CBORValue): CBORValue {
5252
return cloudV2CBORValue;
5353
}
5454

55-
function parse(value: any, name: string, timestamp: number, deviceId: string): CBORValue {
55+
function parse(value: CloudMessageValue, name: string, timestamp: number, deviceId: string): CBORValue {
5656
const parsed: CBORValue = {
5757
n: name,
5858
bt: timestamp !== -1 ? (timestamp || new Date().getTime()) : undefined,

src/client/ArduinoCloudClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class ArduinoCloudClient implements IArduinoCloudClient {
120120
this.subscriptions[topic] = this.subscriptions[topic] = [];
121121
this.subscriptions[topic].push(
122122
this.messagesFrom(topic)
123-
.subscribe(v => cb(v.value as any)));
123+
.subscribe(v => cb(v.value as T)));
124124

125125
return resolve();
126126
} catch (err) {
@@ -177,7 +177,7 @@ export class ArduinoCloudClient implements IArduinoCloudClient {
177177
this.subscriptions[topic].push(
178178
this.messagesFrom(topic)
179179
.pipe(filter(v => v.propertyName === name))
180-
.subscribe(v => cb(v.value as any)));
180+
.subscribe(v => cb(v.value as T)));
181181
}
182182

183183
private messagesFrom(topic: string): Observable<CloudMessage> {

src/utils/index.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { CloudMessageValue } from "../client/IArduinoCloudClient";
2+
13
class ArduinoCloudError extends Error {
24
constructor(public code: number, message: string) {
35
super(message);
@@ -9,23 +11,23 @@ class ArduinoCloudError extends Error {
911
}
1012
}
1113

12-
function isObject(value: any): value is object {
14+
function isObject(value: CloudMessageValue): value is object {
1315
return typeof (value) === "object";
1416
}
1517

16-
function isNumber(value: any): value is number {
18+
function isNumber(value: CloudMessageValue): value is number {
1719
return typeof (value) === "number";
1820
}
1921

20-
function isString(value: any): value is string {
22+
function isString(value: CloudMessageValue): value is string {
2123
return typeof (value) === "string";
2224
}
2325

24-
function isBoolean(value: any): value is boolean {
26+
function isBoolean(value: CloudMessageValue): value is boolean {
2527
return typeof (value) === "boolean";
2628
}
2729

28-
function isArray<T>(value: any): value is T[] {
30+
function isArray<T>(value: CloudMessageValue): value is T[] {
2931
return Array.isArray(value);
3032
}
3133

0 commit comments

Comments
 (0)