Closed angeloashmore closed 2 years ago
This PR adds the ability to type Integration Fields fields with custom catalog-specific types.
For example, if you know the object type returned by a Shopify catalog, you can configure the output to include your custom type.
Custom types can be provided to generateTypes()'s fieldConfigs.integrationFields.catalogTypes option:
generateTypes()
fieldConfigs.integrationFields.catalogTypes
const model = prismicM.model.customType({ seed: t.title, id: "foo", fields: { bar: prismicM.model.integrationFields({ seed: t.title, catalog: "baz" }), }, }); const types = generateTypes({ customTypeModels: [model], fieldConfigs: { integrationFields: { catalogTypes: { baz: "BazType", }, }, }, });
This will provide the following output (this is not the full output, only the relevant part):
interface FooDocumentData { bar: prismicT.IntegrationFields<BazType>; }
If no provider-specific types are given, the field will be typed as prismicT.IntegrationFields.
prismicT.IntegrationFields
🐤
Types of changes
Description
This PR adds the ability to type Integration Fields fields with custom catalog-specific types.
For example, if you know the object type returned by a Shopify catalog, you can configure the output to include your custom type.
Custom types can be provided to
generateTypes()
'sfieldConfigs.integrationFields.catalogTypes
option:This will provide the following output (this is not the full output, only the relevant part):
If no provider-specific types are given, the field will be typed as
prismicT.IntegrationFields
.Checklist:
🐤