Skip to content

improvement(providers): replace @ts-ignore with typed ProviderError class#3235

Merged
waleedlatif1 merged 1 commit intostagingfrom
timing
Feb 17, 2026
Merged

improvement(providers): replace @ts-ignore with typed ProviderError class#3235
waleedlatif1 merged 1 commit intostagingfrom
timing

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Feb 17, 2026

Summary

  • Add ProviderError class to providers/types.ts with typed timing property
  • Replace 14 @ts-ignore + dynamic property assignments across 12 provider files
  • Add success field to FunctionCallResponse (already pushed by every provider)
  • Replace any[] casts with proper types (Message[], FunctionCallResponse[]) in xai, openrouter, vllm, bedrock
  • Remove unused vllmErrorType/vllmErrorCode dead code
  • Remove & { success: boolean } workaround in azure-openai

fixes #3180

Type of Change

  • Refactor (type safety improvement, no runtime behavior change)

Testing

TypeScript compiles cleanly with tsc --noEmit. No runtime changes.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 17, 2026 10:04pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Greptile Summary

Replaced all @ts-ignore annotations with a properly typed ProviderError class across 12 provider files, improving type safety without changing runtime behavior.

Key improvements:

  • Introduced ProviderError class in providers/types.ts with typed timing property (startTime, endTime, duration)
  • Added success?: boolean field to FunctionCallResponse interface (already returned by all providers)
  • Replaced any[] type annotations with proper types: Message[], FunctionCallResponse[], Record<string, unknown>[]
  • Removed type workaround & { success: boolean } from azure-openai
  • Cleaned up unused dead code (vllmErrorType, vllmErrorCode) from vllm provider

Changes verified:

  • All 14 @ts-ignore comments eliminated across the provider layer
  • TypeScript compiles cleanly with no runtime behavior changes
  • Error handling pattern remains consistent: errors thrown with timing metadata preserved

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a pure type safety refactoring with no runtime behavior changes
  • Score of 5 reflects: (1) systematic replacement of @ts-ignore with proper types across all providers following identical pattern, (2) no runtime logic changes - only type annotations improved, (3) TypeScript compiles cleanly per PR description, (4) removal of dead code in vllm, (5) changes are well-scoped and focused on type safety improvement
  • Pay attention to apps/sim/providers/bedrock/index.ts and apps/sim/providers/openrouter/index.ts - both use non-null assertions (result.output!) that assume output is defined when success is true, which is correct based on runtime behavior but not enforced by TypeScript types

Important Files Changed

Filename Overview
apps/sim/providers/types.ts Added ProviderError class with typed timing property and success field to FunctionCallResponse interface
apps/sim/providers/azure-openai/index.ts Replaced @ts-ignore with ProviderError, removed & { success: boolean } type workaround from toolCalls array
apps/sim/providers/bedrock/index.ts Replaced @ts-ignore with ProviderError, changed any[] to FunctionCallResponse[] and Record<string, unknown>[], added non-null assertion on result.output
apps/sim/providers/openrouter/index.ts Replaced @ts-ignore with ProviderError, changed any[] to Message[], FunctionCallResponse[], added non-null assertion on result.output
apps/sim/providers/vllm/index.ts Replaced @ts-ignore with ProviderError, changed any[] to Message[], removed dead code for vllmErrorType/vllmErrorCode

Class Diagram

classDiagram
    class Error {
        +string message
        +string name
        +string stack
    }
    
    class ProviderError {
        +string message
        +string name
        +TimingInfo timing
        +constructor(message, timing)
    }
    
    class TimingInfo {
        +string startTime
        +string endTime
        +number duration
    }
    
    class FunctionCallResponse {
        +string name
        +Record arguments
        +string startTime
        +string endTime
        +number duration
        +Record result
        +Record output
        +Record input
        +boolean success
    }
    
    Error <|-- ProviderError : extends
    ProviderError *-- TimingInfo : contains
    
    note for ProviderError "Replaces Error + @ts-ignore pattern\nProvides typed timing metadata"
    note for FunctionCallResponse "Added success field\n(already returned by providers)"
Loading

Last reviewed commit: 2cc728f

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Greptile Summary

Replaces 14 @ts-ignore directives across 12 provider files with a new typed ProviderError class that properly encapsulates timing information for error handling.

Key improvements:

  • Introduced ProviderError class in providers/types.ts with typed timing property
  • Added success?: boolean field to FunctionCallResponse interface (already used but not typed)
  • Replaced any[] with proper types (Message[], FunctionCallResponse[], Record<string, unknown>[])
  • Removed & { success: boolean } type workaround in azure-openai
  • Cleaned up unused vllmErrorType/vllmErrorCode dead code in vllm provider

Type safety enhancements:

  • All provider error handlers now use strongly-typed ProviderError instead of dynamically adding properties to generic Error objects
  • Message arrays and tool call arrays now have explicit types instead of any[]
  • Non-null assertions (result.output!) are safe because output is always defined when success: true

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • This is a pure type safety refactor with zero runtime behavior changes. The changes eliminate @ts-ignore directives by introducing proper TypeScript types, making the codebase more maintainable. All type assertions are sound (e.g., result.output! is safe because output is always defined when success: true). The PR successfully compiles with tsc --noEmit, demonstrating type correctness.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/providers/types.ts Added ProviderError class with typed timing property and success field to FunctionCallResponse
apps/sim/providers/anthropic/core.ts Replaced @ts-ignore with typed ProviderError for error handling in 2 locations
apps/sim/providers/azure-openai/index.ts Replaced @ts-ignore with ProviderError, removed & { success: boolean } workaround from toolCalls type
apps/sim/providers/bedrock/index.ts Replaced @ts-ignore with ProviderError, replaced any[] with typed arrays, added non-null assertion for result.output!
apps/sim/providers/vllm/index.ts Replaced @ts-ignore with ProviderError, removed unused vllmErrorType/vllmErrorCode properties, typed allMessages as Message[]

Class Diagram

classDiagram
    class ProviderError {
        +string name
        +string message
        +timing timing
        +constructor(message, timing)
    }
    
    class Error {
        +string name
        +string message
    }
    
    class FunctionCallResponse {
        +string name
        +Record arguments
        +string startTime
        +string endTime
        +number duration
        +Record result
        +Record output
        +Record input
        +boolean success
    }
    
    class TimingInfo {
        +string startTime
        +string endTime
        +number duration
    }
    
    ProviderError --|> Error : extends
    ProviderError *-- TimingInfo : contains
    
    note for ProviderError "Replaces @ts-ignore pattern with typed error"
    note for FunctionCallResponse "success field now formally typed"
Loading

Last reviewed commit: 2cc728f

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit cdacb79 into staging Feb 17, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the timing branch February 17, 2026 22:20
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.

1 participant

Comments