Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: convert koa to ts #1848

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Feat: convert koa to ts #1848

wants to merge 2 commits into from

Conversation

spence-s
Copy link

@spence-s spence-s commented Nov 15, 2024

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

I had converted koa to TS last year as a bit of a learning exercise and the thought of having my own custom TS framework, but I ended up not using it.

When I saw koa was open to a TS rewrite for v3, I decided to dust this off.

Its an attempt to keep the v2 koa code as close to untouched as possible while:

  • Making koa esm only
  • Writing koa completely in strictly typed TS with type aware linting on
  • Absolutely minimal changing the JS code
  • pass all tests with minimal changes to the tests

In addition, I also wrote it with xo as the linter, I was going to attempt to convert to ts-standard, but it was going to be a pain in the butt, so I just made xo lint ts files and kept standard the linter for js files.

The tests remain in js and they test the TS build output.

  • The lazy import of async_hooks and version error has been removed.
  • The test of the ESM conversion was removed since its ESM only here.

One thing of note is that these types are not compatible with the current definitely typed ts types.

EDIT: also note all the tests are passing in each node version, but there is a problem with experimental code cov or something, and node 20 has some known issues with sourcemaps causing issues. see: nodejs/node#55054

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.

1 participant