Repository navigation
fix(puck): typecheck the binding and fix the defects it hid - #1461
Merged
Merged
Conversation
packages/puck never typechecked: under tsrx-tsc every extensionless import of a `.tsrx` module failed to resolve, so each name re-exported through one was missing and the probe fixtures' render props fell back to implicit any. It was also a recorded private exception in scripts/typecheck-coverage.json and absent from the root `typecheck` script, so CI never saw any of it. A working check would have reported at once the `export * from './server'` that a formatter bug had deleted from SlotRender (restored in #1452). Make the lane real: - tsconfig uses the octane volar compiler (`"tsrx": { "compiler": "octane/compiler/volar" }`) and allowImportingTsExtensions. - Imports of `.tsrx` modules spell out the `.tsrx` path. The port script now does this after porting (scripts/tsrx-specifiers.mjs), so a re-port keeps it. - `tsrx-tsc --noEmit -p packages/puck/tsconfig.json` joins the root `typecheck` script, and puck moves from `privateExceptions` to `requiredProjects` in the coverage manifest. - @types/flat, @types/object-hash and @types/uuid are dependencies, since the package ships source. The errors were real runtime defects, fixed at the source: - The AutoField fields barrel, which was empty, re-exports upstream's six field modules. Every built-in field type threw "Field type for … did not exist." SlotRender's restored re-export (#1452) names `./server.tsrx`. - The react-shim `forwardRef` returned `render` itself, so Octane called it with props alone and every forwarded ref (DropZone, SlotRender) was lost. It now passes `props.ref` as the second argument. - react-shim did not export `useTransition` or `isValidElement`, which DraggableComponent and ExternalInput import. It re-exports `JSX` and `Octane` from octane/jsx-runtime instead of declaring a conflicting namespace. - The editor preview used `<autoFrameContext.Consumer>`, which Octane contexts do not have. It reads the frame document with `useContext`. - @dnd-kit 0.5 migrations: sensor activation constraints are constraint instances (the old `{ delay, distance }` object made every pointerdown throw "object is not iterable"), `DragDropEvents` is `DragDropEventHandlers`, and clone feedback is configured through the Feedback plugin. - `useRef(null)` sites, native event targets, missing `FC`/`ComponentType` type imports, and the jest-only `reducer/actions/__helpers__` test helper (now skipped by the port script) are adapted. The editor could not render stored content at all: `"hookSlots": { "manual": ["src"] }` told the compiler that puck hand-forwards hook slots, which it does not, and its plain `.ts` hooks import Octane's hooks through react-shim rather than `octane`, so the compiler never slotted them. Every hook in one custom hook shared a single cell, and `useContentIdsWithPreview` read the preview state as its id list. Drop the manual declaration, and give `.ts` modules that call hooks the `/** @jsxImportSource octane */` ownership pragma (the port script adds it). tests/conformance/adaptation.test.ts covers DropZone refs under Render and in the editor, the editor rendering stored content and its iframe preview, pointer interactions on editor components and sortable array items, the select/radio fields' native change, and an external field listing fetched rows. Each test fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 30, 2026 12:05
Puck no longer declares `hookSlots.manual`: its plain .ts hooks carry the @jsxImportSource pragma and are auto-slotted, so the registry of hand-slot-forwarding packages no longer lists it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 5 tasks
trueadm
added a commit
that referenced
this pull request
Sep 30, 2026
Resolve the parity manifests hunk by hunk, keeping main's other pins, and regenerate their lockfile hashes. Take main's puck sources from #1461 and format them with @tsrx/prettier-plugin 0.5; each compiles to the same output. Keep main's deletion of puck's reducer __helpers__ module. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/pucknow typechecks undertsrx-tscand runs in the roottypechecklane. The errors that lane reported were real runtime defects in the binding, so this PR fixes them at the source. It also fixes the hook-slot setup that stopped the editor from rendering stored content, so the fixes can be tested end to end.The typecheck lane
packages/puck/tsconfig.jsonuses the Octane volar compiler ("tsrx": { "compiler": "octane/compiler/volar" }, as jotai does) andallowImportingTsExtensions..tsrxfor an extensionless specifier. So everyimport … from './Config'(reallyConfig.tsrx) failed, and every name re-exported through one (Config,Render, …) was reported as missing. That in turn left the probe fixtures'render(props)as implicitany. The imports now spell out the.tsrxpath, as the rest of the repo does.scripts/port-upstream.mjsapplies the same rewrite after porting (scripts/tsrx-specifiers.mjs), so a re-port keeps it. I ran the updated script against upstreamv0.20.2and it produces the same specifiers and pragmas.tsrx-tsc --noEmit -p packages/puck/tsconfig.jsonis added to the roottypecheckscript.scripts/typecheck-coverage.jsonmoves puck fromprivateExceptionstorequiredProjects.Config<{ HeadingBlock: Props }>. For example,props.titelreportsProperty 'titel' does not exist on type 'WithId<WithPuckProps<{ title: string }>>'. No annotations oranywere added.@types/flat,@types/object-hashand@types/uuidare added todependencies, because the package ships source (as visx and markdown do).Runtime defects the lane exposed
export * from './server', which a formatter bug had deleted; this PR spells it./server.tsrxso the lane resolves it.AutoField/fields/index.tsrxwas empty since the port landed; it now re-exports upstream's six field modules. Before this, every built-in field type (text, number, select, …) threwField type for … did not exist.forwardRefshim. It returnedrenderitself, so Octane called it with props alone and the secondrefargument was alwaysundefined. Refs passed toDropZoneor to a slot never reached the element. The shim now callsrender(props, props.ref ?? null), the same approach as aria's compat shim.react-shimdid not exportuseTransition(imported by DraggableComponent, so the editor crashed on any stored component) orisValidElement(imported by ExternalInput). It now re-exportsJSX/Octanefromoctane/jsx-runtimeinstead of declaring a namespace that conflicted with the import.Context.Consumer. The editor preview used<autoFrameContext.Consumer>, which Octane contexts do not have. It now reads the frame document withuseContext.PointerActivationConstraintsinstances. The old{ delay, distance }object made every pointerdown throwobject is not iterable.DragDropEventsis nowDragDropEventHandlers.Feedback.configure.useRef<X | null>(null)sites, native event targets (e.currentTargetfor select/radiochange), and missingFC/ComponentTypetype imports.src. Upstream's jest-onlyreducer/actions/__helpers__was shipped insrc. It is removed, and the port script skips it.Editor hook slots
"hookSlots": { "manual": ["src"] }told the compiler that puck hand-forwards hook slots, which it does not. On top of that, puck's plain.tshooks import Octane's hooks throughreact-shimrather thanoctane, so the.tsslotting pass never claimed them. Every hook inside one custom hook therefore shared a single cell. For example,useContentIdsWithPreviewread its preview state as the id list and crashed withcontentIdsWithPreview.map is not a function, and the run logged dozens of "dependency array must keep the same length" warnings. This was the README's "full<Puck>editor mount" known difference. The fix has two parts, and both are required:.tsmodules that call hooks get the/** @jsxImportSource octane */ownership pragma, the same convention as base-ui's 129 such modules. The port script adds it.Validation
pnpm format:checkpnpm typecheckpnpm test: not run repo-wide locally; CI runs itpnpm vitest run --project puck --project puck-differential(13 passed, including fix(prettier): keep labeled statements and empty bodies when formatting .tsrx #1452's slot-field Render test).pnpm typecheck:files packages/puck(175 files, src and tests) passes, andpnpm typecheck:coveragepasses.tests/conformance/adaptation.test.tscovers the contracts above. Each test fails with its fix reverted:forwardRefshim fixuseTransitionexport; hook-slot fixuseContextin place ofConsumer; hook-slot fixobject is not iterable)changeisValidElementexportjsdom never loads an iframe's
srcdoc. The iframe test therefore fills the frame document from thesrcdocattribute, as a browser would, and everything past that point runs the real AutoFrame path.Risk / follow-ups
manualmeans the compiler now slots puck's.tsmodules. Only modules that call hooks carry the pragma.Feedback.configure({ feedback: 'clone' })) is type-checked, but no jsdom test drives an actual drag.asoperand in.tsrx('name' in (e.target as Element)becomes'name' in e.target as Element). AutoField'sonBluris written with a localtargetso it is not affected; the formatter fix is tracked separately.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes hook slotting, ref forwarding, and drag-and-drop in the Puck editor path; medium scope but covered by targeted conformance tests.
Overview
Puck is wired into the root
typechecklane and the defects that check surfaced are fixed so the full editor can run on Octane.The port pipeline now rewrites extensionless imports to
.tsrx, adds@jsxImportSource octaneon plain.tsmodules that call hooks (replacing the incorrecthookSlots.manualentry), and updatesreact-shim(forwardRefforwarding refs,useTransition,isValidElement, context types). Source fixes include the missing AutoField fields barrel, @dnd-kit 0.5 API migrations, and nativechangehandlers usinge.currentTarget.React-parity audit files and the user-apps-v1 eval manifest refresh
lockfileSha256/overlayLockfileHashafter the lockfile move. The Octane manual hook-slot registry test drops puck and documents pragma-based auto-slotting.Reviewed by Cursor Bugbot for commit b5091c5. Bugbot is set up for automated code reviews on this repo. Configure here.