Fix compile errors introduced by typescript 4.4.2

4.4.2 introduces a breaking change that the variable in a catch clause
is now `unknown` type. So, we need to cast the `e`, `err`, or `error`
variables to type `Error`.
This commit is contained in:
Andrew Eisenberg 2021-09-10 13:53:13 -07:00
parent 5b28adb7ed
commit 40568daca8
83 changed files with 601 additions and 576 deletions

5
lib/util.js generated
View file

@ -44,7 +44,8 @@ function getExtraOptionsEnvParam() {
return JSON.parse(raw);
}
catch (e) {
throw new Error(`${varName} environment variable is set, but does not contain valid JSON: ${e.message}`);
const message = e instanceof Error ? e.message : String(e);
throw new Error(`${varName} environment variable is set, but does not contain valid JSON: ${message}`);
}
}
exports.getExtraOptionsEnvParam = getExtraOptionsEnvParam;
@ -222,7 +223,7 @@ async function getGitHubVersion(apiDetails) {
}
// Doesn't strictly have to be the meta endpoint as we're only
// using the response headers which are available on every request.
const apiClient = api_client_1.getApiClient(apiDetails);
const apiClient = (0, api_client_1.getApiClient)(apiDetails);
const response = await apiClient.meta.get();
// This happens on dotcom, although we expect to have already returned in that
// case. This can also serve as a fallback in cases we haven't foreseen.