Skip to content

refactor: convert @ts-ignore to @ts-expect-error where the error always fires#7243

Open
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:chore/ts-expect-error
Open

refactor: convert @ts-ignore to @ts-expect-error where the error always fires#7243
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:chore/ts-expect-error

Conversation

@tomas-zijdemans

Copy link
Copy Markdown
Contributor

Converts 16 @ts-ignore comments across 8 files to @ts-expect-error. No runtime changes, comments only.

@ts-ignore suppresses an error whether or not it exists, so when a suppressed error gets fixed upstream, the stale comment sticks around and hides future problems. @ts-expect-error fails the build the moment the error disappears, which makes it self-cleaning. The compiler now guards these 16 spots for free.

I audited all 22 @ts-ignore comments in the repo and only converted the ones where the error is guaranteed in every configuration:

  • Test files passing deliberately invalid arguments (csv, collections, crypto, text)
  • testing/mock.ts: the TS2509 in constructorSpy is inherent to extending a generic constructor
  • random/_test_utils.ts: typed-array mocking that can't satisfy the constructor types
  • _tools/check_docs.ts: accessing .doc on the un-narrowed JsDocTag union

The remaining 8 stay as @ts-ignore on purpose. Their errors are conditional: Deno.lint only exists in Deno >= 2.2 types, the media_types comments work around dnt issue #148 (no error under Deno), time_test.ts depends on runtime lib types, and the FFI type in cli/_tools needs --unstable-ffi. Converting those would break the cross-version CI matrix.

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (ad7c87b) to head (3edcadb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7243   +/-   ##
=======================================
  Coverage   95.00%   95.00%           
=======================================
  Files         617      617           
  Lines       51674    51674           
  Branches     9326     9326           
=======================================
+ Hits        49093    49094    +1     
  Misses       2038     2038           
+ Partials      543      542    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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