diff --git a/package.json b/package.json index b13cb9a..523c704 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "main": "./dist/index.js", "types": "./src/index.ts", "scripts": { - "build": "tsup", + "build": "tsup && tsc --declaration --emitDeclarationOnly --declarationDir dist --noEmit false", "lint": "eslint src --fix", "prettier": "prettier --write src/**/*.ts", "start": "npm run build && node --trace-warnings --enable-source-maps .", - "test": "eslint src && tsc --noEmit && tsup _test.ts --format esm && node dist/_test.mjs", + "test": "eslint src && tsc && tsup _test.ts --format esm && node dist/_test.mjs", "postinstall": "npm run build" }, "repository": { diff --git a/src/structures/Tassa.ts b/src/structures/Tassa.ts index e77ce1b..5f0d4eb 100644 --- a/src/structures/Tassa.ts +++ b/src/structures/Tassa.ts @@ -49,8 +49,14 @@ export class Tassa extends Base { patch(data: Data) { if (this.isJson(data)) { this.handleJson(data); - this.dataCreazione = data.dataCreazione && new Date(data.dataCreazione); - this.dataPagamento = data.dataPagamento && new Date(data.dataPagamento); + this.dataCreazione = + data.dataCreazione === undefined + ? undefined + : new Date(data.dataCreazione); + this.dataPagamento = + data.dataPagamento === undefined + ? undefined + : new Date(data.dataPagamento); this.scadenza = new Date(data.scadenza); } else { if (data.dataCreazione != null) diff --git a/src/types/general.ts b/src/types/general.ts index ed04651..2419819 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -97,26 +97,31 @@ export type ClientOptions = Partial< } | null; } >; -export type Jsonify = [ - T, - D -] extends [ - { - toJSON(): infer J; - }, - true -] - ? Jsonify +export type Jsonify = D extends true + ? Jsonify< + T extends { + toJSON(): infer J; + } + ? J + : T, + false + > : T extends boolean | number | string | null ? T : T extends bigint ? never : T extends symbol | ((...args: any[]) => any) | undefined - ? N extends true - ? never - : undefined + ? undefined + : T extends (infer A)[] + ? Jsonify[] : { - [K in keyof T]: Jsonify; + [K in keyof T as T[K] extends + | bigint + | symbol + | ((...args: any[]) => any) + | undefined + ? never + : K]: Jsonify; }; export type LoginLink = { url: string; diff --git a/tsconfig.json b/tsconfig.json index 2ffb7c8..1e5b637 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,14 @@ "include": ["src/**/*"], "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { - "moduleResolution": "node", "allowSyntheticDefaultImports": true, "allowUnreachableCode": false, "alwaysStrict": true, "esModuleInterop": true, "isolatedModules": true, + "module": "ESNext", + "moduleResolution": "node", + "noEmit": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitReturns": true, @@ -17,7 +19,6 @@ "outDir": "dist", "pretty": true, "resolveJsonModule": true, - "sourceMap": true, - "module": "ESNext" + "sourceMap": true } } diff --git a/tsup.config.ts b/tsup.config.ts index 329eb2e..33afe66 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -10,7 +10,6 @@ const options: Options = { minify: true, keepNames: true, sourcemap: true, - dts: true, }; export default defineConfig(options);