refactor(type)!: make DIRECTION_MASK read-only by tbouffard · Pull Request #803 · maxGraph/maxGraph · GitHub
Skip to content

refactor(type)!: make DIRECTION_MASK read-only#803

Merged
tbouffard merged 2 commits into
mainfrom
refactor/378-DIRECTION_MASK_read-only
May 3, 2025
Merged

refactor(type)!: make DIRECTION_MASK read-only#803
tbouffard merged 2 commits into
mainfrom
refactor/378-DIRECTION_MASK_read-only

Conversation

@tbouffard

@tbouffard tbouffard commented May 3, 2025

Copy link
Copy Markdown
Member

Notes

Covers #378

Summary by CodeRabbit

  • Documentation

    • Updated the changelog to note that the direction mask constant is now read-only at the type level.
  • Refactor

    • Made the direction mask constant read-only, ensuring its values cannot be modified.

@tbouffard tbouffard added the refactor Code refactoring label May 3, 2025
@coderabbitai

coderabbitai Bot commented May 3, 2025

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/src/util/Constants.ts (1)

416-425: Proper Immutability at Type Level Achieved
The addition of as const correctly enforces literal types and readonly properties for DIRECTION_MASK at compile time.

Consider also applying Object.freeze at runtime if you need to enforce immutability during execution:

-export const DIRECTION_MASK = {
+export const DIRECTION_MASK = Object.freeze({
   /** No direction. */
   NONE: 0,
   WEST: 1,
   NORTH: 2,
   SOUTH: 4,
   EAST: 8,
   /** All directions. */
   ALL: 15,
-} as const;
+} as const);
CHANGELOG.md (1)

26-26: Link Changelog Entry to Issue for Traceability
The new breaking change for constants.DIRECTION_MASK is correctly documented. For better traceability, consider linking it to the related issue:

- - `constants.DIRECTION_MASK` is now read-only (types only).
+ - `constants.DIRECTION_MASK` is now read-only (types only). See [#378](https://github.com/maxGraph/maxGraph/issues/378).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b2efb4 and ff45d6e.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • packages/core/src/util/Constants.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-2022)

@sonarqubecloud

sonarqubecloud Bot commented May 3, 2025

Copy link
Copy Markdown

@tbouffard tbouffard merged commit 6d99b3a into main May 3, 2025
@tbouffard tbouffard deleted the refactor/378-DIRECTION_MASK_read-only branch May 3, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant