瀏覽代碼

Add undefined check to avoid TS2532

tags/v0.1.3
bertieb 3 年之前
父節點
當前提交
1696f38ceb
共有 1 個檔案被更改,包括 5 行新增1 行删除
  1. +5
    -1
      src/ts/frontend.ts

+ 5
- 1
src/ts/frontend.ts 查看文件

@@ -226,7 +226,11 @@ function generateTables(rollstats: RollStats): void {
let tb = $("#outcomeTable").find("tbody");
let outcome: Outcomes = okeys[i] as Outcomes;
let outcomeCount = rollstats.outcomeCounts[outcome];
let outcomePercent = (outcomeCount / rollstats.numRolls * 100).toFixed(2);
let outcomePercent: string = "";
if (outcomeCount) {
// Needed to avoid TS2532:
outcomePercent = (outcomeCount / rollstats.numRolls * 100).toFixed(2);
}
tb.append(`<tr> <td>${outcome}</td>
<td>${outcomeCount}</td>
<td>${outcomePercent}</td>


Loading…
取消
儲存