update TS rules to make them stricter

master
Sebastian Di Luzio 2021-12-10 21:36:42 +01:00
parent 45bd654eca
commit 15d24ac1b3
4 changed files with 34 additions and 19 deletions

View File

@ -16,14 +16,17 @@
draw: draw
};
Bangle.on('charging', function (charging) {
if (charging) {
Bangle.buzz();
WIDGETS.chargingStatus.width = iconWidth;
var widget = WIDGETS.chargingStatus;
if (widget) {
if (charging) {
Bangle.buzz();
widget.width = iconWidth;
}
else {
widget.width = 0;
}
Bangle.drawWidgets(); // re-layout widgets
g.flip();
}
else {
WIDGETS.chargingStatus.width = 0;
}
Bangle.drawWidgets(); // re-layout widgets
g.flip();
});
})();

View File

@ -6,7 +6,7 @@
);
const iconWidth = 18;
function draw() {
function draw(this: { x: number; y: number }) {
g.reset();
if (Bangle.isCharging()) {
g.setColor('#FD0');
@ -19,17 +19,20 @@
WIDGETS.chargingStatus = {
area: 'tr',
width: Bangle.isCharging() ? iconWidth : 0,
draw: draw,
draw,
};
Bangle.on('charging', (charging) => {
if (charging) {
Bangle.buzz();
WIDGETS.chargingStatus.width = iconWidth;
} else {
WIDGETS.chargingStatus.width = 0;
const widget = WIDGETS.chargingStatus;
if (widget) {
if (charging) {
Bangle.buzz();
widget.width = iconWidth;
} else {
widget.width = 0;
}
Bangle.drawWidgets(); // re-layout widgets
g.flip();
}
Bangle.drawWidgets(); // re-layout widgets
g.flip();
});
})();

View File

@ -2,7 +2,16 @@
"compilerOptions": {
"module": "es2015",
"noImplicitAny": true,
"target": "es2015"
"target": "es2015",
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true
},
"include": ["../apps/**/*", "./**/*"]
}

View File

@ -178,6 +178,6 @@ declare const g: GraphicsApi;
declare type Widget = {
area: 'tr' | 'tl';
width: number;
draw: () => void;
draw: (this: { x: number; y: number }) => void;
};
declare const WIDGETS: { [key: string]: Widget };