Skip to content

Replace as any casts with proper TypeScript types #469

Closed

Description

@DeFiVC

What

Replace as any type assertions throughout the codebase with proper TypeScript types to improve type safety and catch potential runtime errors at compile time.

Why

Using as any defeats the purpose of TypeScript's type system and can mask bugs. It also makes refactoring harder since the compiler can't verify correctness.

Affected Files

  1. src/middleware/rate-limit.ts (lines 20, 54, 68, 86) - request as any
  2. src/modules/admin/webhook.service.ts (lines 61, 224, 260, 271) - Untyped parameters
  3. src/services/webhook-dispatcher.ts (line 160, 234) - payload as any, col: any
  4. src/routes/versioning.ts (line 34) - (request as any).apiVersion
  5. src/stellar/transactions.ts (line 28) - (err as any)?.response
  6. src/stellar/client.ts (lines 98, 151, 184, 217, 253) - err: any
  7. src/middleware/response-envelope.ts (line 13) - (request as any).apiVersion
  8. src/middleware/validation.ts (lines 32, 41) - result.data as any

Scope

  • Define proper interfaces/types for request objects with additional properties (e.g., apiVersion)
  • Use unknown for error types and narrow with type guards
  • Create proper return type interfaces for webhook stats
  • No functional changes

Acceptance Criteria

  • No as any casts remain in the codebase
  • TypeScript compilation succeeds with strict mode
  • Error handling properly narrows types before accessing properties
  • All type assertions use more specific types or unknown

Technical Context

  • The codebase uses Fastify with TypeScript
  • Error types from Stellar SDK and HTTP calls need proper typing
  • Request augmentation should use module augmentation or proper interfaces

Activity

  1. Yungmon22 commented on Sep 28, 2026

    @Yungmon22

    @Yungmon22 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, I’ve gone through the issue requirements and relevant documentation. I have a clear understanding of the task and am confident I can deliver a solid solution. I’d be glad to discuss my approach before I begin.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Yungmon22 to this issue.

  2. Cyber-Mitch commented on Sep 28, 2026

    @Cyber-Mitch
    Contributor

    @Cyber-Mitch has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Greetings Maintainer!
    I want to work on this issue. I'll make a PR within 24 hours of assignment

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Cyber-Mitch to this issue.

  3. akasom-creator commented on Sep 28, 2026

    @akasom-creator

    @akasom-creator has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    I’d like to work on this because it’s a good cleanup that improves type safety without changing behavior. I’d trace each "as any", replace it with proper Fastify/TypeScript types or "unknown" with type guards, then run strict TypeScript checks and tests to catch any issues.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @akasom-creator to this issue.

  4. drips-wave commented on Sep 29, 2026

    @drips-wave

    Congratulations, @Cyber-Mitch! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @Cyber-Mitch: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  5. grantfox-oss commented on Sep 30, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @Cyber-Mitch's PR #507 was approved and merged by @DeFiVC.

    🏆 @Cyber-Mitch: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,126 total points). Track your full progress on GrantFox.

    👏 Great work, @Cyber-Mitch! Keep contributing to ChainLearnOfficial.

  6. drips-wave commented on Sep 30, 2026

    @drips-wave

    This issue has been completed by @Cyber-Mitch as part of the Stellar Wave Program's 9th Wave 🥳

    😎 @Cyber-Mitch: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions