fix: preserve PreviewGroup imageRender contract - #529
Conversation
|
@Cherry7593 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nrps9909
left a comment
There was a problem hiding this comment.
Verified exact head 0621d2d5a87b7eeb9075d0f2495d16c4e9d1ff72 independently. The Omit<InternalPreviewConfig, 'imageRender'> boundary is the right way to keep the group-only callback contract (current required) separate from the single-image/internal contract (current optional), without changing the runtime forwarding path. I ran npm test -- tests/previewGroup.test.tsx --runInBand (17/17 passing, including the new 0→1 index assertion) and npm run tsc successfully. No blocking issues found.
What changed
Make
GroupPreviewConfigomit the baseimageRendermember before redeclaring the grouped callback, and add a runtime regression test for its numericcurrentvalue.Root cause
GroupPreviewConfigextendsInternalPreviewConfig, but narrowsimageRenderfrom an optionalinfo.currentto a required one. Strict TypeScript consumers therefore report TS2430 for the published declaration.The runtime contracts are genuinely different: single-image rendering may omit
current, while PreviewGroup always supplies its active numeric index.Why this shape
Omit<InternalPreviewConfig, 'imageRender'>preserves all other base members and allows the grouped callback to retain its stronger contract without invalid interface inheritance. Runtime JavaScript is unchanged.Validation
skipLibCheck: falsepassedThe added test verifies
imageRenderreceivescurrent0 initially and 1 after navigation.