Skip to content

Commit 43b0e34

Browse files
committed
In the types, require using $.response to build a response.
1 parent 8df7321 commit 43b0e34

5 files changed

Lines changed: 80 additions & 738 deletions

File tree

.changeset/neat-memes-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"counterfact": minor
3+
---
4+
5+
The type system no longer allows responses constructed without $.response

src/counterfact-types/generic-response-builder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ export type GenericResponseBuilder<
157157
: object extends OmitValueWhenNever<Omit<Response, "examples">>
158158
? COUNTERFACT_RESPONSE
159159
: keyof OmitValueWhenNever<Omit<Response, "examples">> extends "headers"
160-
? {
161-
ALL_REMAINING_HEADERS_ARE_OPTIONAL: COUNTERFACT_RESPONSE;
160+
? COUNTERFACT_RESPONSE & {
162161
header: HeaderFunction<Response>;
163162
}
164163
: GenericResponseBuilderInner<Response>;

src/typescript-generator/operation-type-coder.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ export class OperationTypeCoder extends TypeCoder {
304304
modulePath,
305305
);
306306

307-
return `($: OmitValueWhenNever<{ query: ${queryTypeName}, path: ${pathTypeName}, headers: ${headersTypeName}, cookie: ${cookieTypeName}, body: ${bodyType}, context: ${contextTypeImportName}, response: ${responseType}, x: ${xType}, proxy: ${proxyType}, user: ${this.userType()}, delay: ${delayType} }>) => MaybePromise<${this.responseTypes(
308-
script,
309-
)} | { status: 415, contentType: "text/plain", body: string } | COUNTERFACT_RESPONSE | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: COUNTERFACT_RESPONSE }>`;
307+
return `($: OmitValueWhenNever<{ query: ${queryTypeName}, path: ${pathTypeName}, headers: ${headersTypeName}, cookie: ${cookieTypeName}, body: ${bodyType}, context: ${contextTypeImportName}, response: ${responseType}, x: ${xType}, proxy: ${proxyType}, user: ${this.userType()}, delay: ${delayType} }>) => MaybePromise<COUNTERFACT_RESPONSE>`;
310308
}
311309
}

0 commit comments

Comments
 (0)