web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.07k stars 521 forks source link

[Tracking]: JS -> TS refactor the remaining .js file to .ts and esm #7225

Open SoonIter opened 1 month ago

SoonIter commented 1 month ago

What subject does this issue tracking?

JS -> TS

  1. refactor the remaining .js file to .ts
  2. remove all ts-expect-error
  3. use typescript rather than JSDocs
  4. It is best not to use default imports or exports, https://github.com/microsoft/TypeScript/issues/59257

https://github.com/web-infra-dev/rspack/issues/4640

### Rename to `.ts` file
- [ ] https://github.com/web-infra-dev/rspack/pull/7132
- [ ] https://github.com/web-infra-dev/rspack/pull/7136
- [x] packages/rspack/src/ModuleTypeConstants.js & packages/rspack/src/Template.js
- [x] packages/rspack/src/lib
- [x] packages/rspack/src/config
- [x] packages/rspack/src/util
- [x] packages/rspack/src/loader-runner
- [x] packages/rspack/src/builtin-plugin/css-extract/hmr
- [x] packages/rspack-dev-server/src/ansiHTML.js

Type Coverage

### Increase type coverage
- [x] src/lib/formatLocation.ts
- [x] src/logging/runtime.ts
- [x] src/util/webpack.ts
- [x] src/logging/truncateArgs.ts
- [x] src/node/nodeConsole.ts
- [x] src/builtin-plugin/EnableWasmLoadingPlugin.ts
- [x] src/builtin-plugin/EnableChunkLoadingPlugin.ts
- [x] src/util/memoize.ts
- [x] src/stats/StatsFactory.ts
SoonIter commented 1 month ago

A very huge task, pr welcome~ :D

SoonIter commented 1 month ago

Use https://github.com/alexcanessa/typescript-coverage-report to count the typescript coverage

Before

image

After #7289

Still remaining some ts files

image

our goal is reach >= 97%, so if you are interested in fixing some typescript any problem, also pr welcome ~

wxiaoyun commented 1 month ago

I will work on src/stats/StatsFactory.ts @shulaoda

shulaoda commented 1 month ago

I will work on src/stats/StatsFactory.ts @shulaoda

I am working on src/logging/truncateArgs.ts 👀

wxiaoyun commented 1 month ago

Thanks for leaving utils/webpack Please let me work on it ❤️

wxiaoyun commented 1 month ago

I will work on src/node/nodeConsole.ts as well :heart:

SoonIter commented 1 month ago

after #7437

image

our type coverage reach 95.38%, type coverage of each file >= 80%

👏🏻👏🏻👏🏻Thank you all

any pull request to increase type coverage is acceptable

type coverage contribution guide

  1. run pnpm install cd ./packages/rspack
  2. run npx typescript-coverage-report
  3. view files with low type coverage to contribute
shulaoda commented 1 month ago

type coverage contribution guide

  1. run pnpm install
  2. run pnpm run type-coverage
  3. view files with low type coverage to contribute

Should we add a script in package.json?

SoonIter commented 1 month ago

Should we add a script in package.json?

Sorry, updated with npx typescript-coverage-report

Technologeek commented 4 days ago

Hey @SoonIter Still relevant to increase the type coverage for some of the files mentioned?

shulaoda commented 4 days ago

Hey @SoonIter Still relevant to increase the type coverage for some of the files mentioned?

Welcome, try to do it.

SoonIter commented 4 days ago

Hey @SoonIter Still relevant to increase the type coverage for some of the files mentioned?

yeah, pr welcome