Skip to content

types(dia): infer view type from the model in view lookups - #3473

Draft
kumilingus wants to merge 1 commit into
clientIO:masterfrom
kumilingus:typings-view-lookups
Draft

types(dia): infer view type from the model in view lookups#3473
kumilingus wants to merge 1 commit into
clientIO:masterfrom
kumilingus:typings-view-lookups

Conversation

@kumilingus

Copy link
Copy Markdown
Contributor

Typings-only change to the three model-based view lookups (runtime untouched):

  • cell.findView(paper) - covariant overrides: Element returns ElementView | undefined, Link returns LinkView | undefined.
  • paper.findViewByModel() / paper.getCellView() - per-model overloads (ElementElementView, LinkLinkView, Cell/id → CellView); the caller-asserted generic signatures remain as @deprecated tails so existing findViewByModel<ElementView>(…) call sites keep compiling.
  • Return types now admit the absent-view case: | undefined for findView/findViewByModel (matching the runtime), getCellView keeps its genuine | null.

@joint/react call sites adjusted (guards at three sites; one @ts-expect-error deleted because link.findView() now types as LinkView, where requestConnectionUpdate exists).

paper.findView($el) (DOM-node lookup) intentionally untouched - different use case, nothing to infer from.

Changeset: @joint/core patch.

🤖 Generated with Claude Code

cell.findView() is covariantly overridden on Element/Link, and
paper.findViewByModel()/getCellView() gain per-model overloads - the
caller-asserted generics remain as deprecated tails for compatibility.
Return types now admit the absent-view case (undefined for findView/
findViewByModel, matching the runtime; getCellView already returned
null). Adjust @joint/react call sites accordingly - one @ts-expect-error
became unnecessary since link.findView() now types as LinkView.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kumilingus
kumilingus marked this pull request as draft August 21, 2026 09:42
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.

1 participant