[ ] Chore (a non-breaking change which is related to package maintenance)
[ ] Bug fix (a non-breaking change which fixes an issue)
[x] New feature (a non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
This PR adds the ability to type Embed fields with custom provider-specific types.
For example, if you expect YouTube links to be provided via an Embed field, and you know the oEmbed data that will be provided, you can configure the output to include your custom type.
Custom types can be provided to generateTypes()'s fieldConfigs.embed.providerTypes option:
Types of changes
Description
This PR adds the ability to type Embed fields with custom provider-specific types.
For example, if you expect YouTube links to be provided via an Embed field, and you know the oEmbed data that will be provided, you can configure the output to include your custom type.
Custom types can be provided to
generateTypes()
'sfieldConfigs.embed.providerTypes
option:This will provide the following output (this is not the full output, only the relevant part):
The Embed field can then be type-narrowed by checking
provider_name
against a string constant.If no provider-specific types are given, the field will be typed as
prismicT.EmbedField
.Checklist:
🐦