fix(record-form): type useRecordForm bind's model as the record (PUI-124) #136

Merged
pienter merged 3 commits from feature/PUI-124-userecordform-bind-fails-the-playground-type-check into main 2026-11-21 22:33:19 +00:00
Owner

Makes the playground type-check pass again: a page that spreads useRecordForm's bind on RecordForm without passing initial no longer fails vue-tsc.

On main, cd examples/vue && bun run type-check fails at SettingsForm.vue:201 (TS2345). bind.modelValue was typed record-or-undefined, but RecordForm requires a record. SettingsForm is the only form without initial, and like every page it renders the form only once model is set.

Review guide

  • packages/ui/composables/useRecordForm.ts: RecordFormBinding<T> types modelValue and baseline as T, and its JSDoc says to spread bind only where model is set. model and baseline themselves stay T | undefined without initial.
  • Docs: docs/cms/forms-and-validation.md (the example now guards on model), README, and the existing Unreleased useRecordForm entry in the CHANGELOG.

Proof

  • With the old useRecordForm.ts, the playground type-check fails with exactly that error; with this change it passes.
  • bun run typecheck, lint and format pass; record-form-composable.test.ts: 19 pass.

Choices made: dropped RecordFormBinding's second type parameter (unreleased, no other users); no type-level test in packages/ui (the playground check is the guard, and PUI-121 adds it to CI).

Closes PUI-124

Makes the playground type-check pass again: a page that spreads `useRecordForm`'s `bind` on RecordForm without passing `initial` no longer fails vue-tsc. On main, `cd examples/vue && bun run type-check` fails at `SettingsForm.vue:201` (TS2345). `bind.modelValue` was typed record-or-undefined, but RecordForm requires a record. SettingsForm is the only form without `initial`, and like every page it renders the form only once `model` is set. **Review guide** - `packages/ui/composables/useRecordForm.ts`: `RecordFormBinding<T>` types `modelValue` and `baseline` as `T`, and its JSDoc says to spread `bind` only where `model` is set. `model` and `baseline` themselves stay `T | undefined` without `initial`. - Docs: `docs/cms/forms-and-validation.md` (the example now guards on `model`), README, and the existing Unreleased `useRecordForm` entry in the CHANGELOG. **Proof** - With the old `useRecordForm.ts`, the playground type-check fails with exactly that error; with this change it passes. - `bun run typecheck`, lint and format pass; `record-form-composable.test.ts`: 19 pass. **Choices made:** dropped `RecordFormBinding`'s second type parameter (unreleased, no other users); no type-level test in packages/ui (the playground check is the guard, and PUI-121 adds it to CI). Closes PUI-124
fix(record-form): type useRecordForm bind's model as the record
All checks were successful
ci / lint (pull_request) Successful in 30s
ci / typecheck (pull_request) Successful in 23s
ci / format (pull_request) Successful in 34s
ci / rust (pull_request) Successful in 6m43s
ci / release (pull_request) Has been skipped
c504573c1a
`bind.modelValue` and `baseline` were typed record-or-undefined, which
RecordForm's required `modelValue` rejects, so a form without `initial`
failed vue-tsc on `v-bind="bind"` (the playground's SettingsForm). They
are now typed as the record; spread `bind` only where `model` is set.

Refs PUI-124
Author
Owner

Ready to merge. CI green (format, lint, typecheck, rust). Base: behind main by #135 (61569a8), merges without conflicts. Proof: the playground type-check fails with the old useRecordForm.ts and passes with this change. Review panel (one combined seat, small diff): nothing material. One nit not acted on: there's no type-level test in packages/ui; the playground check is the guard, and PUI-121 adds it to CI.

Ready to merge. CI green (format, lint, typecheck, rust). Base: behind main by #135 (61569a8), merges without conflicts. Proof: the playground type-check fails with the old `useRecordForm.ts` and passes with this change. Review panel (one combined seat, small diff): nothing material. One nit not acted on: there's no type-level test in packages/ui; the playground check is the guard, and PUI-121 adds it to CI.
docs(record-form): record the bind typing fix under Unreleased
All checks were successful
ci / typecheck (pull_request) Successful in 22s
ci / lint (pull_request) Successful in 26s
ci / format (pull_request) Successful in 28s
ci / rust (pull_request) Successful in 3m26s
ci / release (pull_request) Has been skipped
81af78320d
The 0.44.0 release stamped the useRecordForm entry this fix amended, so
the note moves to its own Unreleased entry and 0.44.0 stays as released.

Refs PUI-124
Author
Owner

Ready to merge. Update: main's 0.44.0 release stamped the useRecordForm entry this PR had amended, so main is merged in (f580076) and the note now has its own ## Unreleased → ### Fixed entry (81af783), leaving 0.44.0 as released. Without that, the release job would have found Unreleased empty after the merge. CI green; base current with main (6802ee5). Merge this before #137 and #138: they touch the same lines in useRecordForm.ts and the docs, and I'll update them if they conflict.

Ready to merge. Update: main's 0.44.0 release stamped the useRecordForm entry this PR had amended, so main is merged in (f580076) and the note now has its own `## Unreleased` → `### Fixed` entry (81af783), leaving 0.44.0 as released. Without that, the release job would have found Unreleased empty after the merge. CI green; base current with main (6802ee5). Merge this before #137 and #138: they touch the same lines in useRecordForm.ts and the docs, and I'll update them if they conflict.
pienter deleted branch feature/PUI-124-userecordform-bind-fails-the-playground-type-check 2026-11-21 22:33:19 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pienter/ui!136
No description provided.