diff --git a/package.json b/package.json index 0193a82..6a5dec3 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "scripts": { "test": "npm run test --workspace=packages/safe-chain --workspace=packages/safe-chain-bun", "test:e2e": "npm run test --workspace=test/e2e", - "lint": "npm run lint --workspace=packages/safe-chain" + "lint": "npm run lint --workspace=packages/safe-chain", + "typecheck": "npm run typecheck --workspace=packages/safe-chain" }, "repository": { "type": "git", diff --git a/packages/safe-chain/src/environment/userInteraction.js b/packages/safe-chain/src/environment/userInteraction.js index 14fbc4a..3222874 100644 --- a/packages/safe-chain/src/environment/userInteraction.js +++ b/packages/safe-chain/src/environment/userInteraction.js @@ -8,6 +8,9 @@ import { LOGGING_VERBOSE, } from "../config/settings.js"; +/** + * @type {{ bufferOutput: boolean, bufferedMessages:(() => void)[]}} + */ const state = { bufferOutput: false, bufferedMessages: [], @@ -72,12 +75,21 @@ function writeExitWithoutInstallingMaliciousPackages() { writeOrBuffer(() => console.error(message)); } +/** + * @param {string} message + * @param {...any} optionalParams + * @returns {void} + */ function writeVerbose(message, ...optionalParams) { if (!isVerboseMode()) return; writeOrBuffer(() => console.log(message, ...optionalParams)); } +/** + * + * @param {() => void} messageFunction + */ function writeOrBuffer(messageFunction) { if (state.bufferOutput) { state.bufferedMessages.push(messageFunction); diff --git a/packages/safe-chain/src/main.js b/packages/safe-chain/src/main.js index feb5156..eea9257 100644 --- a/packages/safe-chain/src/main.js +++ b/packages/safe-chain/src/main.js @@ -21,7 +21,6 @@ export async function main(args) { // Global error handlers to log unhandled errors process.on("uncaughtException", (error) => { ui.writeError(`Safe-chain: Uncaught exception: ${error.message}`); - // @ts-expect-error writeVerbose will be added in a future PR ui.writeVerbose(`Stack trace: ${error.stack}`); process.exit(1); }); @@ -29,7 +28,6 @@ export async function main(args) { process.on("unhandledRejection", (reason) => { ui.writeError(`Safe-chain: Unhandled promise rejection: ${reason}`); if (reason instanceof Error) { - // @ts-expect-error writeVerbose will be added in a future PR ui.writeVerbose(`Stack trace: ${reason.stack}`); } process.exit(1);