Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Sep 23, 2025

Easily detect when super methods are removed in the "core" package.
Already in place in other packages.

Summary by CodeRabbit

  • Refactor
    • Marked many internal methods and properties as explicit overrides to improve type safety and inheritance correctness; no user-facing behavior changes.
  • Chores
    • Removed a redundant compiler option and an unnecessary test import to tidy build/typing configuration.

Easily detect when super methods are removed in the "core" package.
Already in place in other packages.
@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Sep 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Adds explicit TypeScript override modifiers across many classes (codecs, canvas, handlers, layouts, shapes, plugins, etc.) and removes noImplicitOverride from packages/core/tsconfig.json. Changes are declarative (method/property signatures and minor formatting); runtime logic and control flow remain unchanged.

Changes

Cohort / File(s) Summary
Serialization Codecs
packages/core/src/serialization/codecs/CellCodec.ts, packages/core/src/serialization/codecs/ChildChangeCodec.ts, packages/core/src/serialization/codecs/GenericChangeCodec.ts, packages/core/src/serialization/codecs/ModelCodec.ts, packages/core/src/serialization/codecs/RootChangeCodec.ts, packages/core/src/serialization/codecs/TerminalChangeCodec.ts
Add override to codec methods (e.g., isNumericAttribute, isExcluded, afterEncode, beforeDecode, afterDecode); signatures annotated as overrides; logic unchanged.
Editor Codecs
packages/core/src/serialization/codecs/editor/EditorCodec.ts, .../EditorKeyHandlerCodec.ts, .../EditorPopupMenuCodec.ts, .../EditorToolbarCodec.ts
Mark encode/decode/afterDecode/decodeChild as override; minor formatting adjustments; behavior unchanged.
mxGraph Codecs
packages/core/src/serialization/codecs/mxGraph/mxCellCodec.ts, packages/core/src/serialization/codecs/mxGraph/mxGeometryCodec.ts
Add override to getName, decodeAttribute, afterDecode; no logic changes.
Canvas
packages/core/src/view/canvas/SvgCanvas2D.ts, packages/core/src/view/canvas/XmlCanvas2D.ts
Mark many drawing API methods/properties as override; minor comment/formatting tweaks; one small normalization removal for shadow color in XmlCanvas2D; otherwise behavior unchanged.
Cell & Geometry
packages/core/src/view/cell/CellOverlay.ts, .../CellState.ts, .../CellTracker.ts, packages/core/src/view/geometry/Geometry.ts, packages/core/src/view/geometry/Rectangle.ts
Add override to toString/clone/destroy/equals and similar methods; implementations unchanged.
Handlers
packages/core/src/view/handler/EdgeHandler.ts, .../EdgeSegmentHandler.ts, .../ElbowEdgeHandler.ts
Add override to marker properties and handler methods/properties; no functional changes.
Layouts
packages/core/src/view/layout/* (CircleLayout, CompactTreeLayout, CompositeLayout, EdgeLabelLayout, FastOrganicLayout, HierarchicalLayout, ParallelEdgeLayout, PartitionLayout, RadialTreeLayout, StackLayout, SwimlaneLayout)
Mark execute, traverse, moveCell and related layout APIs and some properties as override; behavior unchanged.
Layout Datatypes
packages/core/src/view/layout/datatypes/GraphAbstractHierarchyCell.ts, .../GraphHierarchyEdge.ts, .../GraphHierarchyNode.ts
Mark properties and predicates (isEdge/isVertex/isAncestor) as override; logic preserved.
Plugins
packages/core/src/view/plugins/ConnectionHandler.ts
Add override to ConnectionHandlerCellMarker property/methods (hotspotEnabled, getCell, isValidState, getMarkerColor, intersects); behavior unchanged.
Shapes — Edge
packages/core/src/view/shape/edge/* (ArrowConnectorShape, ArrowShape, ConnectorShape, LineShape, PolylineShape)
Add override to rendering, bounds and style methods; minor parameter formatting; behavior unchanged.
Shapes — Node
packages/core/src/view/shape/node/* (ActorShape, CloudShape, CylinderShape, DoubleEllipseShape, EllipseShape, HexagonShape, ImageShape, LabelShape, RectangleShape, RhombusShape, SwimlaneShape, TextShape, TriangleShape)
Add override to many drawing, style, measurement methods and properties; several signatures reformatted; behavior unchanged.
Animation
packages/core/src/view/animate/Morphing.ts
Add override to updateAnimation; no logic change.
Style Registry
packages/core/src/view/style/edge/EdgeStyleRegistry.ts
Add override to add and clear methods; behavior unchanged.
Config
packages/core/tsconfig.json
Remove compilerOptions.noImplicitOverride (previously false).
Tests / Utilities
packages/core/__tests__/utils.ts, packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts
Remove Jest globals import from utils; add override to two test subclass methods (parseDescription, parseConstraints); no runtime change.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The provided description is too brief and does not follow the repository PR template: it states the high-level intent but omits the checklist, a detailed Overview of what changed (notably the added override annotations across many files and the removal of noImplicitOverride in packages/core/tsconfig.json), testing instructions, and links to any related issue, so reviewers lack necessary context to assess scope and impact. Please complete the repo PR template: fill or explain the PR checklist, expand the Overview with concrete details (e.g., summary of files/classes changed and that packages/core/tsconfig.json noImplicitOverride was removed), indicate testing/validation steps and whether this is a breaking change, and link any related issue or discussion so reviewers can validate scope and risk.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "chore(typescript): always use explicit override" is concise, follows Conventional Commits style, and accurately summarizes the primary change (enforcing explicit override usage across the core package to detect removed super methods).
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/TS_core_no_implicit_override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
packages/core/src/view/canvas/XmlCanvas2D.ts (2)

357-373: setDashed ignores fixDash changes when compressed=true.

When dashed stays the same but fixDash changes, early return prevents updating state/XML. Include fixDash in the equality check.

Apply:

   override setDashed(value: boolean, fixDash: boolean): void {
     if (this.compressed) {
-      if (this.state.dashed === value) {
+      if (this.state.dashed === value && this.state.fixDash === fixDash) {
         return;
       }
       super.setDashed(value, fixDash);
     }

349-356: Fix JSDoc param name for setDashed.

Second @param should be fixDash, not value.

  /**
   * Enables or disables dashed lines.
   *
   * @param value Boolean that specifies if dashed lines should be enabled.
-  * @param value Boolean that specifies if the stroke width should be ignored
+  * @param fixDash Boolean that specifies if the stroke width should be ignored
   * for the dash pattern.
   * @default false
   */
packages/core/src/serialization/codecs/StylesheetCodec.ts (2)

145-147: Bug: Map accessed with bracket notation; use get()

styles is a Map, so obj.styles[extend] is always undefined. This breaks style inheritance in decode.

Fix:

-          let style = extend ? clone(obj.styles[extend]) : null;
+          let style = extend ? clone(obj.styles.get(extend)) : null;

177-179: Don’t drop falsy values (e.g., 0) when decoding

if (value) skips valid values like 0. Use a null/undefined check instead.

Fix:

