Skip to content

Conversation

joshuayoes
Copy link
Contributor

Please verify the following:

  • yarn build-and-test:local passes
  • I have added tests for any new features, if relevant
  • README.md (or relevant documentation) has been updated with your changes

Describe your PR

Summary

This PR improves type safety across the Reactotron codebase by replacing any types in the CommandMap interface with specific, well-defined TypeScript interfaces. All payload types are now consolidated in reactotron-core-contract for consistency and reusability.

Changes Made

1. New Type Definitions in reactotron-core-contract

Created dedicated type definition files for command payloads:

  • apiResponse.ts - ApiResponsePayload for HTTP request/response data
  • asyncStorage.ts - AsyncStorageMutationPayload for storage mutations
  • benchmark.ts - BenchmarkReportPayload for performance benchmarks
  • clientIntro.ts - ClientIntroPayload for client connection info
  • display.ts - DisplayPayload for custom display events
  • image.ts - ImagePayload for image data with metadata
  • sagaTaskComplete.ts - SagaTaskCompletePayload and SagaTaskCompleteChild for Redux-saga tasks
  • customCommand.ts - CustomCommandRegisterPayload and CustomCommandUnregisterPayload
  • repl.ts - ReplLsResponsePayload and ReplExecuteResponsePayload

2. Updated CommandMap Interface

Replaced all any types with specific payload types:

// Before
[CommandType.ApiResponse]: any
[CommandType.Display]: any
// ...

// After
[CommandType.ApiResponse]: ApiResponsePayload
[CommandType.Display]: DisplayPayload
// ...

3. Updated reactotron-core-client

  • Imported and used new payload types from reactotron-core-contract
  • Updated DisplayConfig to extend DisplayPayload
  • Fixed type assertions for name and id fields where needed
  • Updated plugins (api-response, benchmark, image, repl) to use contract types
  • Removed local type definitions that are now in the contract

4. Updated reactotron-core-ui

Removed duplicate type definitions in UI command components and imported types from reactotron-core-contract:

  • ApiResponseCommand
  • AsyncStorageMutationCommand
  • BenchmarkReportCommand
  • ClientIntroCommand
  • DisplayCommand
  • ImageCommand
  • SagaTaskCompleteCommand

5. Documentation

Updated reactotron-core-contract/README.md with:

  • Comprehensive usage examples for clients and plugins
  • Complete command type reference tables
  • Guide for plugin authors
  • Examples showing how to use CommandType and payload types

Notes

  • Some fields remain typed as any where appropriate (e.g., saga middleware dynamic data, storage values, eval results)
  • All existing functionality is preserved - this is purely a type safety improvement
  • No breaking changes to the public API

… async storage mutations, benchmarks, client introductions, custom commands, displays, images, and saga task completions
…and import payload types from reactotron-core-contract
…sive usage examples, installation instructions, and detailed command types and payloads
@joshuayoes joshuayoes self-assigned this Oct 3, 2025
@joshuayoes joshuayoes changed the title chore: add reactotron-core-contract chore: add missing command payloads to reactotron-core-contract Oct 3, 2025
@joshuayoes joshuayoes merged commit 81c233d into master Oct 6, 2025
7 checks passed
@joshuayoes joshuayoes deleted the refactor-reactotron-core-contract branch October 6, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants