We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api-gen package generates the following type for all customFields:
api-gen
customFields
customFields?: GenericRecord;
where
type GenericRecord = | never | null | string | string[] | number | { [key: string]: GenericRecord; };
This caused issues for us as soon as we enabled typechecking in the project: product.customFields['custom_product_short_description']
product.customFields['custom_product_short_description']
It seems that GenericRecord type is too generic for customFields. customFields will never be a string or number directly.
GenericRecord
string
number
What we plan to use for now as a workaround is the following type:
type GenericRecordValue = | never | null | string | string[] | number | { [key: string]: GenericRecord } type GenericRecord = { [key: string]: GenericRecordValue }
It's far from ideal as we need to edit the auto-generated storeApiTypes.d.ts manually.
storeApiTypes.d.ts
I think the best solution would be to introduce new, more specific type for customFields field.
Introducing new type specifically for customFields will resolve the type errors when trying to access custom field value.
Introduce separate, more specific type for customFields
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
api-gen
package generates the following type for allcustomFields
:where
This caused issues for us as soon as we enabled typechecking in the project:
product.customFields['custom_product_short_description']
It seems that
GenericRecord
type is too generic forcustomFields
.customFields
will never be astring
ornumber
directly.What we plan to use for now as a workaround is the following type:
It's far from ideal as we need to edit the auto-generated
storeApiTypes.d.ts
manually.I think the best solution would be to introduce new, more specific type for
customFields
field.Use Case
Introducing new type specifically for
customFields
will resolve the type errors when trying to access custom field value.Proposed Solution
Introduce separate, more specific type for
customFields
Alternatives Considered
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: