Skip to content

lint: convert 24 'catch (e: any)' to 'catch (e: unknown)'#50

Closed
adm01-debug wants to merge 1 commit into
mainfrom
claude/lint-any-generics
Closed

lint: convert 24 'catch (e: any)' to 'catch (e: unknown)'#50
adm01-debug wants to merge 1 commit into
mainfrom
claude/lint-any-generics

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

Summary

R5.3 — converts 24 catch (e: any) clauses to catch (e: unknown) across 15 files.

The catch-clause type defaults to unknown in TypeScript 4.4+, which is the canonical typing — it forces the catch body to narrow the error before accessing .message / .stack, surfacing real bugs where consumers assumed an Error shape on a thrown non-Error value.

Why this is safe

tsc --noEmit passes. That means every consumer of these catch bindings already handles unknown correctly — typically via:

err instanceof Error ? err.message : String(err)

If any consumer were doing err.message directly, TypeScript would have errored out. None did.

Files touched (15)

File Cases
src/components/admin/ImageUploadButton.tsx 1
src/components/admin/users/useUserManagement.ts 4
src/components/admin/products/video-gallery/useProductVideoGallery.ts 1
src/components/admin/security/SecureUploadManager.tsx 2
src/components/magic-up/PromptGenerator.tsx 1
src/components/quotes/QuoteConvertToOrder.tsx 1
9 others 14

Validation

Metric Before After
no-explicit-any 273 249 (−24)
tsc --noEmit
npm run test 90 baseline failures 90 (same)

What's still left in no-explicit-any

Pattern Count Status
Plain : any annotations 129 covered by PR #45 (in flight)
: any[] arrays 36 covered by PR #38 (in flight)
Record<string, any> 32 covered by PR #38
as any casts 19 covered by PR #38
<any> generics 17 needs caller-side narrowing review
[key: string]: any index sigs 9 covered by PR #38
Other / Promise<any> 7 per-case

https://claude.ai/code/session_01KWeDG


Generated by Claude Code

The 'catch' clause type defaults to 'unknown' in TypeScript 4.4+,
which is the canonical typing — it forces the catch body to narrow
the error before accessing .message / .stack, surfacing real bugs
where consumers assumed an Error shape on a thrown non-Error value.

Hand-verified: tsc --noEmit passes, meaning every consumer of these
catch bindings already handles 'unknown' correctly (typically via
'err instanceof Error ? err.message : String(err)').

## Files touched (15)

  src/components/admin/ImageUploadButton.tsx                          (1)
  src/components/admin/users/useUserManagement.ts                     (4)
  src/components/admin/products/video-gallery/useProductVideoGallery.ts (1)
  src/components/admin/security/SecureUploadManager.tsx               (2)
  src/components/magic-up/PromptGenerator.tsx                         (1)
  src/components/quotes/QuoteConvertToOrder.tsx                       (1)
  + 9 others (one occurrence each)

## Validation

  no-explicit-any  273 → 249 (−24)
  tsc --noEmit     exit 0 (all consumers narrow correctly)
  tests            no regressions (90 baseline failures)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51c0fd5f-a3e9-43c5-bc77-815d035f2f19

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/lint-any-generics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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