Koa: Koa TypeScript - Type Definition request

Created on 26 Oct 2015  路  16Comments  路  Source: koajs/koa

I am using Koa and TypeScript for server-side development.

Since Koa 2.0.0 is being developed in ES2015, it will be helpful to provide type definitions and reference them in koa's package.json file for automatic IDE integration and type assistance.

This requirement is also discussed here:
https://github.com/borisyankov/DefinitelyTyped/issues/4796

Most helpful comment

I think this is a good idea. To clarify, it's only about a _definition_ file. Not rewriting the whole project. Express has definitions too. It allows awesome IntelliSense in VS Code for example by just doing tsd install koa. At the moment the definitions are all in the DefinitelyTyped Repo but there are many discussions to move to an approach where frameworks bundle their definitions.

All 16 comments

-1 from me personally, koa is a javascript project. If it could live in its own project I _could_ see it being added to the koajs org though.

-1 for me too. The API is usually fixed and changes usually address performance or use case issues. Having this feature be a separate project should be just fine.

I think this is a good idea. To clarify, it's only about a _definition_ file. Not rewriting the whole project. Express has definitions too. It allows awesome IntelliSense in VS Code for example by just doing tsd install koa. At the moment the definitions are all in the DefinitelyTyped Repo but there are many discussions to move to an approach where frameworks bundle their definitions.

+1. Separate or bundled like immutable. But would definitely be useful.

There is express.js' type definition file: https://github.com/borisyankov/DefinitelyTyped/blob/master/express/express.d.ts
and express.js is still a javascript project as you know, the type definition file doesn't change any original code.

Typescript supports async function now for node.js 4.x .
With a promisify library and async function, express.js is good enough, and koa.js is not that appealing to me now.

Yeah I get the part that this is just about adding a definition file to koa, but I'm not interested in maintaining it and afaik other koa maintainers or at least the majority aren't / aren't typescript users either.

The point of "koa is a javascript" project was that this is a javascript library and the core koa team should only have to worry about javascript. Adding a typescript definition file adds maintenance cost, it will need to be kept up to date with all api changes, questions about it will need to be answered. Also, if we "officially support" typescript I can see bug reports being created with typescript snippets, which will cause friction as well.

So, still -1 from me personally.

-1 for typescript definitions _in koa_ for the same reasons @juliangruber mentioned- no reason to officially support it- but by all means, would be neat for this to be something separate though

It depends on the intention of the offical developers whether to write d.ts files, but seriously there are whole bunch of definition files not written by offical developers instead enthusiasts.

However an offical d.ts is always nice, but I suggest you write by your own if you have time/vigor and call other enthusiasts to work together.

I get that this topic is not getting too much love, but I would love to see typings bundled with the module though. Imho it is the only sensible place where typings could be maintained, as mapping modul (/api) versions to commit ids from DefinitelyTyped is just very ugly. One might add bonus point for including the typings that they also are a not too bad very low level api "documentation".

@uwinkelvos i see how this is inconvenient for you, but in this situation that's not because of koa, but because of typescript. Maybe if typescript had better tooling this wouldn't be a problem at all. I'm closing now since koa maintainers aren't interested in maintaining the definition file. However we're still open to adding it to the koajs org, like at /koajs/ts.

Something like this might be a solution:

Since TypeScript 2.0 packages like: npm install @types/package-name are supported. You could look into something like npm install @types/koajs.

@galkowskit the @types typings are installed from DefinitelyTyped.

I'd be very interested in typescript support as it powers a lot of JS autocompletion systems. While I don't personally use typescript, I think the autocompletion is a very important upside.

There are well-maintained typings for koa in the types org: https://github.com/types/npm-koa
They can be installed with typings install koa until https://github.com/Microsoft/types-publisher/issues/4 is implemented.

Going to unsubscribe from this thread as included definitions were declined and there is a good alternative.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coodoo picture coodoo  路  4Comments

sibelius picture sibelius  路  3Comments

imkimchi picture imkimchi  路  4Comments

koalex picture koalex  路  3Comments

rainesinternationaldev picture rainesinternationaldev  路  5Comments