refactor(typescript): introduce the Constructor<T> utility type - #1011
Conversation
Add a generic Constructor<T> type in types.ts to simplify and reuse constructor type declarations: - Replace the inline constructor type in ShapeConstructor with Constructor<Shape> - Use ShapeConstructor in EdgeHandler to replace the ad-hoc cast
WalkthroughAdds a reusable generic Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/types.ts (1)
1464-1473: Consider adding a brief description to theConstructor<T>JSDoc.Other significant utility types in this file (
PerimeterFunction,EdgeStyleFunction,MarkerFactoryFunction) carry prose descriptions. Adding one here would keep documentation consistent for consumers of the public API.✏️ Suggested improvement
/** + * Represents a constructor function for a class that produces instances of type `T`. + * * `@since` 0.23.0 */ export type Constructor<T> = new (...args: any[]) => T;
improve jsdoc [skip ci]
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/types.ts (1)
1464-1468: Optional: add@categorytoConstructor<T>for documentation discoverability.All domain-relevant exported types carry a
@categorytag.Constructor<T>is a general utility type, but if it appears in the generated API docs it should be discoverable. Consider@category Shape(to mirrorShapeConstructor) or a new@category Utility.



Add a generic Constructor type in types.ts to simplify and reuse constructor type declarations:
Summary by CodeRabbit