Skip to content

Commit

Permalink
Turn on more tsc strictness options
Browse files Browse the repository at this point in the history
Various bits of code have been updated accordingly. Some code has been
comemnted out rather than removed. Some code has been commented and an
adjusted version added instead, to better satisfy the compiler. In the
case of unused parameters, some of these have been renamed to have a "_"
prefix rather than removed.
  • Loading branch information
djmattyg007 authored and badaix committed Dec 29, 2020
1 parent 57dec92 commit 15cb5f2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions page/snapcontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ class SnapControl {
private connect(){
this.connection = new WebSocket(this.baseUrl + '/jsonrpc');
this.connection.onmessage = (msg: MessageEvent) => this.onMessage(msg.data);
this.connection.onopen = (ev: Event) => { this.status_req_id = this.sendRequest('Server.GetStatus'); };
this.connection.onopen = () => { this.status_req_id = this.sendRequest('Server.GetStatus'); };
this.connection.onerror = (ev: Event) => { console.error('error:', ev); };
this.connection.onclose = (ev: Event) => {
this.connection.onclose = () => {
console.info('connection lost, reconnecting in 1s');
setTimeout(() => this.connect(), 1000);
};
Expand Down Expand Up @@ -550,7 +550,7 @@ function show() {
let slider = document.getElementById("vol_" + group.id) as HTMLInputElement;
if (slider == null)
continue;
slider.addEventListener('pointerdown', function (ev: PointerEvent) {
slider.addEventListener('pointerdown', function () {
groupVolumeEnter(group.id);
});
slider.addEventListener('touchstart', function () {
Expand Down Expand Up @@ -747,7 +747,7 @@ function deleteClient(id: string) {
}
}

window.onload = function (event: any) {
window.onload = function () {
snapcontrol = new SnapControl(config.baseUrl);
}

Expand Down
31 changes: 14 additions & 17 deletions page/snapstream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Tv {


class BaseMessage {
constructor(buffer?: ArrayBuffer) {
constructor(_buffer?: ArrayBuffer) {
}

deserialize(buffer: ArrayBuffer) {
Expand Down Expand Up @@ -359,7 +359,7 @@ class AudioStream {
chunks: Array<PcmChunkMessage> = new Array<PcmChunkMessage>();

setVolume(percent: number, muted: boolean) {
let base = 10;
// let base = 10;
this.volume = percent / 100; // (Math.pow(base, percent / 100) - 1) / (base - 1);
console.log("setVolume: " + percent + " => " + this.volume + ", muted: " + this.muted);
this.muted = muted;
Expand Down Expand Up @@ -623,21 +623,17 @@ class SampleFormat {


class Decoder {
setHeader(buffer: ArrayBuffer): SampleFormat | null {
setHeader(_buffer: ArrayBuffer): SampleFormat | null {
return new SampleFormat();
}

decode(chunk: PcmChunkMessage): PcmChunkMessage | null {
decode(_chunk: PcmChunkMessage): PcmChunkMessage | null {
return null;
}
}


class OpusDecoder extends Decoder {
constructor() {
super();
}

setHeader(buffer: ArrayBuffer): SampleFormat | null {
let view = new DataView(buffer);
let ID_OPUS = 0x4F505553;
Expand All @@ -657,7 +653,7 @@ class OpusDecoder extends Decoder {
return format;
}

decode(chunk: PcmChunkMessage): PcmChunkMessage | null {
decode(_chunk: PcmChunkMessage): PcmChunkMessage | null {
return null;
}
}
Expand Down Expand Up @@ -689,7 +685,8 @@ class FlacDecoder extends Decoder {
this.cacheInfo = { cachedBlocks: 0, isCachedChunk: true };
// console.log("Flac len: " + this.flacChunk.byteLength);
while (this.flacChunk.byteLength && Flac.FLAC__stream_decoder_process_single(this.decoder)) {
let state = Flac.FLAC__stream_decoder_get_state(this.decoder);
Flac.FLAC__stream_decoder_get_state(this.decoder);
// let state = Flac.FLAC__stream_decoder_get_state(this.decoder);
// console.log("State: " + state);
}
// console.log("Pcm payload: " + this.pcmChunk!.payloadSize());
Expand Down Expand Up @@ -776,13 +773,13 @@ class PlayBuffer {
this.source = source;
this.source.buffer = this.buffer;
this.source.connect(destination);
this.onended = (playBuffer: PlayBuffer) => { };
this.onended = (_playBuffer: PlayBuffer) => { };
}

public onended: (playBuffer: PlayBuffer) => void

start() {
this.source.onended = (ev: Event) => {
this.source.onended = () => {
this.onended(this);
}
this.source.start(this.playTime);
Expand Down Expand Up @@ -823,7 +820,7 @@ class SnapStream {
this.streamsocket.binaryType = "arraybuffer";
this.streamsocket.onmessage = (ev) => this.onMessage(ev);

this.streamsocket.onopen = (ev) => {
this.streamsocket.onopen = () => {
console.log("on open");
let hello = new HelloMessage();

Expand All @@ -837,7 +834,7 @@ class SnapStream {
this.syncHandle = window.setInterval(() => this.syncTime(), 1000);
}
this.streamsocket.onerror = (ev) => { console.error('error:', ev); };
this.streamsocket.onclose = (ev) => {
this.streamsocket.onclose = () => {
window.clearInterval(this.syncHandle);
console.info('connection lost, reconnecting in 1s');
setTimeout(() => this.connect(), 1000);
Expand Down Expand Up @@ -946,7 +943,7 @@ class SnapStream {
}
while (this.audioBuffers.length > 0) {
let buffer = this.audioBuffers.pop();
buffer!.onended = (playBuffer: PlayBuffer) => { };
buffer!.onended = () => { };
buffer!.source.stop();
}
while (this.freeBuffers.length > 0) {
Expand All @@ -958,7 +955,7 @@ class SnapStream {
window.clearInterval(this.syncHandle);
this.stopAudio();
if ([WebSocket.OPEN, WebSocket.CONNECTING].includes(this.streamsocket.readyState)) {
this.streamsocket.onclose = (ev) => { };
this.streamsocket.onclose = () => { };
this.streamsocket.close();
}
}
Expand All @@ -980,7 +977,7 @@ class SnapStream {
this.audioBuffers.push(playBuffer);
playBuffer.num = ++this.bufferNum;
playBuffer.onended = (buffer: PlayBuffer) => {
let diff = this.timeProvider.nowSec() - buffer.playTime;
// let diff = this.timeProvider.nowSec() - buffer.playTime;
this.freeBuffers.push(this.audioBuffers.splice(this.audioBuffers.indexOf(buffer), 1)[0].buffer);
// console.debug("PlayBuffer " + playBuffer.num + " ended after: " + (diff * 1000) + ", in flight: " + this.audioBuffers.length);
this.playNext();
Expand Down
8 changes: 4 additions & 4 deletions page/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
Expand All @@ -59,4 +59,4 @@
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
}

0 comments on commit 15cb5f2

Please sign in to comment.