Skip to content

Improve reporter and statistics typing #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

BelfordZ
Copy link
Contributor

@BelfordZ BelfordZ commented May 22, 2025

User description

Summary

  • refine Reporter configuration typing and remove unused any types
  • define structured types in statistics module
  • replace numerous any annotations with precise interfaces

Testing

  • npm run compile:ts
  • npm test

PR Type

Enhancement


Description

  • Replace all any types with precise TypeScript types

  • Define structured interfaces for statistics and reporter modules

  • Improve function signatures and internal type safety

  • Refactor class properties and methods for stricter typing


Changes walkthrough 📝

Relevant files
Enhancement
index.ts
Strongly type reporter configuration and class properties

src/reporter/index.ts

  • Introduced ReporterConfig interface for reporter configuration typing
  • Updated Reporter interface and class to use precise types instead of
    any
  • Refined constructor and timer properties with explicit types
  • +19/-6   
    index.ts
    Comprehensive type refinement for statistics module           

    src/statistics/index.ts

  • Defined interfaces for network context, transaction stats, and all
    ring types
  • Replaced all any usages with explicit, structured types throughout the
    module
  • Updated class properties, method signatures, and internal logic for
    type safety
  • Improved initialization and utility functions with strict typing
  • +77/-48 

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🏅 Score: 92
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    API Mocking in Tests

    Ensure that any tests for the new or refactored statistics API endpoints (such as 'tx-stats') properly mock external dependencies and do not make real network calls or side effects.

    this.context.network?.registerExternalGet('tx-stats', (req, res) => {
      try {
        // todo: reject if request is not coming from node operator dashboard
        let stats: TxStats = {
    Linear Issue Linkage

    Confirm that the PR is linked to a Linear issue as required by process, since the branch name and PR description do not clearly show a Linear issue key.

    interface ReporterConfig {
      recipient?: string
      interval: number
      console: boolean
      logSocketReports: boolean
    }

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant