Skip to content

Instantly share code, notes, and snippets.

@andreypopp
Created January 22, 2023 18:16
Show Gist options
  • Save andreypopp/81106f00291d3894d287e8534d24ab4c to your computer and use it in GitHub Desktop.
Save andreypopp/81106f00291d3894d287e8534d24ab4c to your computer and use it in GitHub Desktop.
diff --git a/nextjs-api/types.ts b/nextjs-api/types.ts
index c7a7b7b..bff8e10 100644
--- a/nextjs-api/types.ts
+++ b/nextjs-api/types.ts
@@ -28,29 +28,21 @@ export interface MakeEndpointConstruct<C, R, U, D> {
// TODO: How to make optional types work with generics?!
export interface EndpointConstructClient<C, R, U, D, URLParams> {
// FIXME - this is not working
- post?: C extends undefined
- ? undefined
- : (
+ post?: (
params: URLParams,
body: object
) => Promise<{ response: C | undefined; error: unknown }>;
// FIXME - this is not working
- get?: R extends undefined
- ? undefined
- : (
+ get?: (
params: URLParams
) => Promise<{ response: R | undefined; error: unknown }>;
// FIXME - this is not working
- update?: U extends undefined
- ? undefined
- : (
+ update?: (
params: URLParams,
body: object
) => Promise<{ response: U | undefined; error: unknown }>;
// FIXME - this is not working
- delete?: D extends undefined
- ? undefined
- : (
+ delete?: (
params: URLParams,
body?: object
) => Promise<{ response: D | undefined; error: unknown }>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment