You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the new V10 Types, the following type definition is generated for a linked field that allows multiple entries, and has WITHOUT_UNRESOLVABLE_LINKS as a chain modifier:
I understand that with the withoutUnresolvableLinks option passed to the client, that a single linked entry field could possibly be undefined, for example if the content delivery API is used and a piece of linked content is unpublished.
It doesn't make sense to me however, that there could be undefined values within the array of entries. Wouldn't the API response remove any unresolvable links, making it so that the array could be either empty or containing entries, but not containing undefined?
This would suggest to me that the type should actually be: (Entry<ContentTypeSkeleton, "WITHOUT_UNRESOLVABLE_LINKS", string>)[] | undefined
Actual Behavior
In the type for a field with a chain modifier of WITHOUT_UNRESOLVABLE_LINKS, the returned type is an array of entries and undefined values
Possible Solution
Remove undefined from the array type resulting from a field with multiple linked entries and with WITHOUT_UNRESOLVABLE_LINKS
Steps to Reproduce
Create a field type that is an array of linked entries using the V10 types:
Wouldn't the API response remove any unresolvable links, making it so that the array could be either empty or containing entries, but not containing undefined?
The API returns the resolved entries separately and the library adds them in the right places in your entries. When doing so in lists we could remove the links that could not be resolved but then you’ll get a shorter list and couldn’t tell which of the entries could not be resolved. In some use cases the position of list items matter so we need to keep each item in the list.
You can always use Array.filter to get a list with the undefined items removed.
Expected Behavior
Using the new V10 Types, the following type definition is generated for a linked field that allows multiple entries, and has
WITHOUT_UNRESOLVABLE_LINKS
as a chain modifier:(Entry<ContentTypeSkeleton, "WITHOUT_UNRESOLVABLE_LINKS", string> | undefined)[] | undefined
I understand that with the
withoutUnresolvableLinks
option passed to the client, that a single linked entry field could possibly be undefined, for example if the content delivery API is used and a piece of linked content is unpublished.It doesn't make sense to me however, that there could be undefined values within the array of entries. Wouldn't the API response remove any unresolvable links, making it so that the array could be either empty or containing entries, but not containing
undefined
?This would suggest to me that the type should actually be:
(Entry<ContentTypeSkeleton, "WITHOUT_UNRESOLVABLE_LINKS", string>)[] | undefined
Actual Behavior
In the type for a field with a chain modifier of
WITHOUT_UNRESOLVABLE_LINKS
, the returned type is an array of entries and undefined valuesPossible Solution
Remove
undefined
from the array type resulting from a field with multiple linked entries and withWITHOUT_UNRESOLVABLE_LINKS
Steps to Reproduce
EntryFieldTypes.Array<EntryFieldTypes.EntryLink<OtherContentTypeSkeleton>>
Context
This leads to null checks within arrays of linked entries that appear unnecessary
Environment
The text was updated successfully, but these errors were encountered: