Fix some typescript errors in //aos/network/www/...
The typescript compiler upgrade revealed these.
Change-Id: I882e6a93fe69cd45255ae7885b57467ac6cc7498
diff --git a/aos/network/www/config_handler.ts b/aos/network/www/config_handler.ts
index c554647..8670c0a 100644
--- a/aos/network/www/config_handler.ts
+++ b/aos/network/www/config_handler.ts
@@ -33,7 +33,7 @@
this.tree_div.appendChild(channel_div);
const input_el = document.createElement('input');
- input_el.setAttribute('data-index', i);
+ input_el.setAttribute('data-index', i.toString());
input_el.setAttribute('type', 'checkbox');
input_el.addEventListener('click', () => this.handleChange());
channel_div.appendChild(input_el);
@@ -62,7 +62,7 @@
continue;
}
const index = toggle.getAttribute('data-index');
- const channel = this.config.channels(index);
+ const channel = this.config.channels(Number(index));
const namefb = builder.createString(channel.name());
const typefb = builder.createString(channel.type());
Channel.startChannel(builder);
diff --git a/aos/network/www/ping_handler.ts b/aos/network/www/ping_handler.ts
index 9b37d70..a7fb0d4 100644
--- a/aos/network/www/ping_handler.ts
+++ b/aos/network/www/ping_handler.ts
@@ -4,8 +4,8 @@
const fbBuffer = new flatbuffers.ByteBuffer(data);
const ping = aos.examples.Ping.getRootAsPing(fbBuffer);
- document.getElementById('val').innerHTML = ping.value();
- document.getElementById('time').innerHTML = ping.sendTime().low;
+ document.getElementById('val').innerHTML = ping.value().toString();
+ document.getElementById('time').innerHTML = ping.sendTime().low.toString();
}
export function SetupDom() {
diff --git a/aos/network/www/proxy.ts b/aos/network/www/proxy.ts
index 29f055b..ee3ad69 100644
--- a/aos/network/www/proxy.ts
+++ b/aos/network/www/proxy.ts
@@ -11,7 +11,7 @@
constructor(
private readonly handlerFunc:
(data: Uint8Array, sentTime: number) => void,
- private readonly channel: RTCPeerConnection) {
+ private readonly channel: RTCDataChannel) {
channel.addEventListener('message', (e) => this.handleMessage(e));
}
@@ -49,7 +49,7 @@
export class Connection {
private webSocketConnection: WebSocket|null = null;
private rtcPeerConnection: RTCPeerConnection|null = null;
- private dataChannel: DataChannel|null = null;
+ private dataChannel: RTCDataChannel|null = null;
private webSocketUrl: string;
private configInternal: aos.Configuration|null = null;
@@ -88,7 +88,7 @@
}
getConfig() {
- return this.config_internal;
+ return this.configInternal;
}
// Handle messages on the DataChannel. Handles the Configuration message as
@@ -128,7 +128,7 @@
}
// Called for new SDPs. Make sure to set it locally and remotely.
- onOfferCreated(description: RTCSessionDescription): void {
+ onOfferCreated(description: RTCSessionDescriptionInit): void {
this.rtcPeerConnection.setLocalDescription(description);
const builder = new flatbuffers.Builder(512);
const offerString = builder.createString(description.sdp);
@@ -151,7 +151,8 @@
this.dataChannel = this.rtcPeerConnection.createDataChannel('signalling');
this.handlers.add(
new Handler((data) => this.onConfigMessage(data), this.dataChannel));
- window.dc = this.dataChannel;
+ // TODO(james): Is this used? Can we delete it?
+ // window.dc = this.dataChannel;
this.rtcPeerConnection.addEventListener(
'icecandidate', (e) => this.onIceCandidate(e));
this.rtcPeerConnection.createOffer().then(
diff --git a/aos/network/www/reflection.ts b/aos/network/www/reflection.ts
index 62cfa61..a2fe3e4 100644
--- a/aos/network/www/reflection.ts
+++ b/aos/network/www/reflection.ts
@@ -150,7 +150,7 @@
case reflection.BaseType.Double:
return this.bb.readFloat64(offset);
}
- throw new Error('Unsupported message type ' + baseType);
+ throw new Error('Unsupported message type ' + fieldType);
}
};
@@ -239,8 +239,7 @@
return field;
}
}
- throw new Error(
- 'Couldn\'t find field ' + fieldName + ' options are ' + fields);
+ throw new Error('Couldn\'t find field ' + fieldName + '.');
}
// Reads a scalar with the given field name from a Table. If readDefaults