Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 26, 2023
1 parent d2dcba1 commit 6a6ddf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/runtime/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ export function defineCachedEventHandler<
>(
handler: EventHandler<Request, Response>,
opts?: CachedEventHandlerOptions<Response>
): EventHandler<Omit<Request, 'body'>, Response>;
): EventHandler<Omit<Request, "body">, Response>;
// TODO: remove when appropriate
// This signature provides backwards compatibility with previous signature where first generic was return type
export function defineCachedEventHandler<
Request = Omit<EventHandlerRequest, 'body'>,
Request = Omit<EventHandlerRequest, "body">,
Response = EventHandlerResponse,
>(
handler: EventHandler<
Expand Down
13 changes: 9 additions & 4 deletions test/fixture/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,15 @@ describe("defineCachedEventHandler", () => {
>();
});
it("should not allow typed input body", () => {
const b = defineCachedEventHandler<{ body: string }, Promise<{ message: string }>>(fixture);
// eslint-disable-next-line @typescript-eslint/ban-types
expectTypeOf(b).toEqualTypeOf<EventHandler<{}, Promise<{ message: string }>>>()
})
const b = defineCachedEventHandler<
{ body: string },
Promise<{ message: string }>
>(fixture);
expectTypeOf(b).toEqualTypeOf<
// eslint-disable-next-line @typescript-eslint/ban-types
EventHandler<{}, Promise<{ message: string }>>
>();
});
it("is backwards compatible with old generic signature", () => {
const a = defineCachedEventHandler<
Promise<{
Expand Down

0 comments on commit 6a6ddf2

Please sign in to comment.