Skip to content

Commit ab3d202

Browse files
committed
TypeScript option strict
1 parent 1dd6a9e commit ab3d202

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

Distribution/companion/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { settingsStorage } from "settings";
77
export function initialize(defaultSettings) {
88
// Whensettings changed -> send the new value
99
settingsStorage.onchange = function (e) {
10-
if (e.oldValue !== e.newValue && e.newValue !== undefined) {
10+
if (e.key !== null && e.oldValue !== e.newValue && e.newValue !== undefined) {
1111
sendValue(e.key, e.newValue);
1212
}
1313
};
@@ -24,7 +24,7 @@ function sendValue(key, value) {
2424
var message = {
2525
type: "setting",
2626
key: key,
27-
value: JSON.parse(value)
27+
value: value === null ? "" : JSON.parse(value)
2828
};
2929
messaging.peerSocket.send(message);
3030
}

Distribution/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-fitbit-settings",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Module to simplify management of settings inside Fitbit OS applications",
55
"author": "Jérémy Jeanson (https://www.bugshunter.net)",
66
"license": "MIT",

Sources/companion/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { MessageData } from "../common";
99
export function initialize(defaultSettings: any): void {
1010
// Whensettings changed -> send the new value
1111
settingsStorage.onchange = (e) => {
12-
if (e.oldValue !== e.newValue && e.newValue !== undefined) {
12+
if (e.key !== null && e.oldValue !== e.newValue && e.newValue !== undefined) {
1313
sendValue(e.key, e.newValue);
1414
}
1515
};
@@ -23,12 +23,12 @@ export function initialize(defaultSettings: any): void {
2323
* @param key of the settings
2424
* @param value of the settings
2525
*/
26-
function sendValue(key: string, value: string): void {
26+
function sendValue(key: string, value: string | null): void {
2727
if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) {
2828
const message: MessageData = {
2929
type: "setting",
3030
key: key,
31-
value: JSON.parse(value)
31+
value: value === null ? "" : JSON.parse(value)
3232
};
3333
messaging.peerSocket.send(message);
3434
} else {
@@ -67,7 +67,7 @@ export function setDefaultSetting(key: string, value: any): void {
6767
* try to get current setting (return null if not defined or error)
6868
* @param key
6969
*/
70-
function getSetting(key: string): string {
70+
function getSetting(key: string): string | null {
7171
try {
7272
return settingsStorage.getItem(key);
7373
} catch (ex) {

Sources/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-fitbit-settings",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Module to simplify management of settings inside Fitbit OS applications",
55
"author": "Jérémy Jeanson (https://www.bugshunter.net)",
66
"license": "MIT",

Sources/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./node_modules/@fitbit/sdk/sdk-tsconfig.json",
33
"compilerOptions": {
4+
"strict": true,
45
"noEmit": false,
56
"outDir": "../distribution",
67
"sourceMap": false,

0 commit comments

Comments
 (0)