Open BraunreutherA opened 2 years ago
Hi there,
it seems the https://github.com/contentful/field-editors/blob/master/packages/_shared/src/utils/entityHelpers.ts getFieldValue return the wrong type string | undefined. When the Field is not a string field it would return another type.
getFieldValue
string | undefined
As we would like to use the method in our App, would it be possible to
unknown | undefined
or
use a generic type like
export function getFieldValue<T = string>({ /** * Expects an entity fetched with a flag Skip-Transformation: true */ entity, fieldId, localeCode, defaultLocaleCode, }: { entity: { fields: { [key: string]: { [valueKey: string]: string | undefined } }; }; fieldId: string; localeCode: string; defaultLocaleCode: string; }): T | undefined { const values = get(entity, ['fields', fieldId]); if (!isObject(values)) { return; } const firstLocaleCode = Object.keys(values)[0]; return values[localeCode] || values[defaultLocaleCode] || values[firstLocaleCode]; }
Thanks
Alex
Marking issue as stale since there was no acitivty for 30 days
Hi there,
it seems the https://github.com/contentful/field-editors/blob/master/packages/_shared/src/utils/entityHelpers.ts
getFieldValue
return the wrong typestring | undefined
. When the Field is not a string field it would return another type.As we would like to use the method in our App, would it be possible to
unknown | undefined
or
use a generic type like
Thanks
Alex