Merge changes Iaba47567,I2387d566
* changes:
Update Typescript version to 4.1.4
Fixes for Typescript 4.2
diff --git a/package.json b/package.json
index 7f4ac44..3c40690 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
"prettier": "2.0.5",
"rollup": "^2.3.4",
"terser": "^4.8.0",
- "typescript": "4.0.5"
+ "typescript": "4.1.4"
},
"scripts": {
"clean": "git clean -fdx && bazel clean --expunge",
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
index 7b43dfc..80c58ca 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
@@ -297,9 +297,18 @@
}
// Restore inheritFrom.
if (this._inheritsFrom) {
- this._inheritsFrom = {...this.originalInheritsFrom};
- this._inheritFromFilter =
- 'name' in this._inheritsFrom ? this._inheritsFrom.name : undefined;
+ // Can't assign this._inheritsFrom = {...this.originalInheritsFrom}
+ // directly, because this._inheritsFrom is declared as
+ // '...|null|undefined` and typescript reports error when trying
+ // to access .name property (because 'name' in null and 'name' in undefined
+ // lead to runtime error)
+ // After migrating to Typescript v4.2 the code below can be rewritten as
+ // const copy = {...this.originalInheritsFrom};
+ const copy: ProjectInfo | {} = this.originalInheritsFrom
+ ? {...this.originalInheritsFrom}
+ : {};
+ this._inheritsFrom = copy;
+ this._inheritFromFilter = 'name' in copy ? copy.name : undefined;
}
if (!this._local) {
return;
diff --git a/polygerrit-ui/app/utils/date-util.ts b/polygerrit-ui/app/utils/date-util.ts
index 3af8c59..a780af5 100644
--- a/polygerrit-ui/app/utils/date-util.ts
+++ b/polygerrit-ui/app/utils/date-util.ts
@@ -90,15 +90,6 @@
const diff = now.valueOf() - date.valueOf();
return diff < 180 * Duration.DAY;
}
-interface Options {
- month?: string;
- year?: string;
- day?: string;
- hour?: string;
- hour12?: boolean;
- minute?: string;
- second?: string;
-}
// TODO(dmfilippov): TS-Fix review this type. All fields here must be optional,
// but this require some changes in the code. During JS->TS migration
@@ -118,7 +109,7 @@
}
export function formatDate(date: Date, format: string) {
- const options: Options = {};
+ const options: Intl.DateTimeFormatOptions = {};
if (format.includes('MM')) {
if (format.includes('MMM')) {
options.month = 'short';
diff --git a/tools/node_tools/package.json b/tools/node_tools/package.json
index bfc5191..2f33078 100644
--- a/tools/node_tools/package.json
+++ b/tools/node_tools/package.json
@@ -16,7 +16,7 @@
"rollup": "^2.3.4",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.3",
- "typescript": "4.0.5"
+ "typescript": "4.1.4"
},
"devDependencies": {},
"license": "Apache-2.0",
diff --git a/tools/node_tools/yarn.lock b/tools/node_tools/yarn.lock
index 767f285..abb54b0 100644
--- a/tools/node_tools/yarn.lock
+++ b/tools/node_tools/yarn.lock
@@ -7893,10 +7893,10 @@
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
-typescript@4.0.5:
- version "4.0.5"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
- integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
+typescript@4.1.4:
+ version "4.1.4"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.4.tgz#f058636e2f4f83f94ddaae07b20fd5e14598432f"
+ integrity sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg==
typical@^2.6.0, typical@^2.6.1:
version "2.6.1"
diff --git a/yarn.lock b/yarn.lock
index adb731c..d18d5fd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9680,10 +9680,10 @@
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
-typescript@4.0.5:
- version "4.0.5"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
- integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
+typescript@4.1.4:
+ version "4.1.4"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.4.tgz#f058636e2f4f83f94ddaae07b20fd5e14598432f"
+ integrity sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg==
typical@^2.6.1:
version "2.6.1"