refactor(type): explicitly declare the MouseListenerSet interface by tbouffard · Pull Request #770 · maxGraph/maxGraph
packages/core/src/view/plugins/SelectionCellsHandler.ts (2)
27-27: Good addition of type-safe interface import.
The explicit type import of MouseListenerSet prepares for the interface implementation, improving code organization and type safety.
51-51: Excellent enhancement to class declaration.
Explicitly implementing the MouseListenerSet interface alongside GraphPlugin provides stronger type checking and better documents the class's capabilities. This ensures the class correctly implements all required mouse handler methods with proper signatures, preventing potential runtime errors.
packages/core/src/view/other/PanningManager.ts (1)
44-56: Clean and effective parameter simplification.
Removing unused parameters from the mouse event handlers improves code clarity while maintaining interface compatibility. This change makes it immediately clear that these methods don't use any event information. The implementation remains unchanged functionally but is now more maintainable and easier to understand.
packages/core/src/view/GraphView.ts (1)
2173-2177: Simplified method signature improves clarity.
Removing unused parameters from the mouseDown handler creates cleaner, more maintainable code by making it immediately obvious the method doesn't use any event parameters. This refactoring maintains interface compatibility while improving code readability.
packages/core/src/editor/Editor.ts (1)
1628-1628: Improved type safety and parameter naming convention.
Changing the parameter type from any to EventSource and renaming from sender to _sender follows best practices for TypeScript interfaces. The underscore prefix clearly indicates the parameter is intentionally unused, while the explicit type ensures compatibility with the MouseListenerSet interface and helps catch potential type errors.
Also applies to: 1643-1643, 1649-1649
packages/core/src/view/other/DragSource.ts (4)
55-57: Documentation improvements look good.
The class documentation has been reformatted for better readability while maintaining the original content.
126-127: Updated reference from mxGraph to Graph in documentation.
The comment has been updated to use the current class name Graph instead of legacy mxGraph, which improves consistency.
141-142: Updated references from mxGuide to Guide in comments.
The comments have been updated to reference the current class name Guide instead of legacy mxGuide, maintaining consistency with the codebase.
Also applies to: 146-147
294-299: Documentation example code has been modernized.
The code example in the comment has been improved:
- Changed variable declaration from
vartoconst - Updated event utility references from
mxEventtoEventUtils
This aligns with modern JavaScript practices and current naming in the codebase.
packages/core/src/view/plugins/ConnectionHandler.ts (3)
60-66: Updated imports to include MouseListenerSet as a type import.
The import statement now correctly includes the MouseListenerSet type, which is necessary for the interface implementation.
207-207: Explicitly implementing MouseListenerSet interface.
The ConnectionHandler class now explicitly implements the MouseListenerSet interface alongside GraphPlugin. This guarantees that the class implements all required mouse event handler methods with the correct signatures, improving type safety.
754-754: Updated mouse event handler parameters to indicate unused parameters.
The first parameter in mouse event handlers has been renamed from sender to _sender to clearly indicate that it's unused within these methods. This follows TypeScript conventions for marking unused parameters.
Also applies to: 1026-1026, 1491-1491
packages/core/src/view/plugins/TooltipHandler.ts (3)
28-28: Added MouseListenerSet to import statement.
The import statement now properly includes the MouseListenerSet type, which is necessary for the interface implementation.
40-40: TooltipHandler now explicitly implements MouseListenerSet interface.
Explicitly implementing the MouseListenerSet interface ensures that the class implements all required mouse event handler methods with the correct signatures, improving type safety and preventing potential errors.
177-178: Updated mouse event handler parameters and documentation.
The parameter naming has been updated from sender to _sender to indicate it's unused in the method implementations, and some comment text has been improved. This follows TypeScript conventions for marking unused parameters.
Also applies to: 185-185, 210-210
packages/core/src/view/handler/EdgeHandler.ts (3)
59-59: Updated imports to include MouseListenerSet.
The import statement now properly includes the MouseListenerSet type, which is necessary for the interface implementation.
77-77: EdgeHandler now explicitly implements MouseListenerSet.
The class now explicitly implements the MouseListenerSet interface, ensuring that it provides all required mouse event handler methods with the correct signatures. This improves type safety and enforces the interface contract.
787-787: Updated mouse event handler parameters to indicate unused parameters.
The first parameter in mouse event handlers has been renamed from sender to _sender to clearly indicate that it's unused within these methods. This is a good practice in TypeScript to mark parameters that are part of an interface but not used in the implementation.
Also applies to: 1311-1311, 1419-1419
packages/core/src/view/cell/CellTracker.ts (3)
24-24: Looks good: Import of MouseListenerSet as type.
The import has been correctly updated to import MouseListenerSet as a type from the types file.
79-79: Good: Explicit implementation of MouseListenerSet interface.
Explicitly implementing the MouseListenerSet interface helps ensure type safety and enforces the correct method signatures.
106-106: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
packages/core/src/view/handler/VertexHandler.ts (5)
33-34: Looks good: Import of MouseListenerSet as type.
The import has been correctly updated to import MouseListenerSet as a type from the types file.
49-49: Good: Explicit implementation of MouseListenerSet interface.
Explicitly implementing the MouseListenerSet interface helps ensure type safety and enforces the correct method signatures.
635-635: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
834-834: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
1210-1210: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
packages/core/src/view/plugins/RubberBandHandler.ts (5)
34-35: Looks good: Import of MouseListenerSet and GraphPlugin as types.
The imports have been correctly updated to import both MouseListenerSet and GraphPlugin as types from the types file.
60-60: Good: Explicit implementation of MouseListenerSet and GraphPlugin interfaces.
Explicitly implementing both the MouseListenerSet and GraphPlugin interfaces helps ensure type safety and enforces the correct method signatures.
180-180: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
243-243: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
300-300: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
packages/core/src/view/other/Outline.ts (6)
38-38: Looks good: Import of MouseListenerSet as type and updating Listenable import.
The imports have been correctly updated to import MouseListenerSet as a type and change Listenable to a type import as well.
81-81: Good: Explicit implementation of MouseListenerSet interface.
Explicitly implementing the MouseListenerSet interface helps ensure type safety and enforces the correct method signatures.
82-87: Clean constructor parameter simplification.
Changed the constructor parameter container to be optional without a default value, which is cleaner and makes the optional nature of the parameter more explicit in the signature.
575-575: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
607-607: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.
702-702: Good: Renamed unused parameter to indicate it's not used.
Renaming the sender parameter to _sender clearly indicates that this parameter is not used in the method implementation, which is a good practice.