Skip to content

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

Open
kumilingus wants to merge 2 commits into
clientIO:masterfrom
kumilingus:typings-view-lookups
Open

kumilingus wants to merge 2 commits into
clientIO:masterfrom
kumilingus:typings-view-lookups

Conversation

@kumilingus

@kumilingus kumilingus commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Typings-only change to the model-based view lookups (runtime untouched), strictly additive - no existing call site changes meaning or stops compiling:

  • cell.findView(paper) - covariant overrides: Element returns ElementView, Link returns LinkView. Cell.findView() keeps returning CellView.
  • paper.getCellView() - per-model overloads (Element → ElementView | null, Link → LinkView | null, Cell/id → CellView | null); the caller-asserted generic signature remains as a @deprecated tail so existing getCellView<ElementView>(…) call sites keep compiling. It was already | null, so no new nullability.
  • paper.findViewByModel() - untouched. Its return type stays T (non-nullable); adding | undefined would break every strict TypeScript application that chains a call on the result.
  • paper.findView($el) (DOM-node lookup) untouched - different use case, nothing to infer from.

@joint/react: one @ts-expect-error deleted because link.findView() now types as LinkView, where requestConnectionUpdate exists.

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
…llable

Adding `| undefined` to `findViewByModel()` and `findView()` would break
every strict TypeScript application that chains a call on the result.
The lookups keep their original return types; only the additive parts
stay: covariant `findView()` on `Element`/`Link` and the `getCellView()`
overloads (already nullable).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kumilingus
kumilingus marked this pull request as ready for review September 21, 2026 22:33

This branch has not been deployed

No deployments
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