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
+1 -1
View File
@@ -44,7 +44,7 @@
"tslint": "^6.1.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^2.9.2"
"typescript": "^4.4.2"
},
"lint-staged": {
"src/**/*.{ts,tsx,json,css}": [
+1 -1
View File
@@ -487,7 +487,7 @@ export class Connection {
this.clean();
// Force reload from the server
setTimeout(() => window.location.reload(true), 3000);
setTimeout(() => window.location.reload(), 3000);
}
private clean() {
+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;
}
+4 -4
View File
@@ -9467,10 +9467,10 @@ typedarray@^0.0.6:
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==
typescript@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
uglify-es@^3.3.4:
version "3.3.9"