-                if (value) {
+                if (value != null) {
                   style[key] = value;
                 }
packages/core/src/serialization/codecs/editor/EditorToolbarCodec.ts (1)

233-243: Fix incorrect callback reference in selectMode handler (TypeError at runtime)

The change handler calls funct(), which is undefined here. It should call create().

Apply this diff:

-                      into.toolbar!.selectMode(img, (evt: MouseEvent) => {
+                      into.toolbar!.selectMode(img, (evt: MouseEvent) => {
                         const pt = convertPoint(
                           editor.graph.container,
                           getClientX(evt),
                           getClientY(evt)
                         );
-
-                        return editor.addVertex(null, funct(), pt.x, pt.y);
+                        return editor.addVertex(null, create(), pt.x, pt.y);
                       });
🧹 Nitpick comments (55)
packages/core/src/view/shape/node/RhombusShape.ts (1)

49-55: Optional: align JSDoc with actual types

JSDoc still references mxAbstractCanvas2D while the TS type is AbstractCanvas2D. Consider updating or dropping the JSDoc type (TS already provides types).

Apply this minimal doc tweak:

-   * @param {mxAbstractCanvas2D} c
+   * @param {AbstractCanvas2D} c
packages/core/src/view/shape/node/RectangleShape.ts (4)

44-57: Good use of explicit override; add an explicit return type for clarity

Consider annotating the return type to make the API surface clearer and consistent with other methods.

Apply:

-  override isHtmlAllowed() {
+  override isHtmlAllowed(): boolean {

62-68: Add an explicit ': void' return type to paintBackground

Keeps signatures explicit and consistent with paintForeground.

Apply:

-  override paintBackground(
+  override paintBackground(
     c: AbstractCanvas2D,
     x: number,
     y: number,
     w: number,
     h: number
-  ) {
+  ): void {

94-96: Add an explicit ': boolean' return type to isRoundable

Aligns with explicit typing elsewhere.

Apply:

-  override isRoundable(c: AbstractCanvas2D, x: number, y: number, w: number, h: number) {
+  override isRoundable(
+    c: AbstractCanvas2D,
+    x: number,
+    y: number,
+    w: number,
+    h: number
+  ): boolean {

101-107: Doc nit: comment says “background” for paintForeground

The JSDoc above this method refers to “background” while this is the foreground pass. Suggest updating the comment for accuracy.

Update the nearby JSDoc to:

/**
 * Generic foreground painting implementation.
 */
packages/core/src/view/shape/edge/LineShape.ts (1)

55-61: Optional: add explicit return type for clarity

Adding an explicit void return type can improve readability and consistency.

Apply this diff:

-  ) {
+  ): void {
packages/core/src/view/shape/node/HexagonShape.ts (1)

38-38: Optional: add an explicit return type.

Add : void for clarity and to guard against inference drift.

Apply this diff:

-  override redrawPath(c: AbstractCanvas2D, x: number, y: number, w: number, h: number) {
+  override redrawPath(c: AbstractCanvas2D, x: number, y: number, w: number, h: number): void {
packages/core/src/view/shape/edge/PolylineShape.ts (4)

51-53: Add explicit return type for clarity (number).

Keeps signature explicit and aligned with the base type.

Apply this diff:

-  override getRotation() {
+  override getRotation(): number {

58-60: Add explicit return type for clarity (number).

Keeps signature explicit and aligned with the base type.

Apply this diff:

-  override getShapeRotation() {
+  override getShapeRotation(): number {

65-67: Add explicit return type for clarity (boolean).

Keeps signature explicit and aligned with the base type.

Apply this diff:

-  override isPaintBoundsInverted() {
+  override isPaintBoundsInverted(): boolean {

72-82: Guarantee canvas state restoration; use try/finally and add void return type.

Prevents leaving pointerEventsValue in a bad state if painting throws; also makes return type explicit.

Apply this diff:

-  override paintEdgeShape(c: AbstractCanvas2D, pts: Point[]) {
-    const prev = c.pointerEventsValue;
-    c.pointerEventsValue = 'stroke';
-
-    if (!this.style?.curved) {
-      this.paintLine(c, pts, this.isRounded);
-    } else {
-      this.paintCurvedLine(c, pts);
-    }
-    c.pointerEventsValue = prev;
-  }
+  override paintEdgeShape(c: AbstractCanvas2D, pts: Point[]): void {
+    const prev = c.pointerEventsValue;
+    c.pointerEventsValue = 'stroke';
+    try {
+      if (!this.style?.curved) {
+        this.paintLine(c, pts, this.isRounded);
+      } else {
+        this.paintCurvedLine(c, pts);
+      }
+    } finally {
+      c.pointerEventsValue = prev;
+    }
+  }
packages/core/src/view/layout/EdgeLabelLayout.ts (4)

42-44: Unused constructor parameter 'radius'

If not used, prefix to avoid unused warnings without breaking the public API.

Apply this diff:

-  constructor(graph: AbstractGraph, radius: number) {
+  constructor(graph: AbstractGraph, _radius: number) {
     super(graph);
   }

51-51: Remove unused local model in execute

Avoid dead code.

Apply this diff:

-    const model = this.graph.getDataModel();

54-56: Type local arrays to avoid any[]

Improves type safety when passing to placeLabels.

Apply this diff:

-    const edges = [];
-    const vertices = [];
+    const edges: CellState[] = [];
+    const vertices: CellState[] = [];

100-103: Docstring mismatch for avoid

Clarify purpose of the method.

Apply this diff:

-  /**
-   * Places the labels of the given edges.
-   */
+  /**
+   * Adjusts the edge label offset to avoid overlap with the given vertex.
+   */
packages/core/src/view/shape/node/CylinderShape.ts (2)

55-61: Add explicit return type for clarity

Nit: declare the return type to mirror the base signature and prevent accidental returns.

Apply this diff:

-  ) {
+  ): void {

85-92: Add missing override on redrawPath

This likely overrides Shape.redrawPath; add the modifier to benefit from TS checks and align with the PR objective.

Apply this diff:

-  redrawPath(
+  override redrawPath(
packages/core/src/view/shape/node/ImageShape.ts (4)

54-56: Add explicit return type for clarity.

Declare the return type to keep method signatures consistent and ease refactoring.

-  override getSvgScreenOffset() {
+  override getSvgScreenOffset(): number {

68-78: Add explicit return type.

This method returns nothing; make it explicit.

-  override apply(state: CellState) {
+  override apply(state: CellState): void {

91-93: Add explicit return type.

Keep boolean return explicit.

-  override isRoundable(c: AbstractCanvas2D, x: number, y: number, w: number, h: number) {
+  override isRoundable(c: AbstractCanvas2D, x: number, y: number, w: number, h: number): boolean {

98-104: Add explicit return type.

Paint methods are side-effect only; declare void.

-  override paintVertexShape(
+  override paintVertexShape(
     c: AbstractCanvas2D,
     x: number,
     y: number,
     w: number,
-    h: number
-  ) {
+    h: number
+  ): void {
packages/core/src/view/layout/CircleLayout.ts (1)

87-87: Add explicit : void return type for consistency with other execute overrides.

CompactTreeLayout’s execute already uses : void. Aligning improves readability and consistency.

Apply this diff:

-  override execute(parent: Cell) {
+  override execute(parent: Cell): void {
packages/core/src/view/layout/StackLayout.ts (1)

283-291: Nit: add an explicit type for fillValue (clarity, stricter typing).

This keeps types precise in strict setups.

Apply:

-      let fillValue = null;
+      let fillValue: number | null = null;
packages/core/src/view/handler/ElbowEdgeHandler.ts (1)

176-178: Avoid non-null assertion on geometry (optional)

Safer to handle potential null geometry without a non-null assertion.

Apply:

-    } else if (g!.points != null && g!.points.length > 0) {
+    } else if (g?.points != null && g.points.length > 0) {
packages/core/src/view/layout/PartitionLayout.ts (1)

80-112: Explicit override on moveCell: LGTM

Matches GraphLayout contract; no behavior change. Noting the in-method TODO about orientation for a future follow-up.

If useful, I can draft a small PR to handle orientation in the index computation and open a tracking issue.

packages/core/src/view/shape/edge/ArrowShape.ts (2)

60-65: Overrides look correct; consider adding explicit return type

For consistency with other shapes (e.g., ArrowConnectorShape), add an explicit void return type.

-  override augmentBoundingBox(bbox: Rectangle) {
+  override augmentBoundingBox(bbox: Rectangle): void {

70-116: Overrides look correct; add return type and a small guard against degenerate geometry

  • Add explicit void return type.
  • Optional robustness: early-return if pts are degenerate to avoid dividing by zero (ArrowConnectorShape already guards for this case).
-  override paintEdgeShape(c: AbstractCanvas2D, pts: Point[]) {
+  override paintEdgeShape(c: AbstractCanvas2D, pts: Point[]): void {
@@
-    const dx = pe.x - p0.x;
-    const dy = pe.y - p0.y;
-    const dist = Math.sqrt(dx * dx + dy * dy);
+    const dx = pe.x - p0.x;
+    const dy = pe.y - p0.y;
+    const dist = Math.sqrt(dx * dx + dy * dy);
+    if (!Number.isFinite(dist) || dist === 0) {
+      return;
+    }
packages/core/src/view/shape/edge/ArrowConnectorShape.ts (2)

61-66: Property override LGTM; tweak JSDoc to avoid default-value confusion

Base default is false; this shape intentionally overrides to true. Suggest updating the doc to reflect that.

   /**
    * Allows to use the SVG bounding box in SVG.
-   * @defaultValue `false` for performance reasons.
+   * Overrides the base default (`false`) to `true` for this shape.
    */
-  override useSvgBoundingBox = true;
+  override useSvgBoundingBox = true;

70-72: Method override LGTM; add explicit return type for consistency

Add : boolean to match common style across the codebase.

-  override isRoundable() {
+  override isRoundable(): boolean {
packages/core/src/view/shape/node/CloudShape.ts (1)

42-42: Add explicit return type for clarity.

Annotate the method as returning void to match base and improve readability.

Apply this diff:

-  override redrawPath(c: AbstractCanvas2D, x: number, y: number, w: number, h: number) {
+  override redrawPath(c: AbstractCanvas2D, x: number, y: number, w: number, h: number): void {
packages/core/src/view/shape/node/SwimlaneShape.ts (3)

77-116: Prefer strict equality and add explicit return type for clarity.

Use === for boolean comparison and annotate the return type.

Apply:

-  override getLabelBounds(rect: Rectangle) {
+  override getLabelBounds(rect: Rectangle): Rectangle {
@@
-    const realHorizontal = horizontal == !shapeVertical;
+    const realHorizontal = horizontal === !shapeVertical;

121-127: Add explicit return type to getGradientBounds for consistency.

This improves API clarity without changing behavior.

-  override getGradientBounds(
+  override getGradientBounds(
     c: AbstractCanvas2D,
     x: number,
     y: number,
     w: number,
     h: number
-  ) {
+  ): Rectangle {

159-165: Add explicit return type to paintVertexShape.

Minor readability improvement; no behavior change.

-  override paintVertexShape(
+  override paintVertexShape(
     c: AbstractCanvas2D,
     x: number,
     y: number,
     w: number,
     h: number
-  ) {
+  ): void {
packages/core/src/view/shape/node/ActorShape.ts (1)

63-69: Optional: add explicit : void return type to lock the public API.

Prevents accidental return value changes and aligns with stricter API surfaces.

-  ) {
+  ): void {
packages/core/src/view/layout/RadialTreeLayout.ts (2)

126-130: Use vertex.getConnections() here for consistency

Both graph.getConnections(cell, parent?) (ConnectionsMixin) and Cell#getConnections() exist; CompactTreeLayout already uses vertex.getConnections(). Since no parent is passed here, prefer vertex.getConnections().

-    return (
-      super.isVertexIgnored(vertex) || this.graph.getConnections(vertex).length === 0
-    );
+    return (
+      super.isVertexIgnored(vertex) || vertex.getConnections().length === 0
+    );

142-151: Prefer an optional root?: Cell param and pass it through to super

Change the signature to root?: Cell and call super.execute(parent, root) to avoid the nullundefined conversion (matches CompactTreeLayout).

-  override execute(parent: Cell, root: Cell | null = null): void {
+  override execute(parent: Cell, root?: Cell): void {
@@
-    super.execute(parent, root || undefined);
+    super.execute(parent, root);
packages/core/src/view/shape/node/EllipseShape.ts (1)

42-48: Optional: declare the explicit return type.

Improves readability and guards against accidental return changes.

-  override paintVertexShape(
+  override paintVertexShape(
     c: AbstractCanvas2D,
     x: number,
     y: number,
     w: number,
     h: number
-  ) {
+  ): void {
packages/core/src/view/geometry/Geometry.ts (1)

345-361: Prefer not narrowing the parameter type in overrides

equals narrows the parameter to Geometry | null while the base method (in Rectangle) accepts a broader type. To keep LSP and avoid subtle unsoundness at call sites, widen the parameter to Rectangle | null and guard for Geometry.

-  override equals(geom: Geometry | null) {
+  override equals(geom: Rectangle | null) {
+    if (!(geom instanceof Geometry)) return false;
     if (!geom) return false;

     return (
       super.equals(geom) &&
       this.relative === geom.relative &&
       ((this.sourcePoint === null && geom.sourcePoint === null) ||
         !!this.sourcePoint?.equals(geom.sourcePoint)) &&
       ((this.targetPoint === null && geom.targetPoint === null) ||
         !!this.targetPoint?.equals(geom.targetPoint)) &&
       equalPoints(this.points, geom.points) &&
       ((this.alternateBounds === null && geom.alternateBounds === null) ||
         !!this.alternateBounds?.equals(geom.alternateBounds)) &&
       ((this.offset === null && geom.offset === null) ||
         !!this.offset?.equals(geom.offset))
     );
   }
packages/core/src/view/geometry/Rectangle.ts (1)

166-175: Align Rectangle.equals signature with Point.equals and add a runtime guard

Point.equals is declared equals(p: Point | null); change Rectangle.equals to accept Point | null and guard for Rectangle before comparing.

File: packages/core/src/view/geometry/Rectangle.ts

-  override equals(rect: Rectangle | null) {
+  override equals(rect: Point | null) {
+    if (!(rect instanceof Rectangle)) return false;
     if (!rect) return false;

     return (
       rect.x === this.x &&
       rect.y === this.y &&
       rect.width === this.width &&
       rect.height === this.height
     );
   }
packages/core/src/view/layout/ParallelEdgeLayout.ts (1)

111-116: Optional: treat empty cells array distinctly from null

if (cells) treats [] as falsy and falls back to scanning all children. Consider checking nullish explicitly.

Apply:

-    if (cells) {
+    if (cells != null) {
       for (const cell of cells) {
         addCell(cell);
       }
     } else {
packages/core/src/view/handler/EdgeHandler.ts (1)

2323-2340: Explicit override on isValidState: OK. Add explicit boolean return type.

Apply:

-  override isValidState = (state: CellState) => {
+  override isValidState = (state: CellState): boolean => {
packages/core/src/view/shape/node/LabelShape.ts (1)

113-115: Doc/logic mismatch in isHtmlAllowed (likely inverted check for indicator shape)

Comment says “no indicator shape,” but code allows HTML only when an indicator shape exists. Consider flipping the condition. Follow‑up outside this chore PR.

Apply:

-    return super.isHtmlAllowed() && this.indicatorColor === NONE && !!this.indicatorShape;
+    return super.isHtmlAllowed() && this.indicatorColor === NONE && !this.indicatorShape;
packages/core/src/view/canvas/XmlCanvas2D.ts (2)

164-173: Avoid creating unused element.

Only create the element when actually needed.

-    const elem = this.createElement('rotate');
-    if (theta !== 0 || flipH || flipV) {
+    if (theta !== 0 || flipH || flipV) {
+      const elem = this.createElement('rotate');
       elem.setAttribute('theta', String(this.format(theta)));
       elem.setAttribute('flipH', flipH ? '1' : '0');
       elem.setAttribute('flipV', flipV ? '1' : '0');
       elem.setAttribute('cx', String(this.format(cx)));
       elem.setAttribute('cy', String(this.format(cy)));
       this.root.appendChild(elem);
     }

88-94: Add override to the remaining XmlCanvas2D canvas methods

AbstractCanvas2D declares/implements rect, roundrect, ellipse, image, text, stroke, fill, fillAndStroke, end and updateText — mark the corresponding implementations in packages/core/src/view/canvas/XmlCanvas2D.ts with override for consistency and stronger compiler checks.

packages/core/src/serialization/codecs/StylesheetCodec.ts (1)

130-196: Optional: consider marking getStringValue as override (if it exists on ObjectCodec)

If ObjectCodec defines getStringValue, add override for consistency with this PR’s goal. If not, ignore.

packages/core/src/view/layout/datatypes/GraphHierarchyNode.ts (1)

151-180: Clean up redundant null-check and harden against non-array hashCode

Remove the unreachable duplicate null-check and guard for array shape to avoid potential runtime errors.

-  if (
-    otherNode != null &&
-    this.hashCode != null &&
-    otherNode.hashCode != null &&
-    this.hashCode.length < otherNode.hashCode.length
-  ) {
+  if (
+    otherNode != null &&
+    Array.isArray(this.hashCode) &&
+    Array.isArray(otherNode.hashCode) &&
+    this.hashCode.length < otherNode.hashCode.length
+  ) {
     if (this.hashCode === otherNode.hashCode) {
       return true;
     }
-
-    if (this.hashCode == null || this.hashCode == null) {
-      return false;
-    }
packages/core/src/view/layout/datatypes/GraphHierarchyEdge.ts (1)

105-122: Add explicit return type for clarity

Annotate the return type to mirror the base shape and improve readability.

-  override getPreviousLayerConnectedCells(layer: number) {
+  override getPreviousLayerConnectedCells(layer: number): GraphAbstractHierarchyCell[] {
packages/core/src/view/layout/CompositeLayout.ts (2)

69-75: override on moveCell is appropriate; consider minor call simplification.

You can call directly without apply:

  • this.master.moveCell(cell, x, y)
  • this.layouts[0].moveCell(cell, x, y)

Also ensure layouts has at least one element before accessing [0].


80-86: execute override LGTM; loop can be simplified.

Use for‑of and direct calls for readability:
for (const layout of this.layouts) layout.execute(parent);

packages/core/src/serialization/codecs/editor/EditorKeyHandlerCodec.ts (1)

70-87: Parse XML attributes to correct types before binding actions

BindAction expects number/boolean; attributes are strings. Convert safely to avoid subtle runtime issues.

Apply this diff within the decode loop:

-          const as = node.getAttribute('as');
-          const action = node.getAttribute('action');
-          const control = node.getAttribute('control');
-
-          into.bindAction(as, action, control);
+          const asAttr = node.getAttribute('as');
+          const action = node.getAttribute('action') || '';
+          const controlAttr = node.getAttribute('control');
+          const code = asAttr != null ? parseInt(asAttr, 10) : NaN;
+          const ctrl = controlAttr === '1' || controlAttr === 'true';
+          if (!Number.isNaN(code)) {
+            into.bindAction(code, action, ctrl);
+          }
packages/core/src/serialization/codecs/editor/EditorToolbarCodec.ts (1)

231-231: Avoid using null! to satisfy non-nullable parameters

Passing null! to addPrototype is brittle. Prefer loosening addPrototype’s signature to accept pressed?: string | null and insert?: Function | null, or pass undefined where supported.

packages/core/src/serialization/codecs/editor/EditorPopupMenuCodec.ts (1)

40-42: Type _obj as EditorPopupMenu for clarity

Narrowing the parameter improves readability and intent without affecting behavior.

Apply this diff:

-  override encode(_enc: Codec, _obj: Element): Element | null {
+  override encode(_enc: Codec, _obj: EditorPopupMenu): Element | null {
packages/core/src/serialization/codecs/ModelCodec.ts (2)

39-43: Parameter type should be GraphDataModel, not Cell

This codec encodes GraphDataModel; using Cell here is misleading.

Apply this diff:

-  override encodeObject(enc: Codec, obj: Cell, node: Element) {
+  override encodeObject(enc: Codec, obj: GraphDataModel, node: Element) {

48-54: Narrow obj to GraphDataModel in decodeChild

Union with Cell is unnecessary; simplifies typing and intent.

Apply this diff:

-  override decodeChild(dec: Codec, child: Element, obj: Cell | GraphDataModel) {
+  override decodeChild(dec: Codec, child: Element, obj: GraphDataModel) {
@@
-      this.decodeRoot(dec, child, <GraphDataModel>obj);
+      this.decodeRoot(dec, child, obj);
packages/core/src/view/shape/node/TextShape.ts (1)

444-534: updateBoundingBox override: LGTM.

Optional: If zero-size foreignObject text should still set a 0x0 bounding box, prefer explicit null checks:

-      let ow = null;
-      let oh = null;
+      let ow: number | null = null;
+      let oh: number | null = null;
...
-      if (ow && oh) {
+      if (ow != null && oh != null) {
         this.boundingBox = new Rectangle(this.bounds.x, this.bounds.y, ow, oh);
       }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cdd4de and 8e7d635.

📒 Files selected for processing (59)
  • packages/core/src/serialization/codecs/CellCodec.ts (3 hunks)
  • packages/core/src/serialization/codecs/ChildChangeCodec.ts (5 hunks)
  • packages/core/src/serialization/codecs/GenericChangeCodec.ts (1 hunks)
  • packages/core/src/serialization/codecs/ModelCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/RootChangeCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/StylesheetCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/TerminalChangeCodec.ts (1 hunks)
  • packages/core/src/serialization/codecs/editor/EditorCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/editor/EditorKeyHandlerCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/editor/EditorPopupMenuCodec.ts (1 hunks)
  • packages/core/src/serialization/codecs/editor/EditorToolbarCodec.ts (2 hunks)
  • packages/core/src/serialization/codecs/mxGraph/mxCellCodec.ts (1 hunks)
  • packages/core/src/serialization/codecs/mxGraph/mxGeometryCodec.ts (1 hunks)
  • packages/core/src/view/animate/Morphing.ts (1 hunks)
  • packages/core/src/view/canvas/SvgCanvas2D.ts (6 hunks)
  • packages/core/src/view/canvas/XmlCanvas2D.ts (34 hunks)
  • packages/core/src/view/cell/CellOverlay.ts (1 hunks)
  • packages/core/src/view/cell/CellState.ts (1 hunks)
  • packages/core/src/view/cell/CellTracker.ts (1 hunks)
  • packages/core/src/view/geometry/Geometry.ts (2 hunks)
  • packages/core/src/view/geometry/Rectangle.ts (2 hunks)
  • packages/core/src/view/handler/EdgeHandler.ts (2 hunks)
  • packages/core/src/view/handler/EdgeSegmentHandler.ts (7 hunks)
  • packages/core/src/view/handler/ElbowEdgeHandler.ts (3 hunks)
  • packages/core/src/view/layout/CircleLayout.ts (1 hunks)
  • packages/core/src/view/layout/CompactTreeLayout.ts (2 hunks)
  • packages/core/src/view/layout/CompositeLayout.ts (2 hunks)
  • packages/core/src/view/layout/EdgeLabelLayout.ts (1 hunks)
  • packages/core/src/view/layout/FastOrganicLayout.ts (2 hunks)
  • packages/core/src/view/layout/HierarchicalLayout.ts (2 hunks)
  • packages/core/src/view/layout/ParallelEdgeLayout.ts (1 hunks)
  • packages/core/src/view/layout/PartitionLayout.ts (2 hunks)
  • packages/core/src/view/layout/RadialTreeLayout.ts (4 hunks)
  • packages/core/src/view/layout/StackLayout.ts (2 hunks)
  • packages/core/src/view/layout/SwimlaneLayout.ts (2 hunks)
  • packages/core/src/view/layout/datatypes/GraphAbstractHierarchyCell.ts (1 hunks)
  • packages/core/src/view/layout/datatypes/GraphHierarchyEdge.ts (5 hunks)
  • packages/core/src/view/layout/datatypes/GraphHierarchyNode.ts (3 hunks)
  • packages/core/src/view/plugins/ConnectionHandler.ts (4 hunks)
  • packages/core/src/view/shape/edge/ArrowConnectorShape.ts (3 hunks)
  • packages/core/src/view/shape/edge/ArrowShape.ts (2 hunks)
  • packages/core/src/view/shape/edge/ConnectorShape.ts (2 hunks)
  • packages/core/src/view/shape/edge/LineShape.ts (1 hunks)
  • packages/core/src/view/shape/edge/PolylineShape.ts (1 hunks)
  • packages/core/src/view/shape/node/ActorShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CloudShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CylinderShape.ts (1 hunks)
  • packages/core/src/view/shape/node/DoubleEllipseShape.ts (2 hunks)
  • packages/core/src/view/shape/node/EllipseShape.ts (1 hunks)
  • packages/core/src/view/shape/node/HexagonShape.ts (1 hunks)
  • packages/core/src/view/shape/node/ImageShape.ts (3 hunks)
  • packages/core/src/view/shape/node/LabelShape.ts (6 hunks)
  • packages/core/src/view/shape/node/RectangleShape.ts (3 hunks)
  • packages/core/src/view/shape/node/RhombusShape.ts (2 hunks)
  • packages/core/src/view/shape/node/SwimlaneShape.ts (4 hunks)
  • packages/core/src/view/shape/node/TextShape.ts (11 hunks)
  • packages/core/src/view/shape/node/TriangleShape.ts (1 hunks)
  • packages/core/src/view/style/edge/EdgeStyleRegistry.ts (2 hunks)
  • packages/core/tsconfig.json (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/core/tsconfig.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
PR: maxGraph/maxGraph#849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
🧬 Code graph analysis (16)
packages/core/src/serialization/codecs/editor/EditorKeyHandlerCodec.ts (1)
packages/core/src/editor/EditorKeyHandler.ts (1)
  • EditorKeyHandler (48-105)
packages/core/src/view/layout/ParallelEdgeLayout.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/view/layout/FastOrganicLayout.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/view/layout/CompactTreeLayout.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/serialization/codecs/editor/EditorToolbarCodec.ts (1)
packages/core/src/editor/EditorToolbar.ts (1)
  • EditorToolbar (59-478)
packages/core/src/view/layout/RadialTreeLayout.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/view/layout/datatypes/GraphHierarchyEdge.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/view/style/edge/EdgeStyleRegistry.ts (1)
packages/core/src/types.ts (2)
  • EdgeStyleFunction (1300-1306)
  • EdgeStyleMetaData (1554-1565)
packages/core/src/serialization/codecs/StylesheetCodec.ts (1)
packages/core/src/view/style/Stylesheet.ts (1)
  • Stylesheet (49-200)
packages/core/src/serialization/codecs/editor/EditorCodec.ts (1)
packages/core/src/editor/Editor.ts (1)
  • Editor (390-2596)
packages/core/src/view/shape/edge/ArrowConnectorShape.ts (1)
packages/core/src/util/Constants.ts (1)
  • ARROW_SPACING (342-342)
packages/core/src/serialization/codecs/CellCodec.ts (1)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/serialization/codecs/ModelCodec.ts (2)
packages/core/src/view/cell/Cell.ts (1)
  • Cell (66-886)
packages/core/src/view/GraphDataModel.ts (1)
  • GraphDataModel (218-1180)
packages/core/src/view/plugins/ConnectionHandler.ts (1)
packages/core/src/util/Constants.ts (1)
  • NONE (383-383)
packages/core/src/view/canvas/XmlCanvas2D.ts (1)
packages/html/stashed/grapheditor/www/js/Shapes.js (3)
  • flipH (166-166)
  • flipV (167-167)
  • fixDash (3431-3431)
packages/core/src/serialization/codecs/editor/EditorPopupMenuCodec.ts (1)
packages/core/src/editor/EditorPopupMenu.ts (1)
  • EditorPopupMenu (41-329)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: build (windows-2022)
🔇 Additional comments (130)
packages/core/src/view/shape/node/RhombusShape.ts (2)

44-46: LGTM: explicit override for isRoundable

Matches the base Shape contract; no behavior change.


56-62: LGTM: explicit override for paintVertexShape

Signature is consistent with the base; override improves safety against upstream changes.

packages/core/src/view/shape/edge/LineShape.ts (1)

55-61: Explicit override correctly applied

Matches the PR objective; no behavior change. This will surface breakages if the base definition changes.

packages/core/src/view/shape/node/HexagonShape.ts (1)

38-38: LGTM: explicit override correctly applied.

This aligns with the PR goal; signature and behavior remain unchanged.

packages/core/src/view/layout/EdgeLabelLayout.ts (1)

49-49: Explicit override on execute: LGTM

Matches the PR goal; no behavior change.

packages/core/src/view/cell/CellTracker.ts (1)

114-121: Explicit override on destroy is correct and consistent.

Good alignment with the PR goal; idempotent teardown and listener cleanup remain intact.

packages/core/src/view/shape/node/CylinderShape.ts (1)

50-50: Explicit override on svgStrokeTolerance: LGTM

Consistent with the PR goal; no behavior change.

packages/core/src/view/style/edge/EdgeStyleRegistry.ts (2)

36-40: Explicit override on add: LGTM

Signature remains compatible with BaseRegistry.add while extending with optional metaData; behavior unchanged and clearer intent.


55-55: Explicit override on clear: LGTM

Ensures side metadata maps are cleared in sync with the base registry.

packages/core/src/view/shape/edge/ConnectorShape.ts (3)

54-80: override on paintEdgeShape — LGTM

Signature unchanged; explicit override clarifies intent.


144-161: override on augmentBoundingBox — LGTM

No behavior change; override makes inheritance explicit.


46-49: Explicit override on updateBoundingBox — confirm noImplicitOverride for packages/core

Good use of override; automated search found no tsconfig entries for noImplicitOverride under packages/core — ensure compilerOptions.noImplicitOverride = true is set in packages/core/tsconfig.json or inherited from the repo root/extended tsconfig.

packages/core/src/view/layout/CompactTreeLayout.ts (2)

237-239: LGTM: explicit override on isVertexIgnored.

Matches the base contract; no behavior change.


258-258: LGTM: explicit override on execute.

Signature and explicit : void are consistent with the codebase.

packages/core/src/view/layout/StackLayout.ts (2)

155-199: Explicit override on moveCell: verified — signature matches GraphLayout

GraphLayout.ts declares moveCell(cell: Cell, x: number, y: number): void, so the override is compatible.


278-439: LGTM — explicit override of execute matches base signature.
GraphLayout declares execute(parent: Cell): void at packages/core/src/view/layout/GraphLayout.ts:91.

packages/core/src/view/handler/ElbowEdgeHandler.ts (3)

145-159: convertPoint override — looks good

Signature and behavior preserved; override adds compile-time safety.


167-217: redrawInnerBends override — looks good

No behavior changes; override adds clarity and safety.


63-91: Explicit override on createBends — good improvement

Clear signal of intentional overriding; helps catch base signature drift.

Run to confirm base declarations exist and config enforces explicit overrides:

Expected: matches in EdgeHandler; tsconfig shows noImplicitOverride: true in core (and/or root) to enforce usage.

packages/core/src/view/layout/PartitionLayout.ts (1)

118-208: Explicit override on execute: LGTM

Consistent with base GraphLayout; purely declarative change.

packages/core/src/view/cell/CellOverlay.ts (1)

218-220: Explicit override added on toString: LGTM

Matches PR goal; no behavioral change introduced.

packages/core/src/view/layout/HierarchicalLayout.ts (2)

180-252: Override signature is compatible — no action required

GraphLayout declares execute(parent: Cell): void; multiple subclasses already override it with extra optional parameters (e.g., CircleLayout, SwimlaneLayout, ParallelEdgeLayout, RadialTreeLayout). HierarchicalLayout's signature follows the same pattern and should not cause override errors.


595-694: Override signature OK — base method exists

GraphLayout.traverse is declared (packages/core/src/view/layout/GraphLayout.ts) and packages/core/src/view/layout/types.ts shows HierarchicalGraphLayoutTraverseArgs extends GraphLayoutTraverseArgs — signature is compatible.

packages/core/src/view/shape/edge/ArrowConnectorShape.ts (4)

77-80: resetStyles override LGTM

Matches base behavior and preserves spacing reset.


85-92: apply override LGTM

Signature and behavior unchanged; explicit override improves safety.


97-111: augmentBoundingBox override LGTM

Consistent with base contract; no functional change.


116-116: paintEdgeShape override LGTM

Signature annotated correctly; no behavior changes introduced.

packages/core/src/view/shape/node/CloudShape.ts (2)

42-51: LGTM: explicit override added correctly.

Signature matches expected shape override pattern; no functional changes.


42-42: Verified: noImplicitOverride is enabled for core

packages/core/tsconfig.json extends ../../tsconfig.json and the root tsconfig.json contains "noImplicitOverride": true, so explicit override usage is enforced.

packages/core/src/view/layout/FastOrganicLayout.ts (3)

160-164: LGTM: explicit override on isVertexIgnored

Signature aligns with the base API; no behavior change.


170-341: LGTM: explicit override on execute

Consistent with base class contract; no runtime changes introduced.


170-170: Confirmed: root tsconfig.json enables "noImplicitOverride"; ensure core inherits it

tsconfig.json (root) contains "noImplicitOverride": true (line 11). Verify packages/core/tsconfig.json extends the root config or does not override that option.

packages/core/src/view/shape/node/SwimlaneShape.ts (2)

63-65: LGTM: explicit override on isRoundable.

Signature and intent are clear.


58-58: Override on imageSrc is compatible with base Shape.
Shape.imageSrc is declared as string | null in packages/core/src/view/shape/Shape.ts, so the override is type-compatible.

packages/core/src/view/shape/node/ActorShape.ts (1)

63-69: LGTM — override on paintVertexShape is correct.

Base method declared at packages/core/src/view/shape/Shape.ts:729; packages/core/tsconfig.json does not set noImplicitOverride — using override is valid and consistent with other shapes.

packages/core/src/view/layout/RadialTreeLayout.ts (3)

69-69: LGTM: explicit override for levelDistance

Matches base contract; no behavior change.


75-75: LGTM: explicit override for nodeDistance

Consistent with base; safe change.


88-88: LGTM: explicit override for sortEdges

Annotation only; behavior unchanged.

packages/core/src/view/shape/node/EllipseShape.ts (1)

42-48: Approve — no access modifier change needed. Shape.paintVertexShape is declared without an access modifier (public by default) in packages/core/src/view/shape/Shape.ts (around line 729), so the override in packages/core/src/view/shape/node/EllipseShape.ts is consistent and requires no change.

packages/core/src/view/geometry/Geometry.ts (1)

363-365: LGTM: explicit override for clone

Matches intent; covariant return type is appropriate.

packages/core/src/view/geometry/Rectangle.ts (1)

177-179: LGTM: explicit override for clone

No behavior change; consistent with the base class.

packages/core/src/view/shape/node/DoubleEllipseShape.ts (3)

66-72: LGTM: override annotation added

Explicit override improves safety when base API changes.


80-86: LGTM: override annotation added

Consistent with project-wide explicit overrides.


108-122: LGTM: override annotation added

No functional change; clearer intent.

packages/core/src/view/layout/SwimlaneLayout.ts (2)

722-731: Explicit override on traverse: LGTM; ensure a matching base method exists.

If GraphLayout doesn’t declare traverse (even abstract), this will fail under override. Please confirm with the script above.


192-192: Approve — override is compatible with base execute

GraphLayout declares execute(parent: Cell): void, so SwimlaneLayout's override execute(parent: Cell, swimlanes: Cell[] | null = null): void is type‑compatible; LGTM.

packages/core/src/view/cell/CellState.ts (1)

341-373: Verified: Rectangle.clone exists — check TypeScript versions

  • Rectangle declares override clone() (packages/core/src/view/geometry/Rectangle.ts) and CellState uses override clone() (packages/core/src/view/cell/CellState.ts).
  • Root package.json uses TypeScript ~5.9.2 (supports the override modifier), but packages/ts-support/package.json pins TypeScript 3.8.2 (pre-override). Upgrade ts-support's TypeScript to >=4.3 or ensure that package will not tsc-compile these sources.
packages/core/src/view/layout/ParallelEdgeLayout.ts (2)

83-83: Good: explicit override on execute

Matches PR goal; no behavior change.


81-81: JSDoc link style OK — repo search inconclusive

packages/core/src/view/layout/ParallelEdgeLayout.ts contains "Implements {@link GraphLayout.execute}"; ripgrep run returned "No files were searched" and no matches. Run an unrestricted repo search for GraphLayout#execute / GraphLayout.execute (e.g. rg -nP '\bGraphLayout[#.]execute\b|{@link\s+GraphLayout[#.]execute\s*}' -uu) to confirm no '#' links remain.

packages/core/src/view/handler/EdgeHandler.ts (1)

2273-2319: Add explicit return type to getCell

Arrow-field override is fine on TS ≥ 4.9 — add a return type to lock the API:

-  override getCell = (me: InternalMouseEvent) => {
+  override getCell = (me: InternalMouseEvent): Cell | null => {

Verify locally that the repo uses TypeScript ≥4.9 (or that noImplicitOverride isn't enforced) and that Cell is in scope/imported.

packages/core/src/view/shape/node/LabelShape.ts (7)

56-56: Explicit override on imageSrc: OK

Matches the PR’s goal and keeps intent clear.


63-63: Explicit override on spacing: OK

Consistent with base Shape APIs.


79-79: Explicit override on indicatorImageSrc: OK

No behavior change; annotation looks correct.


98-107: redraw override: OK

Order and assignments preserved; no behavior changes.


125-131: paintForeground override: OK

Signature and call order look correct.


262-293: redrawHtmlShape override: OK

Logic unchanged; explicit override aligns with PR goals.


84-92: Verify base 'init' signature matches override

Confirm the base class's init signature (parameter types and return) is assignable to the override init(container: SVGElement) in packages/core/src/view/shape/node/LabelShape.ts:84–92.

packages/core/src/view/handler/EdgeSegmentHandler.ts (9)

66-116: LGTM: getPreviewPoints override is correct

Signature and behavior look consistent with the base handler.


121-219: Potential lost return value from convertPoint (verify intent)

convertPoint is used without capturing its return in two places; if it doesn’t mutate in place, y0/ye may be wrong. If it mutates, this is fine. Please confirm.

If convertPoint returns a new point, apply:

-        if (sc != null) {
-          const pt = this.graph.getConnectionPoint(source, sc);
-          
-          if (pt != null) {
-            this.convertPoint(pt, false);
-            y0 = pt.y;
-          }
-        }
+        if (sc != null) {
+          const pt0 = this.graph.getConnectionPoint(source, sc);
+          if (pt0 != null) {
+            const cpt0 = this.convertPoint(pt0, false);
+            y0 = cpt0.y;
+          }
+        }
@@
-        if (tc) {
-          const pt = this.graph.getConnectionPoint(target, tc);
-
-          if (pt != null) {
-            this.convertPoint(pt, false);
-            ye = pt.y;
-          }
-        }
+        if (tc) {
+          const pt1 = this.graph.getConnectionPoint(target, tc);
+          if (pt1 != null) {
+            const cpt1 = this.convertPoint(pt1, false);
+            ye = cpt1.y;
+          }
+        }

281-283: LGTM: tooltip override

Returning null to disable tooltips matches the stated intent. Ensure base return type allows null.


288-299: LGTM: start override

No behavior change; explicit override improves maintainability.


304-343: LGTM: createBends override

Consistent with existing behavior; explicit override only.


348-351: LGTM: redraw override

Explicit override with pre-refresh keeps current semantics.


356-412: LGTM: redrawInnerBends override

Matches existing logic; override marker is appropriate.


224-276: No change required — abspoints is defined on EdgeHandler

EdgeHandler declares abspoints: (Point | null)[] = [] (packages/core/src/view/handler/EdgeHandler.ts), so EdgeSegmentHandler inherits it and this.abspoints is valid.


34-34: No change required — overridden property type matches base

EdgeHandler declares points: Point[] = []; and EdgeSegmentHandler uses override points: Point[] = []; — types match exactly.

packages/core/src/view/canvas/XmlCanvas2D.ts (1)

88-94: Good addition of explicit override on core canvas methods.

Signatures read consistent with AbstractCanvas2D usage; no runtime behavior changes observed.

Also applies to: 106-111, 116-121, 128-132, 140-145, 157-163, 181-192, 200-211, 219-230, 237-252, 270-307, 314-329, 336-347, 357-373, 384-395, 404-415, 424-435, 443-454, 462-479, 486-503, 510-527, 535-548, 557-570, 578-595, 602-613, 615-627, 629-640, 642-654, 755-759, 771-778, 786-793, 803-812, 824-831, 847-849

packages/core/src/serialization/codecs/StylesheetCodec.ts (2)

52-80: encode override: LGTM

Signature and usage align with ObjectCodec patterns; no logic change introduced.


47-47: Accept static override allowEval as-is.
ObjectCodec declares static allowEval = false and the repo uses TypeScript ~5.9.2 (override on static members is supported since TS 4.3) — no change needed.

packages/core/src/view/layout/datatypes/GraphAbstractHierarchyCell.ts (2)

103-105: LGTM: explicit override on isEdge

Consistent with Cell.isEdge; no behavior change.


110-112: LGTM: explicit override on isVertex

Matches inheritance intent; no behavior change.

packages/core/src/view/layout/datatypes/GraphHierarchyNode.ts (2)

133-135: LGTM: override isVertex always true

Correct for hierarchy nodes; aligns with base contract.


56-56: Approve: narrowing id to string is safe

Cell.id is declared as string | null in packages/core/src/view/cell/Cell.ts, so overriding it with string is assignable and safe.

packages/core/src/view/layout/datatypes/GraphHierarchyEdge.ts (5)

34-35: LGTM: override edges property

Consistent with Cell.edges; no behavior change.


85-100: LGTM: explicit override getNextLayerConnectedCells

Signature aligns with abstract base; return type narrowed to non-null array is acceptable and matches implementation.


127-129: LGTM: explicit override on isEdge

Consistent with hierarchy edge semantics.


49-50: Narrowed target type is safe — writes use GraphHierarchyNode

Confirmed: assignments to target occur in packages/core/src/view/layout/hierarchical/GraphHierarchyModel.ts and SwimlaneModel.ts as internalEdge.target = internalTargetCell (internalTargetCell comes from the vertexMapper and is null-checked and therefore a GraphHierarchyNode), and invert() swaps source/target (both typed GraphHierarchyNode|null).


44-45: Narrowed source type — write sites validated

All assignments to GraphHierarchyEdge.source set GraphHierarchyNode|null (internalEdge.source = internalVertices[i] in GraphHierarchyModel and SwimlaneModel; invert() swaps source/target). No other write sites assign a plain Cell to this property.

packages/core/src/serialization/codecs/GenericChangeCodec.ts (1)

55-64: afterDecode correctly marked as override.

Signature and behavior remain consistent with ObjectCodec.

packages/core/src/serialization/codecs/mxGraph/mxCellCodec.ts (2)

27-29: getName correctly annotated with override.

No changes in behavior.


31-38: decodeAttribute override is correct.

Conditional style conversion remains intact; super delegation preserved.

packages/core/src/view/shape/node/TriangleShape.ts (2)

39-41: isRoundable override is appropriate.

No issues.


46-56: redrawPath override looks good.

Signature matches base expectations; logic unchanged.

packages/core/src/serialization/codecs/TerminalChangeCodec.ts (1)

51-54: afterDecode override is correct.

Behavior unchanged; previous assigned from terminal.

packages/core/src/serialization/codecs/editor/EditorCodec.ts (2)

106-124: afterDecode override LGTM.

Template resolution for defaultEdge/defaultGroup unchanged; explicit override adds clarity.


129-142: decodeChild override LGTM.

Custom handling for Array/ui nodes retained; falls back to super appropriately.

packages/core/src/serialization/codecs/mxGraph/mxGeometryCodec.ts (2)

28-30: getName correctly marked as override.

All good.


36-58: afterDecode override is correct; conversion logic unchanged.

Point array normalization remains intact; no functional changes.

packages/core/src/view/animate/Morphing.ts (1)

92-112: Explicit override is correct; enforced via root tsconfig

packages/core/tsconfig.json extends ../../tsconfig.json and the repo root tsconfig.json sets "noImplicitOverride": true (tsconfig.json:11), so explicit override is enforced project‑wide; no separate ESLint rule enforcing overrides was found.

packages/core/src/serialization/codecs/editor/EditorKeyHandlerCodec.ts (1)

38-40: LGTM: explicit override for encode

No behavior change; matches ObjectCodec contract.

packages/core/src/serialization/codecs/editor/EditorToolbarCodec.ts (2)

48-50: LGTM: explicit override for encode

No functional changes; consistent with other codecs.


133-285: LGTM: override for decode; behavior unchanged aside from above fix

Override modifier is appropriate; rest of logic mirrors existing behavior.

packages/core/src/serialization/codecs/editor/EditorPopupMenuCodec.ts (1)

47-57: LGTM: explicit overrides for encode/decode

Semantics unchanged; codec still forwards config correctly.

packages/core/src/view/canvas/SvgCanvas2D.ts (6)

238-238: LGTM: property marked as override

Matches AbstractCanvas2D contract.


349-351: LGTM: override format

No change in behavior; explicit override is correct.


373-376: LGTM: override reset

Resets gradients after super.reset(); good.


882-901: LGTM: override setLink

Maintains previous behavior; explicit override adds clarity.


906-948: LGTM: override rotate

Logic unchanged; override modifier is appropriate.


951-956: LGTM: override begin

Comment cleanup and explicit override; correct.

packages/core/src/serialization/codecs/RootChangeCodec.ts (3)

46-49: LGTM: override afterEncode

No behavior change; preserves existing encoding of root.


54-74: LGTM: override beforeDecode

Clone-then-decode pattern retained; correct.


79-83: LGTM: override afterDecode

State restoration unchanged.

packages/core/src/serialization/codecs/ChildChangeCodec.ts (5)

54-59: LGTM: override isReference

Matches intent; no behavior change.


64-72: LGTM: override isExcluded

Keeps existing exclusion rules.


77-90: LGTM: override afterEncode

Handles reference vs. full encode as before.


95-133: LGTM: override beforeDecode

Retains logic to avoid re-inserting existing cells.


138-157: LGTM: override afterDecode

Maintains state adjustments; OK.

packages/core/src/view/plugins/ConnectionHandler.ts (5)

2023-2023: LGTM: property marked as override

hotspotEnabled override is appropriate.


2038-2106: LGTM: override getCell

Behavior unchanged; override annotation adds clarity.


2109-2114: LGTM: override isValidState

Preserves existing highlighting logic.


2119-2122: LGTM: override getMarkerColor

Consistent with NONE when not highlighting.


2126-2131: LGTM: override intersects

Semantics unchanged; explicit override is correct.

packages/core/src/serialization/codecs/CellCodec.ts (4)

82-87: Override on isExcluded: LGTM.

Signature and logic unchanged; just adds explicit override.


92-109: Override on afterEncode: LGTM.

Behavior preserved; node wrapping logic remains intact.


114-173: Override on beforeDecode: LGTM.

No functional changes; matches base hook semantics.


75-77: Approve — explicit override is correct; enforcement & TS support verified.

./tsconfig.json sets noImplicitOverride: true (packages/core/tsconfig.json extends it). Root devDependency typescript is ~5.9.2 (TS ≥4.3 supports override on class properties).

packages/core/src/view/shape/node/TextShape.ts (14)

141-143: flipH/flipV property overrides: LGTM.


175-176: verticalTextRotation override: LGTM.


205-207: getSvgScreenOffset override: LGTM.


212-223: checkBounds override: LGTM.


228-302: paint override: LGTM.

Signature matches existing usage; behavior unchanged.


307-339: redraw override: LGTM.


344-363: resetStyles override: LGTM.


370-400: apply override: LGTM.


539-541: getShapeRotation override: LGTM.


546-548: getTextRotation override: LGTM.


554-556: isPaintBoundsInverted override: LGTM.


561-567: configureCanvas override: LGTM.


625-700: redrawHtmlShape override: LGTM.


119-127: Property overrides added (bounds, spacing): LGTM — verify TypeScript used to build core

Root package.json -> devDependencies: ~5.9.2 (supports override since 4.3). packages/ts-support/package.json -> devDependencies: 3.8.2 (pre-4.3). Ensure packages/core is compiled with TS >=4.3 (or upgrade the older package) so the override modifier on fields is supported.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts (2)

50-52: LGTM; optionally add explicit return type for clarity

Adding override is good. Consider making the return type explicit.

-      override parseDescription() {
+      override parseDescription(): void {
         // do nothing
       }

53-55: LGTM; optionally add explicit return type for clarity

Same here; explicit void improves readability and guards signatures.

-      override parseConstraints() {
+      override parseConstraints(): void {
         // do nothing, constraints passed in constructor
       }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e7d635 and 4697971.

📒 Files selected for processing (2)
  • packages/core/__tests__/utils.ts (0 hunks)
  • packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/core/tests/utils.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
PR: maxGraph/maxGraph#849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-24.04)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/core/src/view/canvas/XmlCanvas2D.ts (3)

124-132: Fix JSDoc param name to match signature in scale()

Doc still references “scale” while the parameter is “value”.

   /**
    * Scales the output.
    *
-   * @param scale Number that represents the scale where 1 is equal to 100%.
+   * @param value Number that represents the scale where 1 is equal to 100%.
    */
-  override scale(value: number): void {
+  override scale(value: number): void {

352-373: setDashed: correct second @param name and simplify attribute write

  • JSDoc duplicates “value”; should document “fixDash”.
  • Since fixDash is a boolean, the null check is unnecessary.
   /**
    * Enables or disables dashed lines.
    *
    * @param value Boolean that specifies if dashed lines should be enabled.
-   * @param value Boolean that specifies if the stroke width should be ignored
+   * @param fixDash Boolean that specifies if the stroke width should be ignored
    * for the dash pattern.
    * @default false
    */
   override setDashed(value: boolean, fixDash: boolean): void {
@@
     const elem = this.createElement('dashed');
     elem.setAttribute('dashed', value ? '1' : '0');
 
-    if (fixDash != null) {
-      elem.setAttribute('fixDash', fixDash ? '1' : '0');
-    }
+    elem.setAttribute('fixDash', fixDash ? '1' : '0');
 
     this.root.appendChild(elem);
   }

663-670: Add explicit override to XmlCanvas2D implementations

AbstractCanvas2D declares these methods as abstract — add override to the corresponding XmlCanvas2D implementations to make the overrides explicit and catch accidental mismatches.

File: packages/core/src/view/canvas/XmlCanvas2D.ts — add override to: rect, roundrect, ellipse, image, updateText, end, text, stroke, fill, fillAndStroke.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e7d635 and 4b85bfe.

📒 Files selected for processing (5)
  • packages/core/__tests__/utils.ts (0 hunks)
  • packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts (1 hunks)
  • packages/core/src/view/canvas/XmlCanvas2D.ts (34 hunks)
  • packages/core/src/view/cell/CellState.ts (1 hunks)
  • packages/core/src/view/shape/node/ImageShape.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • packages/core/tests/utils.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/core/src/view/cell/CellState.ts
  • packages/core/src/view/shape/node/ImageShape.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
PR: maxGraph/maxGraph#849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (windows-2022)
🔇 Additional comments (4)
packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts (2)

53-55: Explicit override on parseConstraints: LGTM

Consistent with the explicit override policy; no behavioral change.


50-52: Explicit override on parseDescription — OK

StencilShape declares parseDescription() (public by default) in packages/core/src/view/shape/stencil/StencilShape.ts; the test's override matches and no visibility change is required.

packages/core/src/view/canvas/XmlCanvas2D.ts (2)

88-94: Overrides added — LGTM

Signatures and control flow unchanged; explicit overrides improve safety.

Also applies to: 106-111, 116-121, 140-145, 157-163, 181-192, 200-211, 219-230, 237-252, 270-307, 314-329, 336-347, 384-395, 404-415, 424-435, 443-454, 462-479, 486-503, 510-527, 535-548, 557-570, 601-612, 614-626, 628-639, 641-653, 754-758, 770-777, 785-792, 802-811, 823-841, 846-848


572-578: JSDoc: fix reference for font style flags

Linking to FONT_STYLE_MASK is likely broken. Prefer referencing the constants container.

   /**
    * Sets the current font style.
    *
-   * @param value Numeric representation of the font style. This is the sum of the font styles from {@link FONT_STYLE_MASK}.
+   * @param value Numeric representation of the font style. This is the sum of the
+   * font styles from {@link mxConstants}.
    */
   override setFontStyle(value: number | null = 0): void {

If mxConstants isn’t exported in this package, point to the appropriate symbol (e.g., Constants) or drop the link and describe it as “sum of the font style flags (bold, italic, underline, shadow, strike-through)”.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/core/src/view/canvas/XmlCanvas2D.ts (2)

353-368: Make fixDash optional to preserve API and base signature compatibility.

The JSDoc says default is false, and the body already treats it as optional, but the signature requires it. This is a breaking change for call sites that pass a single argument and may conflict with the base method if it’s declared as optional there.

Apply this diff:

-  override setDashed(value: boolean, fixDash: boolean): void {
+  override setDashed(value: boolean, fixDash?: boolean): void {

Optionally, reflect optionality in the JSDoc param description.


612-624: Restore NONE-to-null normalization in setShadowColor (behavior regression).

Other color setters normalize NONE to null. Omitting it here changes state comparisons and emitted XML for callers passing NONE.

Apply this diff:

 override setShadowColor(value: string | null = null): void {
+    if (value === NONE) {
+      value = null;
+    }
     if (this.compressed) {
       if (this.state.shadowColor === value) {
         return;
       }
🧹 Nitpick comments (2)
packages/core/src/view/canvas/XmlCanvas2D.ts (2)

626-636: Optional: round shadowAlpha like other numeric attributes for consistency.

Other numeric attributes use this.format(...). Consider doing the same here.

-    elem.setAttribute('alpha', String(value));
+    elem.setAttribute('alpha', String(this.format(value)));

752-756: Add override to XmlCanvas2D methods that implement AbstractCanvas2D

AbstractCanvas2D declares these methods as abstract — mark the implementations with override to get compile-time protection against signature/behavior drift.

packages/core/src/view/canvas/XmlCanvas2D.ts — rect (661), roundrect (680), ellipse (699), image (720), end (758), text (869), stroke (935), fill (942), fillAndStroke (949)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b85bfe and 3314c8d.

📒 Files selected for processing (1)
  • packages/core/src/view/canvas/XmlCanvas2D.ts (34 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
PR: maxGraph/maxGraph#849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
🧬 Code graph analysis (1)
packages/core/src/view/canvas/XmlCanvas2D.ts (1)
packages/html/stashed/grapheditor/www/js/Shapes.js (3)
  • flipH (166-166)
  • flipV (167-167)
  • fixDash (3431-3431)
🔇 Additional comments (2)
packages/core/src/view/canvas/XmlCanvas2D.ts (2)

88-95: Good move: explicit override adoption.

Consistent use of override across the class improves safety and future refactor signals. Looks solid here and in similar methods below.


573-575: JSDoc typo fixed; verify link target.

“font style” wording is correct now—thanks. Please confirm {@link FONT_STYLE_MASK} resolves in the docs; adjust to the exported symbol (e.g., constants module or enum) if not.

#!/bin/bash
# Check for a resolvable symbol for the JSDoc link
rg -nP --type=ts '\bFONT_STYLE_MASK\b|enum\s+FontStyle\b|FONT_STYLE_' -C2

@tbouffard tbouffard merged commit 01451b9 into main Sep 24, 2025
2 checks passed
@tbouffard tbouffard deleted the chore/TS_core_no_implicit_override branch September 24, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant