Closed angeloashmore closed 1 year ago
Merging #154 (c328833) into master (1eb04d8) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #154 +/- ##
=======================================
Coverage 91.61% 91.61%
=======================================
Files 18 18
Lines 334 334
Branches 84 84
=======================================
Hits 306 306
Misses 5 5
Partials 23 23
Impacted Files | Coverage Δ | |
---|---|---|
src/SliceZone.tsx | 84.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 1eb04d8...c328833. Read the comment docs.
Path | Size |
---|---|
dist/index.js | 5.63 KB (0%) |
dist/index.cjs | 7.16 KB (0%) |
Types of changes
Description
This PR changes
<SliceZone>
to accept untyped or partially typed Slices. The changes affect both the provided Slices (theslices
prop) and components (thecomponents
prop).It effectively removes any type checking between the
slices
andcomponents
props.It also defaults Slice components'
slice
prop toany
rather thanSliceLike
. This was done to support Prismic's Rest API and GraphQL API with the same set of types.Developers can still provide types to their API responses via
@prismicio/client
's type parameters and Slice components via@prismicio/react
'sSliceComponentProps
. This PR does not include breaking changes.While these changes may seem like a step backwards, it broadens the library's support to include projects with insufficient type data. Today, projects with insufficient types is common. This can happen when Slice components are properly typed, but the API data is not. This is even the case in Prismic-provided integrations like Slice Simulator.
Rather than force developers to hand-type their projects, the library has been updated to gracefully support untyped or partially typed data and components.
For more details on what prompted this change, see https://github.com/prismicio/prismic-types/issues/34.
Component Type Examples
<SliceZone>
will accept any of these typed components.Fully typing a Slice component for Prismic's Rest API:
Fully typing a Slice component for Prismic's GraphQL API using a generated type (e.g. from GraphQL Code Generator):
Partially typing a Slice component (restricted to Prismic's Rest API):
Partially typing a Slice component (restricted to Prismic's GraphQL API):
Partially typing a Slice component (any API):
Checklist:
🦢