Enable strict

This commit is contained in:
Will Scullin 2023-08-06 12:47:43 -07:00
parent 88bd7836bc
commit 0216e75e7f
4 changed files with 462 additions and 624 deletions

View File

@ -22,8 +22,8 @@ import type { byte } from './types';
*/ */
export class TextPage { export class TextPage {
_page: ImageData; _page: ImageData | undefined;
_context: CanvasRenderingContext2D; _context: CanvasRenderingContext2D | undefined;
_buffer: byte[][] = []; _buffer: byte[][] = [];
_greenMode = false; _greenMode = false;
@ -98,6 +98,9 @@ export class TextPage {
this.refresh(); this.refresh();
} }
writeAt(row: byte, col: byte, val: byte): void { writeAt(row: byte, col: byte, val: byte): void {
if (!this._page) {
return;
}
this._buffer[row][col] = val; this._buffer[row][col] = val;
const data = this._page.data; const data = this._page.data;
let color; let color;
@ -169,6 +172,9 @@ export class TextPage {
this.refresh(); this.refresh();
} }
blit() { blit() {
if (!this._page || !this._context) {
return;
}
if (this._dirty) { if (this._dirty) {
this._context.putImageData( this._context.putImageData(
this._page, this._page,

File diff suppressed because it is too large Load Diff

View File

@ -214,19 +214,17 @@ export class KeyBoard {
return span; return span;
} }
const _mouseup = ( const _mouseup = (event: Event) => {
event: MouseEvent & { if (!(event.currentTarget instanceof HTMLElement)) {
currentTarget: HTMLElement; return;
} }
) => {
event.currentTarget.classList.remove('pressed'); event.currentTarget.classList.remove('pressed');
}; };
const _mousedown = ( const _mousedown = (event: Event) => {
event: MouseEvent & { if (!(event.currentTarget instanceof HTMLElement)) {
currentTarget: HTMLElement; return;
} }
) => {
event.currentTarget.classList.add('pressed'); event.currentTarget.classList.add('pressed');
let key = event.currentTarget.dataset[this.shifted ? 'key2' : 'key1']; let key = event.currentTarget.dataset[this.shifted ? 'key2' : 'key1'];
if (!key) { if (!key) {
@ -262,7 +260,7 @@ export class KeyBoard {
case 'SHIFT': case 'SHIFT':
this.shifted = !this.shifted; this.shifted = !this.shifted;
this.kb this.kb
.querySelectorAll('.key-SHIFT') .querySelectorAll<HTMLElement>('.key-SHIFT')
.forEach(function (el: HTMLElement) { .forEach(function (el: HTMLElement) {
el.classList.toggle('active'); el.classList.toggle('active');
}); });

View File

@ -8,15 +8,13 @@
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"target": "es6", "target": "es6",
"lib": ["DOM", "ES6"], "lib": ["DOM", "ES6"],
"noImplicitAny": true, "strict": true,
"noImplicitThis": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"exactOptionalPropertyTypes": true, "exactOptionalPropertyTypes": true,
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"sourceMap": true, "sourceMap": true,
"strictNullChecks": true,
"outDir": "dist", "outDir": "dist",
"baseUrl": ".", "baseUrl": ".",
"allowJs": true, "allowJs": true,