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

Export types #287

Open
2 tasks done
maxijonson opened this issue May 4, 2024 · 0 comments
Open
2 tasks done

Export types #287

maxijonson opened this issue May 4, 2024 · 0 comments

Comments

@maxijonson
Copy link

maxijonson commented May 4, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Feature Request

Whenever I need a type from groqd, I often need to either copy it from the declarations file myself or make an arbitrary query to extract it's type:

// src/utils/groqd.types.ts
// copied from index.d.ts
export type WithAssetOption =
  | "base"
  | "dimensions"
  | "location"
  | "lqip"
  | "palette"
  | "isOpaque"
  | "hasAlpha"
  | "blurHash";

const unknownArrayQuery = q("").filter();
export type UnknownArrayQuery = typeof unknownArrayQuery;

const entityQuery = q("").filter().slice(0);
export type EntityQuery = typeof entityQuery;

It would be nice if the library exported its types, not only to make it simpler to build wrappers around it, but also to make sure that we don't end up with outdated types on our end after updating groqd.

Currently, these are the only things that can be imported:

import {
  q,
  z,
  sanityImage,
  makeSafeQueryRunner,
  nullToUndefined,
  pipe, // Not sure what this is, it's not documented anywhere
  type BaseQuery,
  type GroqdParseError,
  type InferType,
  type Selection,
  type TypeFromSelection,
} from "groqd";
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

1 participant