https://serverless-stack.com/ logo
#sst
Title
# sst
a

Adrián Mouly

08/28/2021, 6:41 AM
I’m getting this warning, but what is supposed to be the type on those
catch
? Looks like has to be
any
or
unknown
but the linter doesn’t allow it.
Copy code
71:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
r

Ross Coundon

08/28/2021, 7:37 AM
Type it as unknown i.e.
catch(err: unknown)
Then either use a type guard
Copy code
if(err instanceof BaseError) {
  // do stuff
}
or cast it
Copy code
const error = err as BaseError
a

Adrián Mouly

08/28/2021, 7:37 AM
Ah, yeah, so I should type is as unknown to avoid any?
r

Ross Coundon

08/28/2021, 7:41 AM
Yeah
a

Adrián Mouly

08/28/2021, 7:43 AM
Cool thanks!
r

Ross Coundon

08/28/2021, 7:43 AM
No worries 😄
f

Frank

08/28/2021, 6:15 PM
Really envy ppl who knows their TS stuff 🤒
2 Views