frontend: Upgrade TypeScript from 2.9.2 to 4.4.2 (#387)

* Upgrade TS from 2.9.2 to 4.4.2

* Avoid mutating a readonly array

`list` is a readonly array but `sort` will mutate the array in-place.
In newer version of TS, it can catch this unexpected behavior.

To avoid mutating a readonly array, we can sort with a new array with
either `[...list]` or `list.slice()`.

* Fix arguments of `window.location.reload`

The `reload` function type definition in `lib.dom.d.ts` takes 0
arguments now. So, we cannot pass a boolean to it.

Also, based on the documentation on MDN, Firefox is the only browser who
supports passing a `forceForget` boolean to `reload` function.
So, I wonder it should be fine to remove the boolean argument and align
the behavior to other browsers.

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
This commit is contained in:
cybai
2021-08-28 00:33:42 +09:00
committed by GitHub
parent 87866b2d42
commit d477cb8045
4 changed files with 9 additions and 7 deletions
+3 -1
View File
@@ -119,7 +119,9 @@ export class NumStats<T extends number> {
let sum = 0;
for (const n of list.sort((a, b) => a - b).slice(extremes, -extremes)) {
for (const n of [...list]
.sort((a, b) => a - b)
.slice(extremes, -extremes)) {
sum += n;
}