mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 21:09:26 -06:00
This commit addresses all feedback from @junlarsen in PR #7801: 1. **Remove default generic parameter from ComponentConfig**: Added explicit AnyComponentConfig type alias instead of default parameter, improving type clarity and preventing accidental usage of overly broad types. 2. **Keep typeof pattern for component configs**: After consideration, we kept the `ComponentConfig<typeof COMPONENT_NAME>` pattern rather than creating individual type aliases (CompilerComponentConfig, etc.) because: - Maintains single source of truth (component name constant drives everything) - Zero maintenance burden (no additional aliases to maintain) - Better refactoring safety (changing component name only requires updating constant) - Type safety is preserved (misspelled constants caught at compile time) 3. **Use Pick types for options parameters**: Replaced inline object types with `Pick<AnyComponentConfig, ...>` and `Pick<LayoutItem, ...>` to ensure options match the actual interface properties exactly. 4. **Remove section comment**: Removed the large comment block as suggested, keeping the code cleaner and more focused. 5. **Document GoldenLayout type issues**: The existing TODO and comments properly explain the TypeScript definition issues with GoldenLayout. 6. **Add targeted Sentry reporting**: Added SentryCapture only for the specific case that should never happen with proper typing (unknown component names). **Additional improvement**: Simplified createDragSource API by returning the EventEmitter directly instead of requiring callers to access ._dragListener. Updated 25+ call sites from: `createDragSource(...)._dragListener.on(...)` to: `createDragSource(...).on(...)` This hides implementation details and provides a cleaner, more intuitive API. Thanks to @junlarsen for the thorough code review and excellent suggestions\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>