koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.24k stars 3.23k forks source link

Feat: convert koa to ts #1848

Open spence-s opened 2 weeks ago

spence-s commented 2 weeks ago

Checklist

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:

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.

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.