prismic-richtext icon indicating copy to clipboard operation
prismic-richtext copied to clipboard

feat: define a serializer child type different from its return type

Open angeloashmore opened this issue 2 years ago • 2 comments

Note: This is a WIP! There is a type error in src/serialize.ts.

Types of changes

  • [ ] 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 allows a map or function Rich Text serializer to define its child type differently from its return type.

Using different child and return types is necessary when the serialization logic (i.e. serialize() or a custom implemenation using asTree()) cannot pass its children value using the return type. This happens in Svelte.

Checklist:

  • [ ] My change requires an update to the official documentation.
  • [x] All TSDoc comments are up-to-date and new ones have been added where necessary.
  • [x] All new and existing tests are passing.

🐱

angeloashmore avatar Mar 22 '23 07:03 angeloashmore

size-limit report 📦

Path Size
dist/index.js 959 B (0%)
dist/index.cjs 1.88 KB (0%)

github-actions[bot] avatar Mar 22 '23 07:03 github-actions[bot]

Codecov Report

Merging #61 (3acbadd) into master (d1020ba) will not change coverage. The diff coverage is 100.00%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##            master       #61   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          528       605   +77     
  Branches        46        46           
=========================================
+ Hits           528       605   +77     
Impacted Files Coverage Δ
src/composeSerializers.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)
src/serialize.ts 100.00% <100.00%> (ø)
src/types.ts 100.00% <100.00%> (ø)
src/wrapMapSerializer.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Mar 22 '23 07:03 codecov-commenter