Files
compiler-explorer/static
Matt GodboltandClaude 25bb769fe4 Improve GoldenLayout type safety and remove 'as any' casts
This commit implements a comprehensive type safety improvement for GoldenLayout
configurations, addressing issue #4490 'The War of The Types'.

## Changes Made

### New Type Infrastructure
- Created static/goldenlayout-types.ts with:
  - ComponentStateMap mapping component names to their state types
  - TypedGoldenLayoutConfig extending GoldenLayout's Config interface
  - TypedComponentConfig with proper type constraints
  - Helper functions for type conversion and component creation

### Core Type Fixes
- Replaced incomplete ConfigType in main.ts with TypedGoldenLayoutConfig
- Updated initializeLayout and findConfig functions to use typed configurations
- Added proper type conversion for layout configurations from various sources

### Eliminated Type Casts
- Removed 25 instances of createDragSource(...) as any across 5 files:
  - static/main.ts: 3 instances (setupAdd function)
  - static/panes/compiler.ts: 20 instances (all view buttons)
  - static/panes/conformance-view.ts: 1 instance
  - static/panes/ir-view.ts: 1 instance
  - static/panes/tree.ts: 1 instance
- All now use typed createTypedDragSource wrapper function

## Benefits
- Compile-time type checking for GoldenLayout configurations
- Better IDE support with autocomplete and error detection
- Cleaner, more maintainable code
- No breaking changes - backward compatibility maintained

## Next Steps to Complete Migration
1. Update Components module functions to return TypedComponentConfig directly
2. Change core ComponentConfig interface to use literal 'component' type
3. Add runtime validation for deserialized layout configurations
4. Remove legacy conversion functions once all code uses typed system
5. Consider extending type safety to other GoldenLayout APIs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-12 12:29:50 -05:00
..
2025-05-19 06:51:21 -05:00
2025-02-26 02:07:09 +02:00
2025-02-26 02:07:09 +02:00
2025-02-26 02:07:09 +02:00
2024-10-25 12:19:04 +03:00
2025-04-24 12:10:37 -05:00
2025-04-24 12:10:37 -05:00
2025-04-24 18:41:55 -05:00