From 7deb71215cbb05fbfaef1d3f650e31e0666aab01 Mon Sep 17 00:00:00 2001 From: skarab42 Date: Sat, 9 Apr 2022 16:32:22 +0200 Subject: [PATCH] fix: build target --- src/index.ts | 7 +++++-- tsconfig.json | 2 +- tsup.config.ts | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index fb8c1d1..91b9936 100644 --- a/src/index.ts +++ b/src/index.ts @@ -103,7 +103,7 @@ export class PojoError< readonly type: TType; readonly args: TArgs; readonly data: TPojo; - readonly cause?: Error | undefined; + override readonly cause?: Error; constructor( type: TType, @@ -116,10 +116,13 @@ export class PojoError< this.type = type; this.args = args; this.data = data; - this.cause = options.cause; this.message = data.message; this.name = this.constructor.name; + // @ts-expect-error error TS2412: Type 'Error | undefined' is not + // assignable to type 'Error' with 'exactOptionalPropertyTypes: true'. + this.cause = options.cause; + if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, options.constructorOpt); } diff --git a/tsconfig.json b/tsconfig.json index c9f35bc..e9a358a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "compilerOptions": { // [Language and Environment] - "target": "ES2015", + "target": "esnext", // [Modules] "rootDir": ".", diff --git a/tsup.config.ts b/tsup.config.ts index 68ed5ba..c4c557c 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from "tsup"; export default defineConfig({ entry: ["src/index.ts"], format: ["cjs", "esm"], + target: "esnext", outDir: "dist", splitting: true, sourcemap: true,