Skip to content

Commit

Permalink
fix: typescript error on install
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Jul 1, 2024
1 parent e52bedd commit 20d3f0f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"build": "bsm",
"clean": "bsm",
"format": "bsm",
"postinstall": "bsm",
"lint": "bsm",
"prepublishOnly": "bsm build",
"semantic-release": "semantic-release",
Expand Down
7 changes: 5 additions & 2 deletions package.scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

module.exports = {
scripts: {
build: ["bsm clean", "tsc --project tsconfig.build.json"],
build: [
"ts-patch install",
"bsm clean",
"tsc --project tsconfig.build.json",
],
clean: "rimraf ./lib",
format: {
_default: "bsm ~.*",
Expand All @@ -16,7 +20,6 @@ module.exports = {
prettier: "prettier -c .",
typescript: "tsc --noEmit",
},
postinstall: ["ts-patch install"],
test: {
$env: "file:.env",
_ci: "jest --runInBand --forceExit --detectOpenHandles",
Expand Down
5 changes: 2 additions & 3 deletions src/AxiosHttpHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios, { Axios, AxiosRequestConfig, AxiosResponse } from "axios";
import debug from "debug";
import { HttpHandler } from "~/HttpHandler";
import { PrintOneOptions } from "~/PrintOne";
import { PrintOneDebugger, PrintOneOptions } from "~/PrintOne";

export class AxiosHTTPHandler extends HttpHandler<
AxiosRequestConfig,
Expand All @@ -12,7 +11,7 @@ export class AxiosHTTPHandler extends HttpHandler<
constructor(
token: string,
options: Required<PrintOneOptions>,
debug: debug.Debugger,
debug: PrintOneDebugger,
) {
super(token, options, debug);
this.client = axios.create({
Expand Down
7 changes: 3 additions & 4 deletions src/HttpHandler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import debug from "debug";
import { PrintOneError } from "~/errors/PrintOneError";
import { PrintOneOptions } from "~/PrintOne";
import { PrintOneDebugger, PrintOneOptions } from "~/PrintOne";

export abstract class HttpHandler<RequestOptions, Response> {
protected readonly debug: debug.Debugger;
protected readonly debug: PrintOneDebugger;

constructor(
token: string,
protected readonly options: Required<PrintOneOptions>,
debug: debug.Debugger,
debug: PrintOneDebugger,
) {
// We require these, so each extended class has type-safe auto-fill
token;
Expand Down
8 changes: 5 additions & 3 deletions src/PrintOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { IWebhookRequest } from "~/models/_interfaces/IWebhookRequest";
export type RequestHandler = new (
token: string,
options: Required<PrintOneOptions>,
debug: debug.Debugger,
debug: PrintOneDebugger,
) => HttpHandler<{ headers: Record<string, string> }, unknown>;
export type PrintOneOptions = Partial<{
url: string;
Expand All @@ -57,10 +57,12 @@ const DEFAULT_OPTIONS: Required<PrintOneOptions> = {
client: AxiosHTTPHandler,
};

export type PrintOneDebugger = (formatter: unknown, ...args: unknown[]) => void;

export type Protected = {
client: HttpHandler<unknown, unknown>;
options: Required<PrintOneOptions>;
debug: debug.Debugger;
debug: PrintOneDebugger;
printOne: PrintOne;
};

Expand Down Expand Up @@ -98,7 +100,7 @@ export class PrintOne {
return this.protected.client;
}

protected get debug(): debug.Debugger {
protected get debug(): PrintOneDebugger {
return this.protected.debug;
}

Expand Down

0 comments on commit 20d3f0f

Please sign in to comment.