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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add Typescript support to filter by a multi-reference field #2220

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented May 9, 2024

Summary

Add Typescript support to filter by a multi-reference field, as it is supported in runtime

Description

Adding EntryFieldTypes.Array to the SupportedTypes type, used by ReferenceSearchFilters -> EntryFieldsQueries -> EntriesQueries -> getEntries().

Motivation and Context

Improve Typescript support on the library.

Todos

  • Implemented feature
  • Feature with pending implementation

Screenshots (if appropriate):

N/A

patch-package output

Thanks for your work on this project! 馃檪

Today I used patch-package to patch contentful@10.9.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/contentful/dist/types/types/query/reference.d.ts b/node_modules/contentful/dist/types/types/query/reference.d.ts
index 2ed780b..df64799 100644
--- a/node_modules/contentful/dist/types/types/query/reference.d.ts
+++ b/node_modules/contentful/dist/types/types/query/reference.d.ts
@@ -1,6 +1,6 @@
 import { EntryFieldTypes } from '../entry';
 import { ConditionalPick } from 'type-fest';
-type SupportedTypes = EntryFieldTypes.EntryLink<any> | undefined;
+type SupportedTypes = EntryFieldTypes.EntryLink<any> | EntryFieldTypes.Array<EntryFieldTypes.EntryLink<any>> | undefined;
 /**
  * Search on references in provided fields
  * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/search-on-references | Documentation}

This issue body was partially generated by patch-package.

@ghost ghost self-requested a review as a code owner May 9, 2024 01:02
@@ -1,7 +1,7 @@
import { EntryFieldTypes } from '../entry'
import { ConditionalPick } from 'type-fest'

type SupportedTypes = EntryFieldTypes.EntryLink<any> | undefined
type SupportedTypes = EntryFieldTypes.EntryLink<any> | EntryFieldTypes.Array<EntryFieldTypes.EntryLink<any>> | undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type SupportedTypes = EntryFieldTypes.EntryLink<any> | EntryFieldTypes.Array<EntryFieldTypes.EntryLink<any>> | undefined
type SupportedTypes =
| EntryFieldTypes.EntryLink<any>
| EntryFieldTypes.Array<EntryFieldTypes.EntryLink<any>>
| undefined

Copy link
Contributor

@mgoudy91 mgoudy91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I added the recommended lint fixes to get it to pass our CI check

@ghost ghost closed this by deleting the head repository May 14, 2024
This pull request was closed.
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

Successfully merging this pull request may close these issues.

None yet

1 participant