I am running nodejs 16.9.0 via the global n npm package. I have the latest typescript as a dependency in my project and my TS config is targeting esnext
Despite all this, I cannot seem to use the 'new' Error handing feature which was apparently added to node a while ago.
Compiling my project with tsc fails and in VS Code, even after restarting the TS server I get the following error with the test code below
const test = new Error('Error one')
new Error('test', { cause: test })
Expected 0-1 arguments, but got 2.ts(2554)
The same issue happens on the latest node.js 17.2.0
tsconfig.json
{
"compilerOptions": {
"strict": true,
"target": "esnext",
"module": "commonjs"
}
}
package.json
"devDependencies": {
"@types/node": "^16.11.12",
"typescript": "^4.5.4"
}
Although it seems to have been merged into nodejs, the v8 page seems to indicate support is still lacking. However I can use other 'modern' features such at the at() function on Array prototypes.