Skip to content

fix: remove explicit type annotations from SeverityChart Tooltip formatter#14

Merged
SynTechRev merged 2 commits into
masterfrom
copilot/fix-typescript-error-severitychart
Apr 13, 2026
Merged

fix: remove explicit type annotations from SeverityChart Tooltip formatter#14
SynTechRev merged 2 commits into
masterfrom
copilot/fix-typescript-error-severitychart

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Recharts' Tooltip formatter prop is typed as Formatter<ValueType, NameType> where ValueType and NameType are constrained generics. Explicitly annotating the callback parameters as number and string breaks assignability, causing a TS compilation error that blocks desktop builds.

Change

frontend/components/analysis/SeverityChart.tsx

- formatter={(value: number, name: string) => [
+ formatter={(value, name) => [
    `${value} anomal${value === 1 ? 'y' : 'ies'}`,
    name,
  ]}

Dropping the annotations lets TypeScript infer from recharts' own type definitions — no semantic change, type-system compatibility restored.

Original prompt

Fix TypeScript Compilation Error in SeverityChart and Clean Up Release Branches

Problem Overview

The repository has been stuck in a failed release cycle with multiple attempts from VS Code agents. There are TypeScript compilation errors blocking desktop builds and a confused branch/tag state.

Current Issues

  1. TypeScript Compilation Error in frontend/components/analysis/SeverityChart.tsx (line 89)
  2. v2.1.1 branch exists but builds fail on it repeatedly
  3. Multiple failed workflow runs (runs Fix broken desktop download links and add automated release workflow #8, docs: update README download links and RELEASING.md for v2.1.0 release #9, #22, #24)
  4. No successful release created yet despite being ready

Root Cause

File: frontend/components/analysis/SeverityChart.tsx
Line: 89-92
Error:

Type error: Type '(value: number, name: string) => [string, string]' is not assignable to type 'Formatter<ValueType, NameType>'

Current problematic code:

<Tooltip
  formatter={(value: number, name: string) => [
    `${value} anomal${value === 1 ? 'y' : 'ies'}`,
    name,
  ]}
/>

The explicit type annotations (value: number, name: string) conflict with recharts' stricter type system in newer versions. TypeScript cannot infer the proper compatibility.

Required Changes

1. Fix TypeScript Error in SeverityChart.tsx

Location: frontend/components/analysis/SeverityChart.tsx lines 88-93

Change from:

<Tooltip
  formatter={(value: number, name: string) => [
    `${value} anomal${value === 1 ? 'y' : 'ies'}`,
    name,
  ]}
/>

Change to:

<Tooltip
  formatter={(value, name) => [
    `${value} anomal${value === 1 ? 'y' : 'ies'}`,
    name,
  ]}
/>

Explanation: Remove explicit type annotations and let TypeScript infer the types from recharts' Formatter type definition. This ensures compatibility with the library's expected signature.

2. Verify No Other TypeScript Errors

Check for any similar patterns in other chart components:

  • frontend/components/analysis/*.tsx
  • Any other files using recharts Tooltip formatters

3. Clean Up Branch State (Optional Documentation)

Add a note in commit message about cleaning up the v2.1.1 branch confusion for future reference.

Testing Requirements

Before Committing

  1. Type Check:

    cd frontend
    npm run type-check  # or tsc --noEmit
  2. Build Test:

    cd frontend
    ELECTRON_BUILD=1 npm run build
  3. Ensure no compilation errors

After PR Merge

  1. Verify Desktop Build workflow passes on master
  2. Verify all TypeScript compilation succeeds
  3. Confirm frontend builds without errors

Expected Outcome

After this fix:

  1. ✅ TypeScript compilation succeeds
  2. ✅ Desktop build workflows pass
  3. ✅ Master branch is clean and ready for v2.1.0 release
  4. ✅ Frontend builds successfully in Electron mode
  5. ✅ No more repetitive failures

Post-Merge Actions

After this PR is merged to master:

  1. Delete the v2.1.1 branch (if it exists as a branch, not a tag):

    git push origin --delete v2.1.1
  2. Create v2.1.0 release tag from clean master:

    git tag -a v2.1.0 -m "Release v2.1.0 - First Official Release"
    git push origin v2.1.0
  3. Monitor automated build:

    • All 4 platforms should build successfully
    • GitHub Release should be created automatically
    • All installers should be attached

Files to Modify

  1. frontend/components/analysis/SeverityChart.tsx - Remove type annotations from Tooltip formatter

Acceptance Criteria

  • TypeScript compilation succeeds without errors
  • Frontend builds successfully with ELECTRON_BUILD=1
  • Desktop Build workflow passes on master
  • No type errors in any chart components
  • Code change is minimal and focused on the fix
  • CI passes on the PR
  • Ready to create v2.1.0 release after merge

Related Context

  • Multiple failed release attempts from VS Code agents
  • v2.1.1 branch has been problematic
  • Master branch currently passing (commit: f52adc9)
  • All infrastructure ready except for this TypeScript error

Success Metrics

After merge and v2.1.0 release:

  • Zero TypeScript compilation errors
  • 4 desktop installers built successfully
  • GitHub Release published
  • Download links functional
  • No more agent cancellations or errors

The following is the prior conversation context from the user's chat exploration (may be truncated):

Assistant: Perfect! Now I have a complete picture. Let me provide you with a thorough assessment:

🔍 COMPLETE ASSESSMENT & ROOT CAUSE ANALYSIS

📊 CURRENT STATE

✅ What's Working

  1. README was updated - The agent's PR merged successfully
  2. Workflow exists - .github/workflows/release-desktop.yml is in place
  3. PR feat: React Native mobile app with TypeScript-ported analysis detectors #7 (Mobile) - Still open and ready to merge (Draft status)

❌ The Problem - NO RELEASE HAS BEEN CREATED YET

Root Cause: The README now points to release links, but NO ACTUAL RELEASE EXISTS.

**Why the 404 error happens:...

This pull request was created from Copilot chat.

…atter

Removes the explicit `(value: number, name: string)` type annotations from
the recharts Tooltip formatter callback. The explicit types conflict with
recharts' stricter Formatter<ValueType, NameType> type in newer versions.
Letting TypeScript infer the types from the library's definition resolves
the compilation error.

Fixes TypeScript error: Type '(value: number, name: string) => [string, string]'
is not assignable to type 'Formatter<ValueType, NameType>'

Agent-Logs-Url: https://github.com/SynTechRev/ODIA/sessions/68618152-d7a0-4312-b08a-d19a0cf7b76c

Co-authored-by: SynTechRev <235390103+SynTechRev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeScript compilation error in SeverityChart fix: remove explicit type annotations from SeverityChart Tooltip formatter Apr 13, 2026
Copilot AI requested a review from SynTechRev April 13, 2026 20:25
@SynTechRev SynTechRev marked this pull request as ready for review April 13, 2026 20:32
Copilot AI review requested due to automatic review settings April 13, 2026 20:32
@SynTechRev SynTechRev merged commit 1c2987d into master Apr 13, 2026
17 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a TypeScript compilation error in the frontend severity pie chart by making the Recharts <Tooltip /> formatter callback contextually typed (via Recharts’ Formatter<ValueType, NameType>), unblocking desktop/Electron builds.

Changes:

  • Remove explicit number/string parameter annotations from Tooltip.formatter in SeverityChart to restore assignability to Recharts’ formatter type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SynTechRev SynTechRev deleted the copilot/fix-typescript-error-severitychart branch April 13, 2026 20:38
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.

3 participants