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
so field values can't be extracted from "ContentList" field types using the getFieldValue<T> method without casting.
getFieldValue<T> expects type ComponentRendering or { [name: string]: Field | Item[] }, but Item.fields is of type { [name: string]: Field | Item | Item[] | undefined; }, so Item.fields cannot be passed to getFieldValue.
Description
The
getFieldValue<T>
helper methodjss/packages/sitecore-jss/src/layout/utils.ts
Line 25 in 5a75ff9
Item.fields
propertyjss/packages/sitecore-jss/src/layout/models.ts
Line 127 in 5a75ff9
getFieldValue<T>
method without casting.getFieldValue<T>
expects typeComponentRendering
or{ [name: string]: Field | Item[] }
, butItem.fields
is of type{ [name: string]: Field | Item | Item[] | undefined; }
, soItem.fields
cannot be passed togetFieldValue
.Expected behavior
In the
Styleguide-FieldUsage-ContentList
component (https://github.com/Sitecore/jss/blob/dev/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-ContentList.tsx), I should be able to usegetFieldValue
on lines37
or48
as follows, without casting:Steps To Reproduce
Try to pass the
fields
of an item in a multilist or treelist field to thegetFieldValue<T>
helper method as described above.Possible Fix
Change the
Fields
type injss/utils.ts
jss/packages/sitecore-jss/src/layout/utils.ts
Line 3 in 5a75ff9
Your Environment
Screenshots
No screenshots necessary.
The text was updated successfully, but these errors were encountered: