booster icon indicating copy to clipboard operation
booster copied to clipboard

lerna run compile fails at framework-common-helpers package

Open vomaksh opened this issue 3 years ago • 3 comments

Bug Report

Current Behavior

When I run lerna run compile then I get the following error:

lerna ERR! npm run compile exited 1 in '@boostercloud/framework-common-helpers'
lerna ERR! npm run compile stdout:

> @boostercloud/[email protected] compile /home/shiroyasha/Documents/community/booster/packages/framework-common-helpers
> tsc -b tsconfig.json

src/retrier.ts(18,23): error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'Error'.
src/retrier.ts(19,7): error TS2322: Type 'unknown' is not assignable to type 'Error | undefined'.
  Type 'unknown' is not assignable to type 'Error'.

Expected behavior

lerna run compile shouldn't give an error

Possible Solution

I think the following if condition in catch block will solve the above problem

if (e instanceof Error) {
 ...
}

Additional information

Environment

  • Node/npm version: Node v14.18.1/npm 6.14.15
  • OS: Ubuntu 21.10

vomaksh avatar Jan 14 '22 18:01 vomaksh

You are right! This is due to a new feature in TypeScript :)

You can do either that or cast it like:

...
} catch (err) {
  const e = err as Error
  ...
}

NickSeagull avatar Jan 18 '22 09:01 NickSeagull

Hey @iyorozuya, do you want to open a PR solving this issue? That would be great ❤️

jesusAlvSoto avatar Jan 21 '22 16:01 jesusAlvSoto

I was fixing other compile errors when running lerna run compile. Definitely opening PR for fixing this issue.

vomaksh avatar Jan 21 '22 20:01 vomaksh