types(dia): infer view type from the model in view lookups - #3473
Open
kumilingus wants to merge 2 commits into
Open
kumilingus wants to merge 2 commits into
kumilingus wants to merge 2 commits into
Conversation
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
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
marked this pull request as ready for review
September 21, 2026 22:33
This branch has not been deployed
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.
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:ElementreturnsElementView,LinkreturnsLinkView.Cell.findView()keeps returningCellView.paper.getCellView()- per-model overloads (Element→ElementView | null,Link→LinkView | null,Cell/id →CellView | null); the caller-asserted generic signature remains as a@deprecatedtail so existinggetCellView<ElementView>(…)call sites keep compiling. It was already| null, so no new nullability.paper.findViewByModel()- untouched. Its return type staysT(non-nullable); adding| undefinedwould 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-errordeleted becauselink.findView()now types asLinkView, whererequestConnectionUpdateexists.Changeset:
@joint/corepatch.🤖 Generated with Claude Code