rspack icon indicating copy to clipboard operation
rspack copied to clipboard

remove all @ts-expect-error

Open hardfist opened this issue 1 year ago • 7 comments

https://github.com/web-infra-dev/rspack/pull/3863 introduces lots of //@ts-expect-error as workaround to enable typecheck test, but we should fix and remove all of it

hardfist avatar Nov 14 '23 13:11 hardfist

I would like to crush all the type errors in the code(call me TS error crusher). Would you like to assign this to me?

There are pretty many of them so would you think that curating a list first would be a better approach?

Thanks!

HerringtonDarkholme avatar Nov 14 '23 19:11 HerringtonDarkholme

I would like to crush all the type errors in the code(call me TS error crusher). Would you like to assign this to me?

There are pretty many of them so would you think that curating a list first would be a better approach?

Thanks!

Yes, type gymnastics is back!

hardfist avatar Nov 14 '23 23:11 hardfist

Let me first recap the current status of ts-error usage in the repo.

Overview

At the moment, more specifically eea9d067073930c350c5ad95f5c1ad89d6c6d424, rspack has 302 ts-expect-errors.

Package Name ts-expect-error Count
packages/rspack-cli 19
packages/rspack-dev-server 41
packages/rspack-plugin-html 18
packages/rspack-plugin-react-refresh 3
packages/rspack 211
scripts 1
webpack-test 9

Rspack core packages breakdown

Since rspack core packages itself has many ts-expect-error, a breakdown will be helpful to make every pull request change small and manageable.

Package Name ts-expect-error Count
src 53
src/builtin-loader 1
src/config 10
src/lib 29
src/loader-runner 25
src/logging 9
src/node 14
src/stats 18
src/util 50
test 2

Strategy

Type errors are nasty to see in codebase but should not impact runtime behavior. To minimize the impact of fixing type error, changes will be split into small, standalone pull request and every change will aim at being type-level only.

Progress Tracking

  • [x] packages/rspack-cli
  • [ ] packages/rspack-dev-server
  • [x] packages/rspack-plugin-html
  • [ ] packages/rspack-plugin-react-refresh
  • [x] scripts
  • [ ] webpack-test
  • [ ] packages/rspack
    • [ ] src
    • [ ] src/builtin-loader
    • [ ] src/config
    • [ ] src/lib
    • [ ] src/loader-runner
    • [ ] src/logging
    • [ ] src/node
    • [ ] src/stats
    • [ ] src/util
    • [ ] test

HerringtonDarkholme avatar Nov 15 '23 03:11 HerringtonDarkholme

Please remember not modify any tsconfig during refactor, because it's easy to be broken like https://github.com/web-infra-dev/rspack/pull/4650

hardfist avatar Nov 15 '23 06:11 hardfist

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Mar 07 '24 02:03 stale[bot]

bump

HerringtonDarkholme avatar Mar 07 '24 02:03 HerringtonDarkholme

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar May 06 '24 02:05 stale[bot]

@SoonIter is this finished?

hardfist avatar Sep 05 '24 15:09 hardfist

@SoonIter is this finished?

not all but most of them, there are still several parts

  1. packages/rspack/loader-runner/index.js
  2. packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts
  3. packages/rspack/src/MultiCompiler.ts
  4. packages/rspack/src/Watching.ts
  5. rspack-dev-server (cannot be removed because of private API)

and some one or two small pieces

SoonIter avatar Sep 06 '24 01:09 SoonIter