Context
Hi, I have a NodeJs+Ts+Architect setup for building and deploying lambda functions. Architect uses typescript plugin to compile typescript. I am trying to use Error class to throw errors.
However, Typescript is picking up Error type from
/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.es5.d.ts
.
In the image below, please note the constructor signature only accepts message
field. And the error interface does not have an options
object either. Please
look at Browser Error Class or NodeJs Error Class to see the signatures.
Node Error has the following constructor signature and Error interface.
Problem
Possible Solutions which I know
I hope the question made sense. Would appreciate if there is a nicer way to solve this, but I am not getting ample discussions on Architect+Ts+NodeJs.
The cause
option was introduced in ES2022
. You would need to use at least that version for your lib types.
Change the lib
version in your tsconfig.json
to:
"compilerOptions": { "lib": ["es2022"] }