From 7c3b7b2018f9fe3538c632ada2f95e665b3b0e38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 02:59:42 +0000 Subject: [PATCH 1/3] Bump typescript from 3.9.7 to 4.5.4 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.7 to 4.5.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v3.9.7...v4.5.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd63f0e7..6cc57068 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11539,9 +11539,9 @@ } }, "typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", + "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", "dev": true }, "union-value": { diff --git a/package.json b/package.json index 2bd66898..dd727f18 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ "nock": "^10.0.6", "prettier": "^2.5.1", "ts-jest": "^26.4.4", - "typescript": "^3.9.7" + "typescript": "^4.5.4" } } From 93ecf41b2b21e2b813b3719d05f2f9ceed25af79 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 6 Jan 2022 02:13:05 -0800 Subject: [PATCH 2/3] Narrow caught exceptions The update from TypeScript 3.9.7 to 4.5.4 brings increased type strictness (introduced in 4.4). Previously, exceptions were used in some catch blocks based on an assumption of their type. But exceptions can have any type and that now results in errors (TS2345, TS2571). This is fixed by narrowing the exceptions to the expected type before using them as such. --- src/installer.ts | 4 +++- src/main.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index 5575621a..4d1481d8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -67,7 +67,9 @@ async function downloadRelease(version: string): Promise { const token: string = core.getInput("token", { required: true }); downloadPath = await tc.downloadTool(downloadUrl, undefined, token); } catch (error) { - core.debug(error); + if (typeof error === "string" || error instanceof Error) { + core.debug(error.toString()); + } throw `Failed to download version ${version}: ${error}`; } diff --git a/src/main.ts b/src/main.ts index a3900f2f..cd809914 100644 --- a/src/main.ts +++ b/src/main.ts @@ -58,7 +58,11 @@ async function run() { await exec.exec(toolPath, execArgs, options); } catch (error) { - core.setFailed(error.message); + if (error instanceof Error) { + core.setFailed(error.message); + } else { + throw error; + } } } From 218fa3c7bc256803e4b1b7328e9eca6707e13ef4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 10 Jan 2022 02:43:34 -0800 Subject: [PATCH 3/3] Repackage action after TypeScript update ``` npm run build npm run pack ``` --- dist/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5c4ba6cb..f9b77cdc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -22,7 +22,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -96,7 +96,9 @@ function downloadRelease(version) { downloadPath = yield tc.downloadTool(downloadUrl, undefined, token); } catch (error) { - core.debug(error); + if (typeof error === "string" || error instanceof Error) { + core.debug(error.toString()); + } throw `Failed to download version ${version}: ${error}`; } // Extract @@ -243,7 +245,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -302,13 +304,18 @@ function run() { } const options = { env: { - ARDUINO_LINT_OFFICIAL: official, + ARDUINO_LINT_OFFICIAL: official, // The official mode is set via an environment variable. }, }; yield exec.exec(toolPath, execArgs, options); } catch (error) { - core.setFailed(error.message); + if (error instanceof Error) { + core.setFailed(error.message); + } + else { + throw error; + } } }); }