Skip to content

Commit 664cbd9

Browse files
committed
REF: TypescriptAPI instantiated by IntegrationBase::constructor().
1 parent 12723a4 commit 664cbd9

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

express-zod-api/src/integration-base.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type SSEShape = ReturnType<typeof makeEventSchema>["shape"];
1111
type Store = Record<IOKind, ts.TypeNode>;
1212

1313
export abstract class IntegrationBase {
14+
/** @internal */
15+
protected readonly api: TypescriptAPI;
1416
/** @internal */
1517
protected paths = new Set<string>();
1618
/** @internal */
@@ -22,10 +24,11 @@ export abstract class IntegrationBase {
2224
>();
2325

2426
protected constructor(
25-
/** @internal */
26-
protected readonly api: TypescriptAPI,
27+
typescript: typeof ts,
2728
protected readonly serverUrl: string,
28-
) {}
29+
) {
30+
this.api = new TypescriptAPI(typescript);
31+
}
2932

3033
readonly #ids = {
3134
pathType: "Path",

express-zod-api/src/integration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { loadPeer } from "./peer-helpers";
88
import { Routing } from "./routing";
99
import { OnEndpoint, walkRouting, withHead } from "./routing-walker";
1010
import { HandlingRules } from "./schema-walker";
11-
import { TypescriptAPI } from "./typescript-api";
1211
import { zodToTs } from "./zts";
1312
import { ZTSContext } from "./zts-helpers";
1413
import type Prettier from "prettier";
@@ -92,7 +91,7 @@ export class Integration extends IntegrationBase {
9291
noContent = z.undefined(),
9392
hasHeadMethod = true,
9493
}: IntegrationParams) {
95-
super(new TypescriptAPI(typescript), serverUrl);
94+
super(typescript, serverUrl);
9695
const commons = { makeAlias: this.#makeAlias.bind(this), api: this.api };
9796
const ctxIn = { brandHandling, ctx: { ...commons, isResponse: false } };
9897
const ctxOut = { brandHandling, ctx: { ...commons, isResponse: true } };

0 commit comments

Comments
 (0)