gajus / slonik

A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.
Other
4.56k stars 138 forks source link

Slonik Errors override with native errors #567

Closed seriouslag closed 4 months ago

seriouslag commented 5 months ago

Slonik custom errors have a property cause.

Native error objects in ES2022 added a cause property.

Expected Behavior

Use native ES2022 types

Current Behavior

Typescript issues an error if the target is set to ES2022 when using Slonik.

Possible Solution

Use native ES2022 types

Steps to Reproduce

Set tsconfig target to ES2022

node_modules/slonik/src/errors.ts:133:10 - error TS2612: Property 'cause' will overwrite the base property in 'SlonikError'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.

       133   public cause?: Error;

Logs