chore(types): Keep intelisense while being more loosen (#10657)
**What** Keep the autocompletion for the fields API in Query APIs while being more flexible in order to prevent limitation from our depth limit but also to be more flexible when assigning string[] coming from the API for example.
This commit is contained in:
committed by
GitHub
parent
9133957a94
commit
048620884b
5
.changeset/pink-ways-count.md
Normal file
5
.changeset/pink-ways-count.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/types": patch
|
||||
---
|
||||
|
||||
chore(types): Keep intelisense while being more loosen
|
||||
@@ -14,20 +14,21 @@ describe("RemoteQuery", () => {
|
||||
it("should return the correct type for fields when using a string entry point", () => {
|
||||
type Result = RemoteQueryObjectConfig<"simple_product">["fields"]
|
||||
expectTypeOf<Result>().toEqualTypeOf<
|
||||
(
|
||||
| "*"
|
||||
| "id"
|
||||
| "handle"
|
||||
| "title"
|
||||
| "variants.id"
|
||||
| "variants.*"
|
||||
| "sales_channels.id"
|
||||
| "sales_channels.*"
|
||||
| "sales_channels.name"
|
||||
| "sales_channels_link.*"
|
||||
| "sales_channels_link.product_id"
|
||||
| "sales_channels_link.sales_channel_id"
|
||||
)[]
|
||||
| (
|
||||
| "*"
|
||||
| "id"
|
||||
| "handle"
|
||||
| "title"
|
||||
| "variants.id"
|
||||
| "variants.*"
|
||||
| "sales_channels.id"
|
||||
| "sales_channels.*"
|
||||
| "sales_channels.name"
|
||||
| "sales_channels_link.*"
|
||||
| "sales_channels_link.product_id"
|
||||
| "sales_channels_link.sales_channel_id"
|
||||
)[]
|
||||
| string[]
|
||||
>()
|
||||
})
|
||||
|
||||
|
||||
@@ -11,9 +11,11 @@ export type RemoteQueryObjectConfig<TEntry extends string> = {
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
> extends never
|
||||
? string[]
|
||||
: ObjectToRemoteQueryFields<
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
>[]
|
||||
:
|
||||
| ObjectToRemoteQueryFields<
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
>[]
|
||||
| string[]
|
||||
}
|
||||
|
||||
export type RemoteQueryObjectFromStringResult<
|
||||
@@ -36,9 +38,11 @@ export type RemoteQueryInput<TEntry extends string> = {
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
> extends never
|
||||
? string[]
|
||||
: ObjectToRemoteQueryFields<
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
>[]
|
||||
:
|
||||
| ObjectToRemoteQueryFields<
|
||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
||||
>[]
|
||||
| string[]
|
||||
/**
|
||||
* Pagination configurations for the returned list of items.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user