Skip to content

Commit de03133

Browse files
committed
fix type check in Client, EventStream and Library
1 parent 6545dea commit de03133

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/Client.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import Library from './Library';
44

55
export default class Client {
66
constructor({ auth, api = new Particle() }){
7-
Object.assign(this, { auth, api });
7+
this.auth = auth;
8+
this.api = api;
89
}
910

1011
ready(){
@@ -84,8 +85,9 @@ export default class Client {
8485

8586
/**
8687
* Delete an entire published library
87-
* @param {String} $0.name Name of the library to delete
88-
* @param {String} $0.force Key to force deleting a public library
88+
* @param {object} params Specific params of the library to delete
89+
* @param {string} params.name Name of the library to delete
90+
* @param {string} params.force Key to force deleting a public library
8991
* @returns {Promise} A promise
9092
*/
9193
deleteLibrary({ name, force }){
@@ -117,8 +119,9 @@ export default class Client {
117119
}
118120

119121
/**
120-
* @param {String} $0.deviceId Device ID or Name
121-
* @param {Boolean} $0.signal Signal on or off
122+
* @param {object} params
123+
* @param {string} params.deviceId Device ID or Name
124+
* @param {boolean} params.signal Signal on or off
122125
* @returns {Promise} A promise
123126
* @deprecated Will be removed in 6.5
124127
*/
@@ -156,7 +159,7 @@ export default class Client {
156159
}, () => {});
157160
}
158161

159-
trackingIdentity({ full=false, context }={}){
162+
trackingIdentity({ full = false, context = undefined }={}){
160163
return this.api.trackingIdentity({ full, context, auth: this.auth })
161164
.then(payload => {
162165
return payload.body;

src/EventStream.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class EventStream extends EventEmitter {
3232
path: `${path}?access_token=${this.token}`,
3333
method: 'get',
3434
port: parseInt(port, 10) || (isSecure ? 443 : 80),
35+
// @ts-ignore
3536
mode: 'prefer-streaming'
3637
});
3738

@@ -70,7 +71,9 @@ class EventStream extends EventEmitter {
7071
// since we are already about to reject the promise anyway
7172
} finally {
7273
let errorDescription = `HTTP error ${statusCode} from ${this.uri}`;
74+
// @ts-ignore
7375
if (body && body.error_description) {
76+
// @ts-ignore
7477
errorDescription += ' - ' + body.error_description;
7578
}
7679
reject({ statusCode, errorDescription, body });

src/Library.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default class Library {
2323
if (!this.downloadUrl) {
2424
return Promise.reject(new Error('No download URL for this library'));
2525
}
26+
// @ts-ignore
2627
return this.client.downloadFile(this.downloadUrl);
2728
}
2829

0 commit comments

Comments
 (0)