Skip to content

feat(joint-react): InferElement/InferLink, LinkModel generics + React Compiler test harness#3352

Merged
kumilingus merged 6 commits into
clientIO:devfrom
samuelgja:chore/joint-react-better-typing
Jun 11, 2026
Merged

feat(joint-react): InferElement/InferLink, LinkModel generics + React Compiler test harness#3352
kumilingus merged 6 commits into
clientIO:devfrom
samuelgja:chore/joint-react-better-typing

Conversation

@samuelgja

@samuelgja samuelgja commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • InferElement / InferLink type utilities (src/utils/create.ts, exported from src/index.ts): extract the element/link record from a cells array (typeof cells) by its type discriminant. Index ['data'] for the render-data type; compose with Computed for reading hooks.
  • LinkModel adopts the JointJS generic form (src/mvc/link-model.ts): extends dia.Link<Attributes> instead of dia.Link<dia.Link.Attributes & Attributes>, so LinkModel<LinkRecord<Data>> keeps data typed instead of widening it to any. React-side only — no @joint/core change.
  • React Compiler verification harness (jest.config.js, package.json): jest split into default (@swc/jest) and react-compiler (babel-plugin-react-compiler, target: '19'). *.compiler.test.tsx runs only under the compiler project and asserts auto-memoization is active and @joint/react behaviour is unchanged when compiled.
  • Tests: create.test.ts (InferElement/InferLink), element-model.test.ts (generic usage + custom-attribute round-trip), use-cells-reactivity.test.tsx (11 tests — id / single-id / collection membership reactivity), paper-interactive.test.tsx (interactive enables linkMove).
  • Docs (paper.types.ts): renderElement JSDoc clarified — the callback receives the element's data slice, typed via InferElement<typeof cells>['data'].

Motivation and Context

  • Gives JS/TS users a typed way to derive element/link data shapes from a cells array (InferElement/InferLink).
  • LinkModel<LinkRecord<Data>> previously lost its data typing; the JointJS generic surface fixes it without touching core.
  • Guards that React Compiler doesn't change @joint/react behaviour, plus regression coverage for useCells reactivity and Paper interactivity.

Screenshots (if appropriate):

…tils

- Introduced tests for the React compiler to verify auto-memoization behavior.
- Added tests for the `useCells` hook to ensure reactivity with graph membership.
- Created tests for the `Paper` component to validate interactive features.
- Implemented type-level tests for `ElementModel` and `LinkModel` generics.
- Added tests for `element` and `link` utility functions to ensure correct behavior and type inference.
@samuelgja samuelgja marked this pull request as draft June 11, 2026 08:03
@samuelgja samuelgja marked this pull request as ready for review June 11, 2026 08:59
@samuelgja samuelgja changed the title feat(joint-react): cell factories, JointJS model generics + React Compiler tests feat(joint-react): InferElement/InferLink, LinkModel generics + React Compiler test harness Jun 11, 2026
@kumilingus kumilingus merged commit 5598ad6 into clientIO:dev Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants