From d78ea42efdaafc541ca46b3fe7fa6b0d304d3933 Mon Sep 17 00:00:00 2001 From: Alex Gawley Date: Fri, 17 Jan 2025 10:10:56 +0000 Subject: [PATCH] Fix EnhancePreflightFn signature --- index.d.ts | 8 ++++---- index.test-d.ts | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 38ed766..0d1c0df 100644 --- a/index.d.ts +++ b/index.d.ts @@ -90,7 +90,7 @@ export type EnhanceElemArg = { export type EnhanceApiFn = ( /** The parsed HTTP request */ - request: EnhanceApiReq, + request: EnhanceApiReq ) => Promise | EnhanceApiRes; export type EnhanceApiFnChain = EnhanceApiFn[]; @@ -112,6 +112,6 @@ export type EnhanceElemFn = (payload: EnhanceElemArg) => EnhanceElemResult; export type EnhancePageFn = EnhanceElemFn; -export type EnhancePreflightFn = ( - payload: EnhanceApiReq, -) => Promise> | Record; +export type EnhancePreflightFn = ({ + req: EnhanceApiReq, +}) => Promise> | Record; diff --git a/index.test-d.ts b/index.test-d.ts index cb114c3..0980162 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,3 @@ -import { expectError } from "tsd"; import type { EnhanceApiFn, EnhanceApiFnChain, @@ -10,8 +9,10 @@ import type { EnhancePreflightFn, } from "."; +import { expectError } from "tsd"; + // Preflight -export const preflight: EnhancePreflightFn = function (req) { +export const preflight: EnhancePreflightFn = function ({ req }) { const { method, path } = req; const title = `Todos — ${path} `; console.log(`Handling ${method} ${path}...`); @@ -41,7 +42,7 @@ export const get: EnhanceApiFn = function (request) { (invalidResponse = { json: { foo: "bar" }, body: "", - }), + }) ); return {