Fix some typescript issues in //y2020/www/...
These were revealed by the typescript compiler upgrade.
Change-Id: I548ac2601c9ce830beda14b51272e04ef07bcd00
diff --git a/y2020/www/BUILD b/y2020/www/BUILD
index 1311b7d..5e11d7c 100644
--- a/y2020/www/BUILD
+++ b/y2020/www/BUILD
@@ -10,6 +10,8 @@
],
visibility = ["//y2020:__subpackages__"],
deps = [
+ "//aos:configuration_ts_fbs",
+ "//aos/network:connect_ts_fbs",
"//aos/network/www:proxy",
"//y2020/vision:vision_ts_fbs",
"//y2020/vision/sift:sift_ts_fbs",
@@ -24,6 +26,8 @@
"field_main.ts",
],
deps = [
+ "//aos:configuration_ts_fbs",
+ "//aos/network:connect_ts_fbs",
"//aos/network/www:proxy",
"//frc971/control_loops/drivetrain:drivetrain_status_ts_fbs",
"//y2020/vision/sift:sift_ts_fbs",
diff --git a/y2020/www/field_handler.ts b/y2020/www/field_handler.ts
index 5053ef6..ffb4aee 100644
--- a/y2020/www/field_handler.ts
+++ b/y2020/www/field_handler.ts
@@ -84,7 +84,7 @@
export class FieldHandler {
private canvas = document.createElement('canvas');
private imageMatchResult: frc971.vision.sift.ImageMatchResult|null = null;
- private drivetrainStatus: DrivetrianStatus|null = null;
+ private drivetrainStatus: DrivetrainStatus|null = null;
constructor(private readonly connection: Connection) {
document.body.appendChild(this.canvas);
@@ -238,7 +238,7 @@
this.drawField();
//draw cameras
if (this.imageMatchResult) {
- for (const i = 0; i < this.imageMatchResult.cameraPosesLength(); i++) {
+ for (let i = 0; i < this.imageMatchResult.cameraPosesLength(); i++) {
const pose = this.imageMatchResult.cameraPoses(i);
const mat = pose.fieldToCamera();
const x = mat.data(3);
diff --git a/y2020/www/image_handler.ts b/y2020/www/image_handler.ts
index e48fbfb..c84fa23 100644
--- a/y2020/www/image_handler.ts
+++ b/y2020/www/image_handler.ts
@@ -108,7 +108,7 @@
}
handleSelect(ev: Event) {
- this.selectedIndex = ev.target.selectedIndex;
+ this.selectedIndex = (ev.target as HTMLSelectElement).selectedIndex;
}
handleImage(data: Uint8Array): void {
@@ -137,8 +137,8 @@
this.imageBuffer = new Uint8ClampedArray(this.width * this.height * 4); // RGBA
// Read four bytes (YUYV) from the data and transform into two pixels of
// RGBA for canvas
- for (const j = 0; j < this.height; j++) {
- for (const i = 0; i < this.width; i += 2) {
+ for (let j = 0; j < this.height; j++) {
+ for (let i = 0; i < this.width; i += 2) {
const y1 = this.image.data((j * this.width + i) * 2);
const u = this.image.data((j * this.width + i) * 2 + 1);
const y2 = this.image.data((j * this.width + i + 1) * 2);
@@ -194,21 +194,21 @@
const idata = ctx.createImageData(this.width, this.height);
idata.data.set(this.imageBuffer);
ctx.putImageData(idata, 0, 0);
- console.log('features: ', this.result.featuresLength();
+ console.log('features: ', this.result.featuresLength());
if (this.selectedIndex === 0) {
- for (const i = 0; i < this.result.featuresLength(); i++) {
+ for (let i = 0; i < this.result.featuresLength(); i++) {
const feature = this.result.features(i);
this.drawFeature(feature);
}
} else {
console.log(this.result.imageMatchesLength(), this.result.cameraPosesLength());
const imageMatch = this.result.imageMatches(this.selectedIndex - 1);
- for (const i = 0; i < imageMatch.matchesLength(); i++) {
+ for (let i = 0; i < imageMatch.matchesLength(); i++) {
const featureIndex = imageMatch.matches(i).queryFeature();
this.drawFeature(this.result.features(featureIndex));
}
// Draw center of target.
- const cameraPose = this.result.cameraPoses(this.selctedIndex - 1);
+ const cameraPose = this.result.cameraPoses(this.selectedIndex - 1);
ctx.strokeStyle = 'red';
ctx.beginPath();
ctx.arc(
@@ -223,12 +223,12 @@
}
const defaultOption = document.createElement('option');
defaultOption.innerText = 'Show all features';
- defaultOption.setAttribute('value', 0);
+ defaultOption.setAttribute('value', '0');
this.select.appendChild(defaultOption);
- for (const i = 0; i < this.result.imageMatchesLength(); i++) {
+ for (let i = 0; i < this.result.imageMatchesLength(); i++) {
const imageMatch = this.result.imageMatches(i);
const option = document.createElement('option');
- option.setAttribute('value', i + 1);
+ option.setAttribute('value', (i + 1).toString());
option.innerText =
`Show image ${i} features (${imageMatch.matchesLength()})`;
this.select.appendChild(option);