postgrest-js: Unable to import helper types since 1.15.6
Bug report
Describe the bug
Before 1.15.6 it was possible to import helper types from @supabase/postgrest-js to perform type mappings etc. like this:
import type { GetResult } from "@supabase/postgrest-js/dist/module/select-query-parser";
export type TablesSelect<
Schema extends GenericSchema,
TableName extends keyof Schema['Tables'],
Query extends string,
> = GetResult<
Schema,
Schema['Tables'][TableName]['Row'],
TableName,
Schema['Tables'][TableName] extends { Relationships: infer R } ? R : never,
Query
>;
However, starting from version 1.15.6 with the change to the package build (package.json etc), it became impossible to import any files from subdirectories of the build because of the exports configuration.
Expected behavior
All types of the library which are publicly exposed as part of generics, function arguments and whatsoever should be properly exported imho so that it is possible to properly type code depending on postgrest-js.
The easiest solution would probably be to export helper types through some namespace from index.ts.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 17 (6 by maintainers)
Thanks all, seems like a proper support is needed here. I’ll see if this can be accomplished with the already exported QueryResult or, failing that, we’ll reexport GetResult
The use case is exactly as described above: To generate types for table selects.
For example to write a component that accepts some data which has been selected somewhere else:
This is extremly useful and currently prevents us from upgrading supabase client as this is not possible anymore now. It also makes sense, as the other helper types (
Tables,TablesInsert,TablesUpdate) are available, but no type is exported to get a subset of a table. Instead of exposing the internal type likeGetResult, I would like even more for aTablesSelecttype to be exported for everyone to use as part of the public API because it is extremely useful.As an additional +1 here, I also want to mention that this is used by
supabase-cache-helperswhich has a full video on the Supabase YouTube channelYea this is holding me up on upgrading as well, we have as PR #560 at your convenience
Hey, sorry to bother you @soedirgo, but think this might be implemented? I mean we are not talking about any large feature, just about exporting an already existing type (either directly, with an
Unstable_prefix or through a proper helper) which otherwise blocks quite a few users from upgrading their version of postgrest-js. I would make a PR, but that wouldn’t make sense without a decision on someone from the maintainer side on which solution to opt for yet I think.Hi all, in an attempt to help move things along I made a simple PR. Let me know if this can be improved 😃
#560