Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct typings for go({data: "raw"}) #456

Open
xamogh opened this issue Dec 25, 2024 · 2 comments
Open

Correct typings for go({data: "raw"}) #456

xamogh opened this issue Dec 25, 2024 · 2 comments

Comments

@xamogh
Copy link

xamogh commented Dec 25, 2024

Describe the bug
Correct typings for data returned by entity when {data: "raw"} is provided
ElectroDB Version
3.0.1

Is it possible to do something like:

type GoGetTerminal<
  A extends string,
  F extends string,
  C extends string,
  S extends Schema<A, F, C>,
  ResponseItem,
> = <Options extends GoQueryTerminalOptions<keyof ResponseItem>>(
  options?: Options,
) => Options extends { data: "raw" }
  ? Promise<{
      data: {
        $metadata: {
          httpStatusCode: number;
          requestId: string;
          extendedRequestId: string | undefined;
          cfId: string | undefined;
          attempts: number;
          totalRetryDelay: number;
        };
        Item?: ResponseItem;
      };
    }>
  : Options extends GoQueryTerminalOptions<infer Attr>
    ? Promise<{
        data:
          | {
              [Name in keyof ResponseItem as Name extends Attr
                ? Name
                : never]: ResponseItem[Name];
            }
          | null;
      }>
    : Promise<{ data: ResponseItem | null }>;

@xamogh
Copy link
Author

xamogh commented Dec 25, 2024

Or at the very least it should have "unknown".

type GoGetTerminal<
  A extends string,
  F extends string,
  C extends string,
  S extends Schema<A, F, C>,
  ResponseItem,
> = <Options extends GoQueryTerminalOptions<keyof ResponseItem>>(
  options?: Options,
) => Options extends { data: "raw" }
  ? unknown
  : Options extends GoQueryTerminalOptions<infer Attr>
    ? Promise<{
        data:
          | {
              [Name in keyof ResponseItem as Name extends Attr
                ? Name
                : never]: ResponseItem[Name];
            }
          | null;
      }>
    : Promise<{ data: ResponseItem | null }>;

@tywalch
Copy link
Owner

tywalch commented Dec 30, 2024

It is definitely possible, though it hasn't been prioritized for bandwidth reasons at the current moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants