From 751f2f1b877307a55193aafc43e1f391195b56d5 Mon Sep 17 00:00:00 2001 From: Joey Wunderlich Date: Fri, 30 Jun 2023 10:16:37 -0700 Subject: [PATCH] clear out some annotations by not confusing our old ts compiler --- libs/mixer/sim/music.ts | 24 ++++++++++++++++-------- libs/wifi---esp32/sim/wifisockets.ts | 11 +++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libs/mixer/sim/music.ts b/libs/mixer/sim/music.ts index 73e87ac4a..42933acf7 100644 --- a/libs/mixer/sim/music.ts +++ b/libs/mixer/sim/music.ts @@ -71,24 +71,29 @@ namespace pxsim.music { } export function _sequencerState(id: number): string { - return lookupSequencer(id)?.state(); + const seq = lookupSequencer(id); + return seq && seq.state(); } export function _sequencerCurrentTick(id: number): number { - return lookupSequencer(id)?.currentTick(); + const seq = lookupSequencer(id); + return seq && seq.currentTick(); } export function _sequencerPlaySong(id: number, song: RefBuffer, loop: boolean): void { const decoded = decodeSong(song.data); - lookupSequencer(id)?.start(decoded, loop); + const seq = lookupSequencer(id); + seq && seq.start(decoded, loop); } export function _sequencerStop(id: number): void { - lookupSequencer(id)?.stop(); + const seq = lookupSequencer(id); + seq && seq.stop(); } export function _sequencerSetVolume(id: number, volume: number): void { - lookupSequencer(id)?.setVolume(volume); + const seq = lookupSequencer(id); + seq && seq.setVolume(volume); } export function _sequencerSetVolumeForAll(volume: number): void { @@ -98,15 +103,18 @@ namespace pxsim.music { } export function _sequencerSetTrackVolume(id: number, trackIndex: number, volume: number): void { - lookupSequencer(id)?.setTrackVolume(trackIndex, volume); + const seq = lookupSequencer(id); + seq && seq.setTrackVolume(trackIndex, volume); } export function _sequencerSetDrumTrackVolume(id: number, trackIndex: number, drumIndex: number, volume: number): void { - lookupSequencer(id)?.setDrumTrackVolume(trackIndex, drumIndex, volume); + const seq = lookupSequencer(id); + seq && seq.setDrumTrackVolume(trackIndex, drumIndex, volume); } export function _sequencerDispose(id: number) { - lookupSequencer(id)?.dispose(); + const seq = lookupSequencer(id); + seq.dispose(); sequencers = sequencers.filter(s => s.id !== id); } diff --git a/libs/wifi---esp32/sim/wifisockets.ts b/libs/wifi---esp32/sim/wifisockets.ts index 3599b62e4..7d9b51446 100644 --- a/libs/wifi---esp32/sim/wifisockets.ts +++ b/libs/wifi---esp32/sim/wifisockets.ts @@ -156,7 +156,11 @@ namespace pxsim._wifi { const WIFI_ID = 1234 export function _allowed() { - const bid = board()?.runOptions?.boardDefinition?.id + const b = board(); + const bid = b + && b.runOptions + && b.runOptions.boardDefinition + && b.runOptions.boardDefinition.id; return /esp32|-s2/.test(bid) } @@ -295,7 +299,10 @@ namespace pxsim.crypto { concat.set(b, len) len += b.length } - const r = window?.crypto?.subtle?.digest("SHA-256", concat) + const r = window + && window.crypto + && window.crypto.subtle + && window.crypto.subtle.digest("SHA-256", concat); if (r) return r.then(buf => new RefBuffer(new Uint8Array(buf))) else